- 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 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
- Also include two other properties of your choice (like name, creationDate, etc.)
- use the
body-parser
express middleware to onPOST
andPUT
routes - save your data using the storage module with file system persistence from last week
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 bodyPOST
- test 200, response body like{<data>}
for a post request with a valid bodyPOST
- test 400, with an invalid request body
- 1pt a
GET
request to/api/resource-name
should respond with an array of all of the ids for that resource - if you do the bonus you should not test for a 404 for
GET
request with no query, and instead write a test that ensures your aGET
to/api/resouce-name
returns a 200 and an array