Welcome to the Node.js Logistics Management workshop. This project is designed to apply basic concepts of Node.js, Express, promises, and the difference between development and production dependencies. You will create a RESTful API that interacts with the file system instead of a database.
- Create a repository on GitHub named
nodejs-logistics-project. - Follow the instructions and complete the objectives outlined in this document.
- Upload your project to GitHub and share the repository link.
- Set up a Node.js development environment.
- Create a web server using Node.js and Express.
- Implement routes and middleware in Express.
- Read and write data in the file system using the
fsmodule with promises. - Handle errors and secure the RESTful API with middleware.
- Understanding status codes and response bodies.
- Differentiate between development and production dependencies.
- Design relational model for the required entities.
You will create a RESTful API to manage logistics information. The entities to be managed are: Warehouses, Shipments, Drivers, and Vehicles. Each entity will be stored in a JSON file in the file system.
A warehouse is a building for storing goods. It has the following properties:
- ID: A unique identifier for the warehouse.
- Name: The name of the warehouse.
- Location: The location of the warehouse.
A shipment is a load of goods that is transported from one place to another. It has the following properties:
- ID: A unique identifier for the shipment.
- Item: The name of the item being shipped.
- Quantity: The quantity of the item being shipped.
A driver is a person who drives a vehicle to transport goods. It has the following properties:
- ID: A unique identifier for the driver.
- Name: The name of the driver.
A vehicle is a machine used to transport goods. It has the following properties:
- ID: A unique identifier for the vehicle.
- Model: The model of the vehicle.
- Year: The year the vehicle was manufactured.
- A warehouse can have multiple shipments. However, a shipment can only belong to one warehouse.
- A driver can drive multiple vehicles. However, a vehicle can only be driven by one driver.
- A vehicle can transport multiple shipments. However, a shipment can only be transported by one vehicle.
- A shipment can be transported by one driver. However, a driver can transport multiple shipment.
- A driver can work in one warehouse. However, a warehouse can have multiple drivers.
- A vehicle can be parked in multiple warehouses. However, a warehouse can only have one vehicle parked.
- A warehouse can have multiple drivers. However, a driver can only work in one warehouse.
- Route: POST /warehouses
- Request Body:
{ "name": "Warehouse Name", "location": "Warehouse Location" } - Successful Response:
- Code: Buscar el código correcto
- Response Body:
{ "message": "Warehouse created successfully", "warehouse": { "id": 1, "name": "Warehouse Name", "location": "Warehouse Location" } }
- Route: GET /warehouses
- Successful Response:
- Code: Buscar el código correcto
- Response Body:
{ "warehouses": [ { "id": 1, "name": "Warehouse Name", "location": "Warehouse Location" } ] }
- Route: GET /warehouses/:id
- Successful Response:
- Code: Buscar el código correcto
- Response Body:
{ "warehouse": { "id": 1, "name": "Warehouse Name", "location": "Warehouse Location" } }
- Route: PUT /warehouses/:id
- Request Body:
{ "name": "New Warehouse Name", "location": "New Warehouse Location" }
- Route: DELETE /warehouses/:id
- Successful Response:
- Code: Buscar el código correcto
- Response Body:
{ "message": "Warehouse deleted successfully" }
- Route: POST /shipments
- Request Body:
{ "item": "Item Name", "quantity": 100, "warehouseId": 1 }
- Route: GET /shipments
- Successful Response:
- Code: Buscar el código correcto
- Response Body:
{ "shipments": [ { "id": 1, "item": "Item Name", "quantity": 100, "warehouseId": 1 } ] }
- Route: GET /shipments/:id
- Successful Response:
- Code: Buscar el código correcto
- Response Body:
{ "shipment": { "id": 1, "item": "Item Name", "quantity": 100, "warehouseId": 1 } }
- Route: PUT /shipments/:id
- Request Body:
{ "item": "New Item Name", "quantity": 150, "warehouseId": 1 }
- Route: DELETE /shipments/:id
- Successful Response:
- Code: Buscar el código correcto
- Response Body:
{ "message": "Shipment deleted successfully" }
- Route: POST /drivers
- Request Body:
{ "name": "Driver Name" }
- Route: GET /drivers
- Successful Response:
- Code: Buscar el código correcto
- Response Body:
{ "drivers": [ { "id": 1, "name": "Driver Name" } ] }
- The project must be created with Node.js and Express.
- You must implement a RESTful API.
- You must use the
fsmodule to read and write files. - You must use middleware to handle errors and secure the API.
- You must differentiate between development and production dependencies.
- You must differentiate the variety of status codes.