Git Product home page Git Product logo

nodejs2021q4-service's Introduction

RS School - NodeJS Course - 2021 Q4

Task 10. REST service - NestJS

About

REST service application which used PostgreSQL database with TypeORM library, built on NestJS framework and containerized by Docker

Technical task

How to install and use

  • Using Docker Compose
    1. Install Docker and Docker Compose
    2. Clone this repository
    3. Switch to task_10_nestjs branch
    4. Command string for start PostgreSQL DB in Docker: docker-compose up
    5. Run npm i to install dependencies
    6. Run npm run start:dev to start REST-service app
    7. Command string for tests (start app in docker image first): npm run test:auth
  • Application starts on port 4000 by default
  • After starting the app you can open in your browser OpenAPI documentation by typing http://localhost:4000/doc/

Application operate with the following resources

  • User (with attributes):
    { id, name, login, password }
  • Board (set of columns):
    { id, title, columns }
  • Column (set of tasks):
     { id, title, order }
  • Task:
    {
      id,
      title,
      order,
      description,
      userId, //assignee
      boardId,
      columnId
    }

Details

  1. For User, Board and Task REST endpoints with separate router paths should be created

    • User (/users route)
      • GET /users - get all users (remove password from response)
      • GET /users/:userId - get the user by id (ex. โ€œ/users/123โ€) (remove password from response)
      • POST /users - create user
      • PUT /users/:userId - update user
      • DELETE /users/:userId - delete user
    • Board (/boards route)
      • GET /boards - get all boards
      • GET /boards/:boardId - get the board by id
      • POST /boards - create board
      • PUT /boards/:boardId - update board
      • DELETE /boards/:boardId - delete board
    • Task (boards/:boardId/tasks route)
      • GET boards/:boardId/tasks - get all tasks
      • GET boards/:boardId/tasks/:taskId - get the task by id
      • POST boards/:boardId/tasks - create task
      • PUT boards/:boardId/tasks/:taskId - update task
      • DELETE boards/:boardId/tasks/:taskId - delete task
  2. When somebody DELETEs Board, all its Tasks should be deleted as well.

  3. When somebody DELETEs User, all Tasks where User is assignee should be updated to put userId = null.

Logging

The App implements a Logging service. Logging supports multiple logging levels and store logging level in environment variable.

Three levels of logging are supported:

  • error
  • warn
  • info

To define max logging level set variable LOGGING_LEVEL in the .env file.

  • Events with defined in .env logging level are logging to Console and file ./logs/common.log
  • Events with level error are logging to the file ./logs/error.log too
  • uncaughtException and unhandledRejection events are logging with level error

Developer environment and instruments

  • Node 16.13.0
  • JWT Authorization
  • TypeScript 4.5.2
  • NestJS - server-side node.js framework
  • PostgreSQL DB
  • TypeORM
  • Docker
  • Jest 27.3.1
  • Supertest 6.1.6
  • ESLint 8.3.0
  • TSDoc 0.0.4
  • Npm 8.1.0

nodejs2021q4-service's People

Contributors

igorbarbashov avatar

Watchers

James Cloos avatar  avatar

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.