CRUD API for product updates. Built with NodeJS/Express, TypeScript and Prisma as ORM.
Routes | Description | Request body | Response body |
---|---|---|---|
POST /user |
Create a new user for API auth token | Yes | Bearer Token |
POST /user/login |
Login existing user to get API auth token | Yes | Bearer Token |
DELETE /user/:username |
Delete existing user | No | Message object |
GET /product |
Get all products | No | Array of objects |
GET /product/:id |
Get a single product by id | No | Object |
POST /product |
Create a single product | Yes | Object |
PUT /product/:id |
Update a single product | Yes | Object |
DELETE /product/:id |
Delete a single product | No | Object |
GET /update |
Get all products updates | No | Array of objects |
GET /update/:id |
Get a single product update by id | No | Object |
POST /update |
Create a single product update | Yes | Object |
PUT /update/:id |
Update a single product update | Yes | Object |
DELETE /update/:id |
Delete a single product update | No | Object |
Prerequisites:
- Clone and open the project on Visual Studio Code or via terminal.
- Install dependencies running
npm install
- Add DB connection string from Render on
DATABASE_URL
variable to the corresponding.env
file and on./prisma/schema.prisma
datasource url. - Run prisma migrations with
npx prisma migrate dev --name init
- Run the project with
npm run dev
- Create a new user and use the returned token as
Bearer Token
for authentication.
NOTE: Check postman_collection.json
for all available routes.
Run all tests with npm run test
or by file with npm run test filename.test.ts
.
Check ./tests
folder for unit and integrations tests.
NOTE: Check files and add a valid Bearer Token
before running tests.
MIT License
Copyright (c) 2023 Anibal Ventura