Task 1 Node.js: Orders API 50 pts · Node.js, REST API, ExpressJS
Implement a REST service that exposes the /orders endpoint. Each item is a JSON object with the following properties:
id— unique integer, auto-generated starting from 1customer— Stringproduct— Stringqty— Integerprice— Floattotal— Floatstatus— one of:pending,completed,cancelled
The boilerplate is in Workspace → server.js. GET /orders is already implemented. Implement the missing endpoints:
-
POST
/orders- Creates a new order from the request body
- Auto-assigns a unique
idstarting from 1 - Sets
statusto"pending" - Returns status 201 with the created order object
-
PUT
/orders/:id- Accepts
{ "status": "..." }in the request body - Valid values:
pending,completed,cancelled - Invalid status → return 400
- Valid status → update order, return 200 with updated object
- Accepts
Example requests and responses
POST /orders — Request body:
{"customer": "John Smith", "product": "MacBook Pro", "qty": 1, "price": 1999, "total": 1999}
Response — status 201:
{"id": 1, "customer": "John Smith", "product": "MacBook Pro", "qty": 1, "price": 1999, "total": 1999, "status": "pending"}
PUT /orders/1 — Request body:
{"status": "completed"}
Response — status 200:
{"id": 1, "customer": "John Smith", "product": "MacBook Pro", "qty": 1, "price": 1999, "total": 1999, "status": "completed"}
PUT /orders/1 with invalid status — Request body:
{"status": "shipped"}
Response — status 400. No requirements for response body.
Task 2 JavaScript: Order Filter Component 50 pts · JavaScript, CSS
Complete the implementation in Workspace → Orders Table. Add a filter input and implement the filtering logic.
- The input must have
data-testid="order-filter" - Filters the orders table rows by the Status column in real time
- Filtering is case-insensitive — typing
compmatchesCompleted - Non-matching rows must be hidden with
display: none, not removed - When input is cleared, all rows become visible again
- Vanilla JavaScript only — no jQuery, no libraries
Do not change existing table structure, class names, or
data-testid attributes.
Example
Input: pend → only Pending rows visible, all others hidden.
Input: (empty) → all rows visible.