Node.js v21.1.0
NestJS
Postgres
TypeORM
$ yarn install
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>
To run migrations:
$ yarn db:migrate
To drop database just in case:
$ yarn db:drop
# development
$ yarn run start
# watch mode
$ yarn run start:dev
# production mode
$ yarn run start:prod
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": ""
}
}
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": ""
}
}
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
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": ""
}