Git Product home page Git Product logo

lab-08-09-single-resource-api's Introduction

cf lab-08-single-resource-api

To Submit this Assignment

  • 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

Build Tool Instructions

  • create a package.json that lists all dependencies and developer dependencies
  • include an .eslintrc
  • include a .gitignore
  • include a readme with project description
  • create a gulpfile

Directions

  • Create these directories to organize your code:
  • lib
  • model
  • test
  • Create a HTTP Server using the http module
  • Create a Object Constructor that creates a simple resource with at least 3 properties
  • An id property that is set to a unique node-uuid id is required
  • Also include two other properties of your choice (like name, creationDate, etc.)
  • Create a body parser that uses Promises to parse the json in the body of POST and PUT requests
  • Create a url parser that returns a promise and uses nodes url and querystring modules parse the request url
  • Create a Router Constructor that manages requests to GET, POST, PUT, and DELETE requests
  • Create a route for doing CREATE, READ, and DELETE operations on your simple resource
  • Create a storage module that will store resources by their type and id

Server Endpoints

/api/simple-resource-name

  • POST request
  • pass data as stringifed json in the body of a post request to create a resource
  • GET request
  • pass an ?id=<uuid> in the query string to retrieve a specific resource as json
  • DELETE request
  • pass an ?id=<uuid> in the query string to delete a specific resource
  • should return 204 status with no content in the body

Tests

  • 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/simple-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 found
  • GET - test 400, responds with 'bad request' if no id was provided in the request
  • GET - test 200, response body like {<data>} for a request made with a valid id
  • POST - test 400, responds with 'bad request' for if no body provided or invalid body
  • POST - test 200, response body like {<data>} for a post request with a valid body

Bonus

  • 2pts a GET request to /api/simple-resource-name with no ?id= should retrun an array of all of the ids for that resource

lab-08-09-single-resource-api's People

Contributors

broxsonl avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.