This is an api for a restaurant app
- User should be able to register
- User should be able to login
- Implement JWT authentication
- 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 dev
- somehostsite.com
field | data_type | constraints |
---|---|---|
id | string | required |
username | string | required |
firstname | string | required |
lastname | string | required |
string | required | |
password | string | required |
user_type | string | required, default: user, enum: ['user', 'admin'] |
- Route: /api/v1/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: /api/v1/login
- Method: POST
- Body:
{
"password": "Password1",
"username": 'jon_doe",
}
- Responses
Success
{
message: 'Login successful',
token: 'sjlkafjkldsfjsd'
}
- Route: /api/v1/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: /api/v1/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: /api/v1/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}]
}
...
- Emmanuel Asuquo