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 1
  • customer — String
  • product — String
  • qty — Integer
  • price — Float
  • total — Float
  • status — one of: pending, completed, cancelled

The boilerplate is in Workspace → server.js. GET /orders is already implemented. Implement the missing endpoints:

  1. POST /orders
    • Creates a new order from the request body
    • Auto-assigns a unique id starting from 1
    • Sets status to "pending"
    • Returns status 201 with the created order object
  2. 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
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 comp matches Completed
  • 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.