ExpressJS

What is Express

Express is a small framework that sits on top on NodeJS to simplify its APIs and add features

Express vs. Node

Processes take many lines of code in NodeJS whereas the may only take a few with ExpressJS 

Express is Unopinionated

Certain things you have to do the 'Express Way' but outside of that you get to choose how you design your app

We will be splitting our code up into smaller organized, understandable pieces using the MVC or Model - View - Controller paradigm

Express has 3 main parts:

  • middleware
  • routing
  • subapplication (usually called router)

Middleware

Middleware is an array of functions that run in our code. It allows many handlers (functions) to run in sequence

Routing

Routing has to do with choosing paths or routes to deliver code. Much easier in Express than in vanilla NodeJS

Subapplication

Commonly known as router. This is built into Express and allows us to separate our routes as our code base grows larger.

Other Frameworks

  • Hapi
  • Meteor
  • Kraken

Routing parts

app.METHOD( PATH, MAYBE MIDDLEWARE, HANDLER)

app.get( '/users', authenticate, (req, res) => {

....do something here

});

Lets build an Express Server

ExpressJS

By JD Richards