FastFeet 2.0 is a delivery service application that builds on the previously developed FastFeet.
This app features all the latest tools and practices in backend development!
- Express
- Sucrase + Nodemon
- ESLint + Prettier + EditorConfig
- Docker for Windows
- Sequelize - using PostgreSQL, but MySQL could also have been used
- mongoose
- Redis + Bee-Queue for managing queues and background jobs
- jwt for authentication
- Yup for schema (input data) validation
- Multer for file uploads
- date-fns for manipulating dates
- Mailtrap for testing fake email
- Handlebars for generating HTML templates
- Sentry for reporting errors
- Youch for prettifying error reporting
- dotenv for storing environment variables
Bellow are the functionalities that were implemented for this application.
It aims to allow admins to add deliverymen to the application.
A deliverymen needs to have the following fields:
- id (deliveryman's id)
- name (deliveryman's name)
- avatar_id (deliveryman's picture)
- email (deliveryman's email)
- created_at
- updated_at
Resource | Method | Parameters | Header |
---|---|---|---|
/deliverymen | GET | - | Bearer Token |
/deliverymen | POST | {name, email} | Bearer Token |
/deliverymen/:id | PUT | {name, email} | Bearer Token |
/deliverymen/:id | DELETE | - | Bearer Token |
After a deliveryman is registered in the application the admin user has to assign orders to the deliverymen.
The Order needs to have the following fields:
- id (order's id)
- recipient_id (recipient's foreign key)
- deliveryman_id (deliveryman's foreign key)
- signature_id (recipient's signature, which will be an image)
- product (product to be delivered)
- canceled_at (cancellation date, if cancelled)
- start_date (pick up date)
- end_date (delivery date)
- created_at
- updated_at
- start_date must be added at the same moment the product is picked up for delivery, and the product can only be picked up between 08:00h and 18:00h.
- end_date must be added when the delivery is successfully completed.
- The deliverymen must receive an email when a order is assigned to him.
Resource | Method | Parameters | Header |
---|---|---|---|
/orders | GET | - | Bearer Token |
/orders | POST | {recipient_id, deliveryman_id, product} | Bearer Token |
/orders/:id | PUT | {recipient_id, deliveryman_id, product} | Bearer Token |
/orders/:id | DELETE | - | Bearer Token |
Deliverymen must be able to display the orders that were assigned to them by informing only their respective id.
Therefore, they should be able to visualize:
- orders that were not delivered or cancelled
Resource | Method | Parameters | Header |
---|---|---|---|
/deliveryman/:id/not-delivered | GET | - | - |
- orders that have already been delivered by him/her
Resource | Method | Parameters | Header |
---|---|---|---|
/deliveryman/:id/deliveries | GET | - | - |
Deliverymen should be able to add a pick up date (start_date) and a delivery date (end_date) for their deliveries. They cannot pick up more than 5 orders per day.
Resource | Method | Parameters | Header |
---|---|---|---|
/deliveryman/:deliveryman_id/start-delivery/:order_id | PUT | {start_date} | - |
Furthermore, when completing a delivery, deliverymen shoud be able to register an image, which will be the signature_id in the orders table.
- Image will be sent as 'file' in multipart/form-data
Resource | Method | Parameters | Header |
---|---|---|---|
/deliveryman/end-delivery?deliveryman_id=&order_id= | PUT | - | - |
Deliverymen will not always be able to successfully deliver an order, due to a number of different reasons.
The delivery_problems table needs to have the following fields:
- delivery_id (order's id foreign key)
- description (description about the problem the deliveryman had)
- created_at
- updated_at
- Route that will list all deliveries that have a problem
Resource | Method | Parameters | Header |
---|---|---|---|
/delivery-problems | GET (index) | - | Bearer Token |
- Route that will list all the problems a delivery has based on its id (order_id)
Resource | Method | Parameters | Header |
---|---|---|---|
/delivery/:id/problems | GET (show) | - | Bearer Token |
- Route that will allow a deliveryman - no need for admin auth - to register problems with a delivery by entering the order_id
Resource | Method | Parameters | Header |
---|---|---|---|
/delivery/:id/problems | POST | {description} | - |
- Route that the delivery services company will use to cancel a delivery by using the delivery_problem id, from the delivery_problems table.
- canceled_at date will be the date the delivery is cancelled
Resource | Method | Parameters | Header |
---|---|---|---|
/delivery/:id/delivery-problems | PUT | - | Bearer Token |
- Clone this repo using
git clone https://github.com/yagosansz/rockseat-bootcamp2020-challenge03.git
- Move yourself to the appropriate directory:
cd rockseat-bootcamp2020-challenge03
- Run
yarn
to install dependencies
- Run
yarn sequelize db:migrate
to create tables - Run
yarn sequelize db:seed:all
to add seed data to the database - Run
yarn dev
to start the development server - Run
yarn queue
to start processing queues for background jobs - Test routes by either using Insomnia or Postman
Made with ❤️ by Yago!