Johan-FF / Enterprise-Project-Rest-API---Nest-js

Backend created with Nest.js and the ORM Prisma and implementation of a Rest API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

Nest framework TypeScript starter repository.

This is a project that implements the Prisma ORM to query a simple database (the database is described in the DB section).

Installation

  1. Clone the repository:
git clone https://github.com/Johan-FF/Enterprise-Project-Rest-API---Nest-js.git
cd Enterprise-Project-Rest-API---Nest-js
  1. Install the required dependencies:
npm install

DB

modelo.png

For the database script see prisma/migrations/20240213152623_init/migration.sql or prisma/schema.prisma.

In general the tables have this structure:

type Enterprise = {
  enterpriseId: number;
  name: string;
  createdAt: Date;
  updateAt: Date;
}

type Project = {
  projectId: number;
  description: string;
  name: string;
  startDate: Date;
  endDate: Date;
  createdAt: Date;
  updateAt: Date;
  state: string;
  enterpriseId: number;
}

type User = {
  userId: number;
  username: string;
  password: string;
  profesionalHeadline: string;
  createdAt: Date;
  updateAt: Date;
  projectId: number;
  enterpriseId: number;
}

type UserProject = {
  userProjectId: number;
  projectId: number;
  userId: number;
}

The UserProject table has a zero or many relationship with the Project and User tables; the User and Project tables have a zero or many relationship with the Enterprise table.

API

METHOD URI BODY DESCRIPTION
GET /enterprise Returns a list of type Enterprise.
GET /enterprise/:id Returns a data of type Enterprise.
POST /enterprise { name: string; } Creates and returns the complete Enterprise type structure.
PUT /enterprise/:id { name: string; } Updates and returns the complete Enterprise type structure.
DELETE /enterprise/:id Removes and returns the complete Enterprise type structure.
GET /project Returns a list of type Project.
GET /project/:id Returns a data of type Project.
POST /project { description: string; name: string; state: string; enterpriseId: number; } Creates and returns the complete Project type structure.
PUT /project/:id { description: string; name: string; state: string; enterpriseId: number; } Updates and returns the complete Project type structure.
PUT /project/start/:id {} Updates the value of the Project startDate field.
PUT /project/end/:id {} Updates the value of the Project endDate field.
DELETE /project/:id Removes and returns the complete Project type structure.
GET /user Returns a list of type User.
GET /user/:id Returns a data of type User.
POST /user { username: string; password: string; profesionalHeadline: string; projectId: number; enterpriseId: number;} Creates and returns the complete User type structure.
PUT /user/:id { username: string; password: string; profesionalHeadline: string; projectId: number; enterpriseId: number;} Updates and returns the complete User type structure.
DELETE /user/:id Removes and returns the complete User type structure.
GET /user-project Returns a list of type UserProject.
GET /user-project/:id Returns a data of type UserProject.
GET /user-project/projects/:id Returns a list of records that have the User ID.
GET /user-project/users/:id Returns a list of records that have the Project ID.
DELETE /user-project/:id Removes and returns the complete UserProject type structure.

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

About

Backend created with Nest.js and the ORM Prisma and implementation of a Rest API.


Languages

Language:TypeScript 97.0%Language:JavaScript 3.0%