Installation

Installation

To run the City Nature Challenge site locally, you will need to complete three steps (below):

  1. Install and run Strapi
  2. Create a PostgreSQL database
  3. Run Next.js

While this documentation will explain the basics of how to install and run the CNC site, one should have an understanding of Node.js, on which Strapi, Next.js and the project's serverless functions are written.

Install Strapi

For a more detailed walkthrough on how to install and run Strapi, please refer to the official Strapi documentation (opens in a new tab).

  1. Copy the cnc repo from the museum's GitHub

    git clone <repo URL>
  2. Check if Node.js is installed

    node --version

    a. If node is installed, make sure that the installed node version is the same as the projects. To check the project's node version, look at strapi-backend/package.json under engines.node.

    b. If node is not installed, install the project's node version (see above to check what version to install).

  3. Open terminal and enter strap-backend/

    cd strapi-backend/
  4. Install project modules

    npm install 
  5. Get .env file

    A .env should never be committed to a git repo and will therefore need to be supplied by another developer on the team.

Install/configure PostgreSQL

If PostgreSQL is not installed, it is recommended to use Postgres.app (opens in a new tab) (if using macOS).

  1. Create a new PostgreSQL database

  2. From the new PostgreSQL database, copy values for port (likely 5432), user, password, database name.

  3. Add the following key:value pairs in your .env (or replace the exisiting values if keys already exist) with values from new PostgreSQL database

    DATABASE_HOST=
    DATABASE_PORT=
    DATABASE_USER=
    DATABASE_PSWRD= 
    DATABASE_NAME=
  4. Import data into strapi

    npm run strapi import -- -f <location>

    For more information on where to find data exports and how the CNC site manages its automated export, please refer HERE.

Run/configure Strapi

  1. Run the strapi server

    strapi run develop
  2. Navigate to localhost:1337/admin (if not prompted in terminal)

  3. Log in (create account if needed)

  4. Navigate to Settings > Roles > Public

  5. Set all Permissions to find/findOne

  6. Test API by navigating to localhost:1337/api/pages

    You should recieve a JSON of all pages with their IDs.

Install/run Next.js

  1. In terminal, change directory to next-frontend

    cd ../next-frontend	
  2. Check node version

    node --version
  3. Make sure correct node version is installed

    See node version of next.js by checking next-frontend.package.json

  4. Run npm install

    npm install
  5. Run next.js server

    npm run dev
  6. Navigate to http://localhost:3000 (opens in a new tab)

    You should see the City Nature Challenge site.