Skip to content

AuraEnabled/ictp

Repository files navigation

Test project

Node.js v21.1.0

Stack

NestJS
Postgres
TypeORM

Installation

$ yarn install

Prerequisites

After installing dependencies you need first to provide file .env in the way shown in .env.example inside root directory.

# More likely you will use localhost
DB_HOST=<YOUR_DB_HOST>
# Default 5432 for postgres
DB_PORT=<YOUR_DB_PORT>
DB_USERNAME=<YOUR_DB_USERNAME>
DB_PASSWORD=<YOUR_DB_PASSWORD>
DB_NAME=<YOUR_DB_NAME>
# Salt for hashing password
BCRYPT_SALT=<USER_PASSWORD_HASH_SALT>
JWT_SECRET=<YOUR_JWT_SECRET>

Running migrations

To run migrations:

$ yarn db:migrate

To drop database just in case:

$ yarn db:drop

Running the app

# development
$ yarn run start

# watch mode
$ yarn run start:dev

# production mode
$ yarn run start:prod

Endpoints

Registration

No authentication required
Method: POST
URL: http://localhost:3000/api/auth/signUp
Payload format:

{
    "user": {
        "firstname": "",
        "lastname": "",
        "email": "",
        "password": "",
        "role": "",
        "bossId": ""
    }
}

Response format:

{
    "user": {
        "firstname": "",
        "lastname": "",
        "email": "",
        "role": "",
        "id": 1,
        "token": ""
    }
}

Login & get JWT

No authentication required
Method: POST
URL: http://localhost:3000/api/auth/signIn
Payload format:

{
  "user": {
    "email": "",
    "password": ""
  }
}

Response format:

{
  "user": {
    "id": 1,
    "firstname": "",
    "lastname": "",
    "email": "",
    "token": ""
  }
}

List of users (hierarchically)

Authentication required
Method: GET
URL: http://localhost:3000/api/user/details
Headers:

{
  "Authorization": "Bearer <USER_JWT_HERE>"
}

Response format for Administrator (diagram):

├─admin
├─boss
│ ├─subordinate
│ └─subordinate
└─boss
  ├─subordinate
  ├─subordinate
  └─subordinate

Response format for Boss (diagram):

boss
├─subordinate
├─subordinate
└─subordinate

Change Boss of the user

Authentication required
Method: PUT
URL: http://localhost:3000/api/user/change-boss
Headers:

{
  "Authorization": "Bearer <USER_JWT_HERE>"
}

Payload format:

{
  "user": {
    "userId": 9,
    "newBossId": 15
  }
}

Response format:

{
  "id": 9,
  "firstname": "",
  "lastname": "",
  "email": "",
  "bossId": 15,
  "role": ""
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published