Skip to content

TarasMakarchuk/corporate_structure

Repository files navigation

NodeJS NestJS RxJS Typeorm TypeScript Postgres Swagger JWT NPM Postman Git WebStorm

Description

A tiny server app based on Node.js (Nest.js). The app implements simple organization user structure management operations. The following user roles are supported: a. Administrator (top-most user, only he can change user roles); b. Boss (any user with at least 1 subordinate); c. Regular user (user without subordinates). Each user except the Administrator must have a boss (strictly one). The following REST API endpoints exposed:

  1. Register user.
  2. Authenticate as a user.
  3. Return list of users, taking into account the following:
  • administrator can see everyone;
  • boss can see herself and all subordinates (recursively);
  • regular user can see only himself.
  1. Change user's boss (only boss can do that and only for his subordinates).

Swagger documentation 📋

Postman collections 📬

Admin's credentials 🔐

 filrsrtName: "Admin"
 lastName: "Admin"
 enail: "admin@gmail.com"
 password: "test"

Installation ☕

$ npm install
or
$ yarn install

Setup environment on the Server🔧

# development mode
1. Create inside server dir file .env
2. Copy content from .env.dist to .env
3. Change the data in the .env file to required

Migrations 🔧

# generate migrations
$ npm run migration:generate src/db/migrations/migration_name

# run migrations
$ npm run migration:run

Seeding the database 🌱

# seed table
$ npm run seed:run

Running the app 🚀

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Running the app and the database in the Docker 🐋

Change in the .env file variable 
from 
POSTGRES_HOST=localhost 
to 
POSTGRES_HOST=docker-host
# build the container
$ docker-compose build

# start the container
$ docker-compose up

# stop the container
$ docker-compose down