This the backend for a project for a job-interview. You can find the Frontend here
$ npm install
Add a .env file in the root folder of the project, there is a .env.example that show what it should contain the .env file. You also are going to need to add a ormconfig.json file, this is for setting your local connection to your DB, in this project it was use PG 13, so is recomended that you use this version too in this project. This is the format of the ormconfig.json :
{
"type": "postgres", <== this should stay the same
"host": "localhost", <== this should stay the same, depends on your DB
"port": 5432, <== example, default port
"username": "root", <== example, default
"password": "root", <== example
"database": "database", <== example,
"entities": ["dist/**/**.entity{.ts,.js}"], <== this should stay the same
"migrations": [
"src/migration/**/*.ts" <== this should stay the same
],
"subscribers": [
"src/subscriber/**/*.ts" <== this should stay the same
],
"synchronize": true, <== this should stay the same
"cli":{
"migrationsDir":"./" <== this should stay the same
}
}
It should go in the root folder, right here:
use this command for generating the migrations
typeorm migration:generate -n test
once thats done all the tables will be created, and you can run the app. There are no seeds needed for this project.
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
GET:http://localhost:3000/employee
Gets all employees in the DB
POST:http://localhost:3000/employee
Post data to create a employee in the DB. Format of the json:
{
"firstName":string;
"secondName":string;
"firstLastname":string;
"secondLastName":string;
"position":string;
"deparment":string;
}
DELETE:http://localhost:3000/employee
Deletes a employee from the DB with the specify ID
{
id:number
}
GET:http://localhost:3000/employee/supervisor
gets all employees that are supervisor of another employee
POST:http://localhost:3000/employee/supervisor
Creates a new "Supervisor" (that is also a employee) to another employee. (see the MER here). json format:
{
employee:{
id:number
},
supervisor:{
id:number
}
}
DELETE:http://localhost:3000/employee/supervisor
Deletes a supervisor from a employee. json format:
{
id:number
}
POST:http://localhost:3000/employee/account
Associates an Account with an employee.Json format:
{
employee:{
id:number
},
account:{
id:number
}
}
GET:http://localhost:3000/employee/account
Gets all account associated to one employee (not all accounts need to have a employee as owner)
GET:http://localhost:3000/account
get all accounts in the DB
POST:http://localhost:3000/account
Creates a new Account. json format:
{
productNumber:string;
currentAmount:number;
}
DELETE:http://localhost:3000/account
Deletes a account with the specify ID. json format;
{
id:number
}
GET:http://localhost:3000/invoice
gets all invoices in the db (invoices are a combination of varios "transactions" made by one "employee" with an specific "account". (see the MER here)
POST:http://localhost:3000/invoice
creates a new invoice. json format:
{
concept:string;
aprovedBy:string;
sign:string;
startDate:Date;
endDate:Date;
}
DELETE:http://localhost:3000/invoice
deletes a invoice with the specify id. json format:
{
id:number
}
GET:http://localhost:3000/transaction
gets all transactions of all accounst in the DB.
POST:http://localhost:3000/transaction
Creates a new transaction. json format:
{
amount:string;
description:string;
sign:string;
originAccount:{
id:number;
};
destinyAccount:{
id:number;
};
}
DELETE:http://localhost:3000/transaction
Deletes a transaction with the specify id. json format:
{
id:number
}
Nest is MIT licensed.