Intro to Express

Who am I?

  • Ryan Hirsch
  • Software Developer
  • Work at WWT Asynchrony Labs

Simplest way two "machines" can talk to one another over a network?

Netcat

Allows us to open a simple TCP server and client.

 

These two windows can send simple messages back and forth.

What if we replace one of those terminal windows with something else

Chrome Request

Our Response

Express

  • Sinatra inspired

  • Minimal framework with many features available through plugins

  • Gets over 18 million downloads a month

  • Has over 35k stars on GitHub, one of the top 50 projects

History

  • Created in 2010

    • Around Node v0.4

  • Created by TJ Holowaychuk

    • Connect, Express, Jade, Stylus, Mocha, Superagent, Koa, Commander...

  • Sold in June 2014 to StrongLoop

  • Purchased in September 2015 by IBM

  • Turned over to the Node Foundation in January 2016

Hello World

Express Routing

  • HTTP verb functions off of your app instance

Dynamic Values in Routes

  • Values prefixed with ":foo" are available on the request.params
  • Any query string values are available on the request.query

Advanced Routing configuration

  • Most routes should not be defined directly on the app
    • large files difficult to understand
  • Better to split up across multiple routers

Middleware

  • The way to leverage 'plugins'

Custom Middleware for SOME routes

Middleware Authentication

  • Passport JS
  • Client Side with Firebase

Creating your own custom middleware

Intro to ExpressJS

By Ryan Hirsch

Intro to ExpressJS

  • 538