OKitel / nodejs2021Q4-service

https://github.com/rolling-scopes-school/basic-nodejs-course/blob/master/descriptions/rest-service.md

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RS School REST service

PostgreSQL, nodejs, Docker

This application is a Trello competitor. It can be used for managing tasks and boards. Backend is written in Typescript and uses Fastify framework to handle requests in nodejs server. It may be used on every type of OS because it works inside isolated Docker containers. Data is stored inside PostgreSQL database.

Prerequisites

Downloading

git clone https://github.com/OKitel/nodejs2021Q4-service.git

Installing NPM modules

npm install

Running application

npm start

After starting the app on port (4000 as default) you can open in your browser OpenAPI documentation by typing http://localhost:4000/docs/. For more information about OpenAPI/Swagger please visit https://swagger.io/.

Testing

After application running open new terminal and enter:

To run all tests without authorization

npm test

To run only one of all test suites (users, boards or tasks)

npm test <suite name>

To run all test with authorization

npm run test:auth

To run only specific test suite with authorization (users, boards or tasks)

npm run test:auth <suite name>

Development

If you're using VSCode, you can get a better developer experience from integration with ESLint and Prettier extensions.

Auto-fix and format

npm run lint

Debugging in VSCode

Press F5 to debug.

For more information, visit: https://code.visualstudio.com/docs/editor/debugging

Docker 🐳

This application is using docker compose file to declare and build images. Also it creates user defined network between containers. To run the entire app use the next command in your terminal in the project root directory

docker compose up

This command will build containers with app and postgreSQL database. The size of app container is 270 MB.

When containers start, the application waits for the Postgres container to start first.

If you want to keep your terminal free of logs you may use the next command

docker compose up -d

To see logs from the container in the detached mode use

docker compose logs -f

If any error occurs container will be automatically restarted.

Logs and data are stored outside containers (in volumes), that is why they will be saved even if you delete images from your PC and then rebuild it again.

Nodemon watches after changes inside src directory and will rebuild containers.

There is no need to rebuild images after changes inside .env file.

To stop containers use

docker compose stop

To stop and delete containers use

docker compose down

To delete images from your PC use

docker image rm <image ID>

The image of this app is in private Docker Hub repository okitel/rsschool-nodejs-service.

To launch tests you need to install all dependencies into the root directory. There are no tests inside docker containers.

Documentation

Typedoc is installed so you can generate documentation based on tsdoc. To do this, use the following script:

npm run docs

About

https://github.com/rolling-scopes-school/basic-nodejs-course/blob/master/descriptions/rest-service.md


Languages

Language:TypeScript 75.6%Language:JavaScript 23.5%Language:Shell 0.7%Language:Dockerfile 0.2%