A progressive Node.js framework for building efficient and scalable server-side applications.
This project is done with Nest
This is a backend service with:
- login/register functionallyty operating with Local passport strategy (username / password). And once registered the JWT stratygey is enforced for some endpoints that need authorization.
- certificates that can be aquired by authenticated users and transferred by authenticated users
Swagger api is at: localhost:3000/api. You need to login and paste the authorization token in the top right. Once you are logged in, all authrorized endpoints are available for use.
I've also added a postman collection file Certificates NEST.postman_collection
in the repository you can import and use once you have everything up and running.
I've included the .env
file for convenience.
Prerequisites
docker
(20.10.21)
docker compose
node
(v18.12.1)
- Install all the necessary dependencies:
$ npm install
- Create a docker volume named
data
andtestdata
. These volumes will hold our regular and test database respectivly.
docker volume create data
docker volume create testdata
- start database:
docker compose up
#just run the app
$ docker compose up
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
NOTE: Make sure to run either
npm run start
ornpm run start:dev
before running thenpm run seed
, because this will make a connection to the runningg postgres database and will create the tables based on the loaded entities in the configuration.
I couldn't use typeorm-seed
becuase the typeorm
library is version 0.3.x
and typeorm-seed
library still does not support that version.
I found an alternative typeorm-extension
that works with typeorm 0.3.x
but it was still in devlopment so not everything in the documentation works so I had to make some workarounds (check setup.ts
file). I use a jest global setup to, setup the database and run the seed before the tests run. Once the database is created you can run the individual test command npm run seed -- -d ./data-source-test.config.ts
.
# seed test database
npm run test:e2e //to setup test database and seed it and run tests afterwards
# seed main database
npm run seed //after you've started the application, so the tables are created
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest is MIT licensed.