Midterm Project
Due: 12:00pm (noon), Friday April 1, 2022
Description
The goal of this project is to develop a basic REST API. The theme of your project is up to you, but it must satisfy the following criteria:
The ExpressJS library must be used for the server component.
The base route for all resources must be
/api/
.There must be separate URIs for individual resources.
Operations on resources must use appropriate HTTP methods.
Individual resources must respond to all of the following HTTP methods:
GET
: retrieve a JSON representation of the resource at the specified URI. If the request is successful, the HTTP response status must be 200 (0K). Otherwise the HTTP status must be 404 (Not Found).POST
: create a new resource at the specified URI. The body of the request must be a complete JSON representation of the resource to create. If the resource creation is successful, the HTTP response status must be 201 (Created) and the “Location” header must be set to the URI of the created resource. Otherwise, the HTTP response status must be 400 (Bad Request) with a JSON body reporting the error.PUT
: update an existing resource. The request body must be a complete JSON representation of the resource to update. If the update is successful the HTTP response status must be 200 (OK). If the resource does not exist, the HTTP response header must be set to 404 (Not Found). Otherwise, the response status must be 400 (Bad Request) with a JSON body reporting the reason.DELETE
: delete a resource. If successful, the HTTP response status must be set to 204 (No Content). Otherwise, the HTTP response header must be set to 404 (Not Found) if the resource does not exist.
There must be two related resources.
Each resource must be sufficiently complex. (This criteria is somewhat subjective; if you think your proposed resources are too simplistic, then ask me.)
All data interchange must use JSON.
The application data must be stored in a SQLite database.
All accesses to the database must use prepared statements when appropriate.
Note: in order for ExpressJS to properly parse JSON in the body of the request (for the POST
and PUT
methods), a line similar to line 3 (depending on the name of the variable in line 2) below must be added to the code BEFORE any route handlers.
1 const express = require('express')
2 const app = express()
3 app.use(express.json({strict: false}))
Turning in the Assignment
For this assignment, you must turn in a zip file of a directory named midterm-project.zip
containing the following files:
index.js
– the implementation of the APIpackage.json
pacakge-lock.json
init_db.sql
– SQL statements that create the appropriate tables and insert some initial dataREADME.md
– Documentation for the REST API
Submit the zip file to the appropriate folder on D2L.
Grading Criteria
Grading (out of 100 points):
- 10 points – Documentation
- 10 – complete documentation that follows the standards
- 5 points – incomplete documentation and/or documentation that does not follow the standards
- 0 points – no documentation
- 60 points – Implementation
- 60 points – correct implementation of the specification
- 30 points – mostly correct implementation of the specification
- 0 points – incorrect implementation (less than half of the required functionality)
- 10 points –
init_db.sql
- 10 points – correct implementation
- 5 points – incomplete implementation
- 0 points – incorrect implementation
- 20 points –
README.md
- 20 – complete documentation of the REST API
- 10 – mostly complete documentation of the REST API
- 0 – little or no documentation of the REST API