- fork this repository
- write all of your code in a directory named
lab-
+<your name>
e.g.lab-duncan
- push to your repository
- submit a pull request to this repository
- submit a link to your PR in canvas
- write a question and observation on canvas
- create a package.json that lists all dependencies and developer dependencies
- include a .env and .test.env
- include an .eslintrc
- include a .gitignore
- include a readme with a project description
- how to install
- how to start the server
- document the routes
- include a package.json
- have a lint script for running eslint
- have a test script for running mocha
- start script for running your server
- have a start-db script for running mongod
- have a stop-db script for stoping mongod
-
Create these directories to organize your code:
-
lib
-
model
-
route
-
db
-
test
-
Create a HTTP Server using
express
-
Create a Object Constructor using mongoose that creates a resource with at least 3 properties
-
it can not have the same properties as the in class sample code, or yesterdays lab
-
make sure you include at least one propertie with the
unique
validator set to true -
Also include two other properties of your choice (like name, creationDate, etc.)
-
use the
body-parser
express middleware to onPOST
andPUT
routes
POST
request- pass data as stringified json in the body of a post request to create a resource
GET
request- pass the id of a resource though the query string to fetch a resource
PUT
request- pass data as stringified json in the body of a put request to update a resource
DELETE
request- pass the id of a resource though the query string to delete a resource
- your tests should start your server when they begin and stop your server when they finish
- write a test to ensure that your api returns a status code of 404 for routes that have not been registered
- write tests to ensure your
/api/resource-name
endpoint responds as described for each condition below: GET
- test 404, responds with 'not found' for valid request made with an id that was not foundGET
- test 200, response body like{<data>}
for a request made with a valid idPUT
- test 200, response body like{<data>}
for a post request with a valid bodyPUT
- test 400, with invalid bodyPUT
- test 404, with invalid idDELETE
- test 204, with valid idDELETE
- test 404, with invalid idPOST
- test 200, response body like{<data>}
for a post request with a valid bodyPOST
- test 400, with an invalid request bodyPOST
- test 409, with an a conflict for a unique property