Git Product home page Git Product logo

node-http-server's Introduction

General Assembly Logo

Node HTTP Module: Server

Node has a built-in HTTP module for making and responding to requests. In this training, we'll examine the Node HTTP docs and annotate server code. We'll become familiar with the HTTP module, as well as using function signatures to find the correct documentation for a procedure. We'll also look at a promisified version of a simple server.

Prerequisites

Objectives

By the end of this, developers should be able to:

  • Diagram the flow of a server written in Node.
  • Annotate code using documentation.
  • Find documentation based on function signature.

Preparation

  1. Fork and clone this repository.
  2. Install dependencies with npm install.

Lab: Read Node Server Documentation

Read the following documentation from the Node HTTP module. While reading, take note of any new concepts or vocabulary that is confusing. Pay attention to function signatures. When you're finished taking notes, research one or two points you'd like made clearer. We will discuss our findings.

Demo: A Node Echo Server

An echo server is a server that responds with all the information it received during a request. It's a bit like "Hello, World!".

Let's run the echo server with node lib/htpp-server.js. You should see echo server listening. Now make a request with curl:

curl --include --request GET \
  http://localhost:3000/people/?name=Jason&role=Awesome

Next, try this request:

curl --include --request POST http://localhost:3000/sign-in \
  --header "Content-Type: application/json" \
  --data "{
    \"credentials\": {
      \"email\": \"[email protected]\",
      \"password\": \"an example password\"
    }
  }"

Annotate Along: Echo Server

Let's read the code in lib/http-server.js. Our goal is to annotate the code as we try to understand what it is doing at a high level. As we take notes, write questions you have along with your notes.

After we annotate a few lines together, you may continue annotating on your own.

Read-Along: Examine a Promisified Server

Read the code in lib/http-server-promises.js. Compare it to the code in lib/http-server.js. Annotate any questions you have about promises.

Additional Resources

Source code distributed under the MIT license. Text and other assets copyright General Assembly, Inc., all rights reserved.

node-http-server's People

Watchers

James Cloos avatar Jessica Cornman-Homonoff 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.