A simplified stock control application.
This project is a simple application that satisfies the needs of Resinas Botânicas virtual store (@resinasbotanicas on instagram). Also, it's a proof of concept (POC) to get started with typescript.
- Clone this repository
- Run
npm i
ornpm install
to installl dependencies - Create a PostgreSQL database, you can choose the name you prefer
- Configure the PostgreSQL database using the
dump.sql
file - Create a
.env
file with aPORT
and aDATABASE_URL
as in.env.example
file - Run
npm run dev
to start the local server
Table "categories" infos:
id | name |
---|---|
1 |
brinco |
2 |
anel |
3 |
colar |
4 |
pulseira |
5 |
quadro |
POST /product
{
"categoryId": 1,
"name": "cobra coral",
"quantity": 3
}
Status: 201 Created
POST /product-sold
{
"name": "cobra coral"
}
Status: 201 Created
-
All products:
GET /products
-
Products by category:
GET /products?category=brinco
- All products
Status: 200 OK
[
{
"id": 1,
"name": "borboleta",
"quantity": 1,
"category": "colar"
},
{
"id": 2,
"name": "estrela vermelha",
"quantity": 2,
"category": "brinco"
}
]
- Products by category "brinco":
Status: 200 OK
[
{
"id": 2,
"name": "estrela vermelha",
"quantity": 2,
"category": "brinco"
}
]
GET /product/:id
Status: 200 OK
{
"id": 1,
"name": "borboleta",
"quantity": 1,
"category": "colar"
}
-
All products:
GET /total-products-available
-
Products by category:
GET /total-products-available?category=colar
- All products
Status: 200 OK
{
"total": 42
}
- Products by category "colar":
Status: 200 OK
{
"total": 12
}
-
All products:
GET /total-products-sold
-
Products by category:
GET /total-products-sold?category=anel
- All products
Status: 200 OK
{
"total": 39
}
- Products by category "anel":
Status: 200 OK
{
"total": 11
}
PATCH /update-product
{
"name": "estrela vermelha",
"quantity": 1
}
Status: 200 OK
DELETE /delete-product/:id
Status: 204 No Content