- Bodyparser
- Authentication
- Lucid ORM
- Migrations and seeds
- Functional tests
$ yarn || npm install
Run the following command to run startup migrations and seeders.
$ yarn db:configure || npm run db:configure
To start the application tests:
$ yarn start:test || npm run start:test
Latest result:
➜ yarn start:test
yarn run v1.15.2
$ node ace test
info: serving app on http://127.0.0.1:3333
Database migrated successfully in 295 ms
Seeded database in 144 ms
Pizza Flavor
✓ should be available flavor options (301ms)
Pizza Order
✓ should be return orders (181ms)
✓ should be create order with pizza personalizations (187ms)
✓ should be create order without pizza personalizations (185ms)
Pizza Personalization
✓ should be available personalization options (193ms)
User Session
✓ should be able to authenticate with valid credentials (179ms)
✓ should not be able to authenticate with invalid credentials (178ms)
✓ should be able to access private routes when authenticated (192ms)
✓ should not be able to access private routes when not authenticated (7ms)
Pizza Size
✓ should be available size options (185ms)
PASSED
total : 10
passed : 10
time : 2s
Reset completed in 208 ms
Done in 3.23s.
To start application in development environment:
$ yarn start:dev || npm run start:dev
To start application in production environment:
$ yarn start || npm run start
DEMO: https://thiagodesouza-delivery-api.herokuapp.com
Route | Verb(s) | Handler | Middleware | Name |
---|---|---|---|---|
/api/users | POST | UserController.store | av:StoreUser | users.store |
/api/users/:id | PUT,PATCH | UserController.update | auth,av:UpdateUser | users.update |
/api/sessions | POST | SessionController.store | av:StoreSession | sessions.store |
/api/sizes | HEAD,GET | SizeController.index | auth | sizes.index |
/api/flavors | HEAD,GET | FlavorController.index | auth | flavors.index |
/api/personalizations | HEAD,GET | PersonalizationController.index | auth | personalizations.index |
/api/orders | HEAD,GET | OrderController.index | auth | orders.index |
/api/orders | POST | OrderController.store | auth,av:StoreOrder | orders.store |
/api/orders/:id | HEAD,GET | OrderController.show | auth | orders.show |
// POST: /api/users
{
"name": "Thiago de Souza",
"email": "thiago@email.com.br",
"password": "udschallenge",
"password_confirmation": "udschallenge"
}
// DEMO: https://thiagodesouza-delivery-api.herokuapp.com/api/users
// POST: /api/sessions
{
"email": "thiago@email.com.br",
"password": "udschallenge"
}
// DEMO: https://thiagodesouza-delivery-api.herokuapp.com/api/sessions
// HEADER: Authorization - Bearer <user-token>
// POST: /api/orders
{
"size_id": 3,
"flavor_id": 3,
"personalizations": [1, 2, 3]
}
// DEMO: https://thiagodesouza-delivery-api.herokuapp.com/api/orders
Best regards,
Thiago Rodrigues de Souza
e-mail: email@thiagodesouza.com.br
site: https://www.thiagodesouza.com.br