Coder Social home page Coder Social logo

certificates-rest's Introduction

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

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

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.

Installation

I've included the .env file for convenience.

Prerequisites

docker (20.10.21)

docker compose

node (v18.12.1)

  1. Install all the necessary dependencies:
$ npm install
  1. Create a docker volume named data and testdata. These volumes will hold our regular and test database respectivly.
docker volume create data
docker volume create testdata
  1. start database:
docker compose up

Running the app

#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 or npm run start:dev before running the npm 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.

Seed

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

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Support

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.

Stay in touch

License

Nest is MIT licensed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.