Installation
To run the City Nature Challenge site locally, you will need to complete three steps (below):
- Install and run Strapi
- Create a PostgreSQL database
- 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).
-
Copy the cnc repo from the museum's GitHub
git clone <repo URL>
-
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 atstrapi-backend/package.json
underengines.node
.b. If
node
is not installed, install the project's node version (see above to check what version to install). -
Open terminal and enter
strap-backend/
cd strapi-backend/
-
Install project modules
npm install
-
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).
-
Create a new PostgreSQL database
-
From the new PostgreSQL database, copy values for port (likely 5432), user, password, database name.
-
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=
-
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
-
Run the strapi server
strapi run develop
-
Navigate to localhost:1337/admin (if not prompted in terminal)
-
Log in (create account if needed)
-
Navigate to Settings > Roles > Public
-
Set all Permissions to find/findOne
-
Test API by navigating to localhost:1337/api/pages
You should recieve a JSON of all pages with their IDs.
Install/run Next.js
-
In terminal, change directory to next-frontend
cd ../next-frontend
-
Check node version
node --version
-
Make sure correct node version is installed
See node version of next.js by checking
next-frontend.package.json
-
Run npm install
npm install
-
Run next.js server
npm run dev
-
Navigate to http://localhost:3000 (opens in a new tab)
You should see the City Nature Challenge site.