Contains data models and tests for Categories and Products interfaces
Used for GET requests. Searches (memory) database for and category with entered _id
and returns it. Returns entire category list if called without an _id
. Returns error message if _id
is not found.
Used for POST requests. Validates entry with validate
method, creates and appends UUID to entry, and adds it to the database. If a valid entry, returns the added category. Returns error message if entry does not contain all fields required by the schema
.
Used for PUT requests. Validates entry with validate
method, searches for category with _id
entered, updates that category with entry, and saves it to the database. If a valid entry, returns the updated category.
Used for DELETE requests. Searches database for _id
entered, removes the category with matching _id
from the database, and returns an empty object upon success. Returns error message if _id
is not found.
Used for all POST and PUT requests. Checks if all required fields in the schema are present in record entered. Returns true
or false
.
npm i
PORT
- assign a port numberMONGODB_URI
- URL to the running mongo instance/db
npm start
- How do you run tests?
npm run test
npm run lint