You can continue working on the code from last week for this weeks task.
Copy over all of your code to this folder now.
To submit you should open a pull request with all of your code in this folder.
In the following homework, you will create new API endpoints in the NodeJS application cyf-ecommerce-api
that you created for last week homework for the Database 2 class.
-
If you don't have it already, add a new GET endpoint
/products
to load all the product names along with their supplier names. -
Update the previous GET endpoint
/products
to filter the list of products by name using a query parameter, for example/products?name=Cup
. This endpoint should still work even if you don't use thename
query parameter! -
Add a new GET endpoint
/customers/:customerId
to load a single customer by ID. -
Add a new POST endpoint
/customers
to create a new customer. -
Add a new POST endpoint
/products
to create a new product (with a product name, a price and a supplier id). Check that the price is a positive integer and that the supplier ID exists in the database, otherwise return an error. -
Add a new POST endpoint
/customers/:customerId/orders
to create a new order (including an order date, and an order reference) for a customer. Check that the customerId corresponds to an existing customer or return an error. -
Add a new PUT endpoint
/customers/:customerId
to update an existing customer (name, address, city and country). -
Add a new DELETE endpoint
/orders/:orderId
to delete an existing order along all the associated order items. -
Add a new DELETE endpoint
/customers/:customerId
to delete an existing customer only if this customer doesn't have orders. -
Add a new GET endpoint
/customers/:customerId/orders
to load all the orders along the items in the orders of a specific customer. Especially, the following information should be returned: order references, order dates, product names, unit prices, suppliers and quantities.