This is an api for a pizza app
- User should be able to register
- User should be able to login with Passport using JWT
- Implement basic auth
- User should be able to get orders
- Users should be able to create orders
- Users should be able to update and delete orders
- Test application
- Install NodeJS, mongodb
- pull this repo
- update env with example.env
- run
npm run start:dev
- somehostsite.com
field | data_type | constraints |
---|---|---|
id | string | required |
username | string | required |
firstname | string | optional |
lastname | string | optional |
string | optional | |
password | string | required |
user_type | string | required, default: user, enum: ['user', 'admin'] |
field | data_type | constraints |
---|---|---|
id | string | required |
created_at | date | required |
state | number | required,default:1 |
total_price | number | required |
items | array | required |
item.name | string | required |
item.price | number | required |
item.size | string | required, enum: ['m', 's', 'l'] |
item.quantity | number | required, enum: ['m', 's', 'l'] |
- Route: /signup
- Method: POST
- Body:
{
"email": "[email protected]",
"password": "Password1",
"firstname": "jon",
"lastname": "doe",
"username": 'jon_doe",
}
- Responses
Success
{
message: 'Signup successful',
user: {
"email": "[email protected]",
"password": "Password1",
"firstname": "jon",
"lastname": "doe",
"username": 'jon_doe",
}
}
- Route: /login
- Method: POST
- Body:
{
"password": "Password1",
"username": 'jon_doe",
}
- Responses
Success
{
message: 'Login successful',
token: 'sjlkafjkldsfjsd'
}
- Route: /orders
- Method: POST
- Header
- Authorization: Bearer {token}
- Body:
{
items: [{ name: 'chicken pizza', price: 900, size: 'm', quantity: 1}]
}
- Responses
Success
{
state: 1,
total_price: 900,
created_at: Mon Oct 31 2022 08:35:00 GMT+0100,
items: [{ name: 'chicken pizza', price: 900, size: 'm', quantity: 1}]
}
- Route: /orders/:id
- Method: GET
- Header
- Authorization: Bearer {token}
- Responses
Success
{
state: 1,
total_price: 900,
created_at: Mon Oct 31 2022 08:35:00 GMT+0100,
items: [{ name: 'chicken pizza', price: 900, size: 'm', quantity: 1}]
}
- Route: /orders
- Method: GET
- Header:
- Authorization: Bearer {token}
- Query params:
- page (default: 1)
- per_page (default: 10)
- order_by (default: created_at)
- order (options: asc | desc, default: desc)
- state
- created_at
- Responses
Success
{
state: 1,
total_price: 900,
created_at: Mon Oct 31 2022 08:35:00 GMT+0100,
items: [{ name: 'chicken pizza', price: 900, size: 'm', quantity: 1}]
}
...
- Daniel Adesoji