Skip to content

Latest commit

 

History

History

warmup-02

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Warm-Up: Express

Setup

  • On each day, create a new branch of this repository with the date
    • e.g., 11-22-2018
  • Create a JS folder with the same date name
    • e.g., 11-22-2018/
  • Follow the instructions below in that folder
  • Timebox this to 1 hour
  • Create a PR from that branch to master

Warm-Up Exercise

Before You Start ... complete the daily warm-up

The goal for this exercise is to build up muscle memory on basic server setup and operations. You'll be tasked with creating servers many times during your career and in projects. This should be the type of thing that you can construct nearly blindfolded, to give yourself a stable starting point from which to do your actual work.

Create

  • Build an express web server. From Scratch. By Hand.
  • Listens on process.env.PORT1
  • Serves static files from a folder called ./public2
  • Has a separate routes.js file for serving custom routes
    • handles a GET on '/' with a simple response of 'hello'3
    • handles a POST on '/save' with a JSON response containing the data posted to the server4
  • Handles 404's6 by serving the user a a custom page (.ejs5)
  • Handles Errors7 by serving the user a custom page (.ejs5)
    • log the actual error to the console
  • Deploy to Heroku, via your master branch

Test

  • Write tests for each route, the 404 page, and a simulated error
    • Use supertest
  • Confirm tests passing at Travis, via the master branch

Resources

  1. dotenv usage
  2. Serving static files
  3. Basic routing in Express
  4. JSON in Express
  5. EJS with Express
  6. Handling 404 responses
  7. Error handling