This is a simple Node.js API project that uses Express, SQLite, and TypeScript. It provides endpoints to manage a list of products and customers.
-
Clone the repository:
git clone https://github.com/DelusionCB/nodejs-bakery-api.git
-
Install dependencies
cd nodejs-api npm install
-
Start the server:
npm start
Starting server, will create new sqlite -file in src/db -folder.
It will also run src/Defaults/ JSON -files for default data.
Default customer ID is 123456
The server will start on http://localhost:8080 by default. You can change this in:
index.ts const port = 8080;
Example of products
{
"data": [
{
"id": 1,
"name": "Chocolate Cake",
"description": "A rich and moist chocolate cake.",
"image_placeholder": "https://www.thomsonsmartcook.com/wp-content/uploads/2019/09/Sweet-shortcrust-pastry-1-650x650.jpg",
"rating": 4,
"price": 30.5,
"currency": "eur"
},
{
"id": 2,
"name": "Pancake",
"description": "A fluffy and syrupy pancake.",
"image_placeholder": "https://www.thomsonsmartcook.com/wp-content/uploads/2019/09/Sweet-shortcrust-pastry-1-650x650.jpg",
"rating": 5,
"price": 15,
"currency": "eur"
},
],
}
Pagination is returned without giving query parameters but that is the way you should use them.
Example of metadata:
"metadata": {
"count": 43,
"page": 1,
"pageSize": 6,
"totalPages": 8
}
Example of details:
{
"id": 1,
"customerID": 123456,
"products": [
{
"id":1,
"name":"Chocolate Cake",
"description":"A rich and moist chocolate cake.",
"image_placeholder":"https://www.thomsonsmartcook.com/wp-content/uploads/2019/09/Sweet-shortcrust-pastry-1-650x650.jpg",
"rating":4,
"price":30.5,
"currency":"eur"
}
],
"status": "ordered"
}
Example of POST:
{products: ['id1', 'id2', 'id3']}
Does what it says, sets users products into empty list & changes status to "not_ordered"
This project is licensed under the MIT License.