Instructions on how to start
Clone the repository
Start a Docker server. On Mac it can be done by opening the Docker app.
Run this command on repository's folder docker-compose up
TypeScript & Nest.js on top of Express.js.
PostgreSQL with TypeORM.
Authentication
Logging
Swagger documentation
erDiagram
device {
uuid id
string name
datetime created_at
string brand_id
}
device_brand {
uuid id
string name
}
device_brand ||--o{ device : "has"
Loading
curl -X POST http://localhost:3000/brands -H " Content-Type: application/json" -d ' {"name": "Blackberry"}'
curl -X POST http://localhost:3000/devices -H " Content-Type: application/json" -d ' {"name": "Blackberry Phone 1", "brandId": "<id from request 1>"}'
curl -X GET http://localhost:3000/devices/< id from request 2 >
curl -X PATCH http://localhost:3000/devices/< id> -H " Content-Type: application/json" -d ' {"name": "IPhone 12 Pro"}'
curl -X GET http://localhost:3000/devices
7. Query devices by brand name
curl -X GET " http://localhost:3000/devices?brandName=Blackberry&limit=10&offset=0"
curl -X DELETE http://localhost:3000/devices/< id>
Device creation time is added to the table automatically. (created_at)
Tests are implemented for src/device/device.service.ts in src/device/device.service.spec.ts
Soft delete is implemented. In order to replace a device, a new device is created and the old one is marked as deleted.
Pagination is implemented for the devices list. All query parameters are optional.
Appropriate indexes are added to the tables for better performance.