This is a simple inventory system, where you can create, read, update, and delete products.
GET /products - get all products
GET /products/:id - get a specific product
POST /products - create a new product
PUT /products/:id - update a product
DELETE /products/:id - delete a product
Just run npm install
or yarn
to install all dependencies.
npx prisma init --datasource-provider sqlite
now we need to run a migration in order to create our Products
table
npx prisma migrate dev --name init
and finally run the project!
npm run dev
[
{
"id": 1,
"name": "Super cool thing",
"price": 2,
"qty": 30,
"created_at": "2022-12-05T17:53:12.243Z"
}
]
assuming that the id we queried is 1
{
"id": 1,
"name": "Super cool thing",
"price": 2,
"qty": 30,
"created_at": "2022-12-05T17:53:12.243Z"
}
example body
{
"name": "Super cool thing",
"price": 2,
"qty": 30
}
response
{
"id": 1,
"name": "Super cool thing",
"price": 2,
"qty": 30,
"created_at": "2022-12-05T18:15:55.412Z"
}
example body
{
"name": "Super cool thing",
"price": 5,
"qty": 15
}
response
{
"id": 1,
"name": "Super cool thing",
"price": 5,
"qty": 15,
"created_at": "2022-12-05T17:53:12.243Z"
}
200 OK, 404 Not Found or 500 Internal Server Error