Envolution is a platform that connects environmental organizations with volunteers striving to make an impact on climate change. Based on their geolocation, this PWA matches volunteers with projects that reflect their specific ecological interests.
This is the back-end repository. The front-end can be found at GitHub
To use the Envolution server consider the following:
- Begin by forking this repository, and cloning it to your computer with the following command:
git clone https://github.com/jonas-wedemeyer/envolution-server.git
- For macOS users, use Homebrew to install PostgreSQL. Install and start PostgreSQL on your machine by entering the two commands below in your terminal:
brew install postgres
brew services start postgres
For Windows users please refer to the following site to install PostgreSQL: https://www.postgresql.org/download/windows/
- Set the environment variables in the
example.env
file. You can leave theNODE_ENV
andDB_NAME
set toproduction
andenvolution
correspondingly. Create a password and set it toJWT_SECRET
. The DB_USR and DB_PASS variables correspond to your PostgreSQL account username and password. Create a Cloudinary account at the following site: https://cloudinary.com/users/register/free
NODE_ENV=production
SERVER_PORT=
JWT_SECRET=
DB_USR=
DB_PASS=
DB_NAME=envolution
DB_HOST=db
CLOUDINARY_URL=
- After cloning the repo you'll have to decide whether or not to use Docker to run the server. Below you’ll find the steps for running the server with or without Docker.
###With Docker
-
Start running Docker on your machine
-
In the
example.env
file set the variableDB_HOST
todb
-
Rename the
example.env
file to.env
and save the file -
Open your terminal and enter the command
docker-compose up --build
- Once Docker is running open a new terminal window and enter the command below to start PostgreSQL, replacing
username
with your PostgreSQL username
psql -h localhost -p 5432 -U username envolution
- To seed the database, open a new terminal window and enter the following script
bash scripts/seed-db.sh
###Solving potential errors when running Docker:
- If you get an error regarding Sequelize that indicates port
5432
is already in use, change the host port within thedocker-compose.yml
file from5432
to a number above 3000, for instance4000
. The final result will be the following:
ports:
- 4000:5432
- If you get an error regarding exisiting node modules, specifically bcrypt, clean your Docker containers, images, and build cache with the Docker command below. For more information on this refer to Docker documentation: https://docs.docker.com/engine/reference/commandline/system_prune/
docker system prune
###Without Docker
-
In the
example.env
file set the variableDB_HOST
todb
-
Rename the
example.env
file to.env
and save the file -
Start PostgreSQL, create a new database, and connect to it with the following commands:
psql postgres
postgres=# CREATE DATABASE envolution;
postgres=# \c envolution;
Your bash should now look like this:
envolution=#
- Set a password for the current PostgreSQL user with the following command:
envolution=# ALTER USER <user_name> WITH PASSWORD 'new_password';
- Run the server with the following:
npm run dev
- To seed the database, open a new terminal window and enter the following:
npm run seed:all
- Koa
- Sequelize
- PostgreSQL
- JWT
- Docker
##Developers