Back end for a hobby chat application. Author Perttu Kärnä
Core technologies used:
- Express as core REST api
- Express-JWT for auth management
- Sequelize as ORM
- PostgreSQL as database
- Docker as container platform
- Jest as testing framework
To get this project running locally, you'll need Docker and docker-compose tools. This project uses docker-compose reference v2.
- Clone this repository to your local machine
- Create a volume container for the database by running
docker volume create --name=chatdb
- Build containers by running
docker-compose build
in the project root - Run containers with
docker-compose up
(provide -d flag for running in background)- The back end will be available at localhost, port 3000
- To get into the containers, find out containers id or name by running
docker ps
and then rundocker exec -it <container-id-or-name> /bin/sh
- Press Ctrl + C to shut down the containers
- If running on background, or if the containers abort, run
docker-compose down
in the project root
- If running on background, or if the containers abort, run
For more docker commands read their documentation.
There is REST API tests for this project at tests -folder. To run tests locally, use docker-compose-test.yml -file. Please note, that this will run tests continuously.
- For single run, use
npm test
- For continuous testing, use
npm run test:ci
- This will watch for file changes and runs the tests when changes are detected
- Please note that you'll need PostgreSQL database and correct configs for local database in config.js
If you want to run a single run, change the docker-compose-test.yml to use command npm test
for running the app container. For continuous run, it should be npm run test:ci
.
- Build images by
docker-compose -f docker-compose-test.yml build
- Run containers by
docker-compose -f docker-compose-test.yml up
- If you need to change container build process (Dockerfile.test) or package.json -file, just run
docker-compose -f docker-compose-test.yml up --build
to build and run containers
- If you need to change container build process (Dockerfile.test) or package.json -file, just run
- Bring the containers down with Ctrl + C