Giter Club home page Giter Club logo

job-interview-backend's Introduction

npm npm npm

Description

This the backend for a project for a job-interview. You can find the Frontend here

Installation

$ npm install

Before Starting

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:

image

Running the migrations

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.

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

image

API´s availables

  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
}

License

Nest is MIT licensed.

job-interview-backend's People

Contributors

angelsucasas avatar

Watchers

 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.