Git Product home page Git Product logo

07-vanilla-http's Introduction

cf Lab 07: Vanilla HTTP Server

Submission Instructions

  • fork this repository & create a new branch for your work
  • write all of your code in a directory named lab- + <your name> e.g. lab-susan
  • 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

Learning Objectives

  • students will be able to identify key qualities of the HTTP protocol
  • students will be able to implement an HTTP server using the node.js http module

Requirements

Configuration

Your lab directory must include

  • .gitignore
  • .eslintrc.json
  • .eslintignore
  • package.json
  • README.md

Note: You will need to npm i cowsay for this project

Feature Tasks

Documentation:
  • Brief description of you app
  • How to install / get started with your app
  • How to interact with the endpoints
    • Sample requests and example responses
    • Note: use a code block to show the HTTPie and response format
  • Create an HTTP Server using the NodeJS http module
  • Create a custom body parsing module that is used for parsing the body of all POST and PUT requests
GET (request methods) /
  • For GET requests made to /, the server should respond with the following:
    • A header containing Content-Type: text/plain
    • A status code of 200
    • A response with the string "hello from my server!"
GET /cowsay?text={message}
  • For all GET requests made to /cowsay, the server should respond with the following:
    • Note: the query string should have the key value text=message
    • The response header should include Content-Type: text/plain
    • If the query text=message is set, respond with:
      • A status code of 200
      • A response body that includes the value returned from cowsay.say({ text: <querystring text> })
    • If the query text=message is not set, respond with:
      • Status code 400
      • A body including the value returned from cowsay.say({ text: 'bad request' })
POST /cowsay
  • For all POST requests made to /cowsay, the server should respond with the following:
    • The response header should include Content-Type: text/plain
    • If the JSON {text: message} is set in the body, respond with:
      • A status code of 200
      • A response body including the value returned from cowsay.say({ text: <querystring text> })
    • If the JSON {text: message} is not set in the body, respond with:
      • Status code 400
      • A body including the value returned from cowsay.say({ text: 'bad request' })

Tests

  • Note: There is no need to unit test the body parser module for this lab
  • Write tests that validate any GET request to / and assert that the 200 response is received, including the defined response message
  • Write tests that validate all GET requests to /cowsay and assert that the 200 response is received, including the cowsay response message
    • Do not neglect the query string format required for the text message
  • Write tests that validate any malformed requests to /cowsay and assert that the 400 response is received, including the cowsay response message
  • Write tests that validate all POST requests to /cowsay and assert that the 200 response is received, including the cowsay response message
  • Write tests that validate any malformed requests to /cowsay and assert that the 400 response is received, including the cowsay response message
    • Do not neglect the request body format required for the text message

Stretch

  • Add the ability to change the cow file - ex: dragon, sheep, etc (note: this should be done through the querystring)

Rubric 10pts

  • Documentation: 2pts
  • Feature Tasks: 5pts
  • Tests: 3pts

07-vanilla-http's People

Contributors

clairj avatar sjschmidt44 avatar

Watchers

James Cloos 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.