Create the CRUD endpoints to the bellow entity:
Equipment
{
model: string,
category: enum ("cartucho" | "toner"),
ppm: integer (0 to 999999),
wifi: boolean,
consumption: number (0 to 999999)
}
Required: model, category
The test should be done using:
- Database: sqlite3
- Back-end: Node.js
- Source code in english
- NodeJS backend using NestJs Framework and Typescript
- Jest as the testing framework
- Swagger
- NestJS Logger
- files
.spec.ts
- unit tests - files
.e2e-spec.ts
- end to end tests
- clone the git repository
- run
yarn install
- run
npm start
to start the aplication
- open the terminal and run the command of the chosen test type:
- to run all tests:
npm run test
- to run unit tests:
npm run test:unit
- to run end to end tests:
npm run test:e2e
If using VSCode, inside src/modules/module-name/api, you may find .http
files that works with the extension REST Client
https://marketplace.visualstudio.com/items?itemName=humao.rest-client
- Install the extension
- Start the aplication
- Open the .http file
- Click send (replace the id when necessary)
Access http://localhost:3000/docs to view swagger documentation.
I've used clean architecture with concepts of "Domain Driven Design" (which is a design tool and not an architecture). I've separated the context by components (modules), which also follow NestJS standards. This module separation has an monolitic backend-api in mind, wich can be easily expanded. For a micro-service (with a single context), i would bring everyting inside the modules folder foward, separating the content on their corresponding layers.
The services (usecases) contains the business rules of the application.