Skip to content

Instantly share code, notes, and snippets.

@ralphcrisostomo
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralphcrisostomo/637f89e6d4d8495adab9 to your computer and use it in GitHub Desktop.
Save ralphcrisostomo/637f89e6d4d8495adab9 to your computer and use it in GitHub Desktop.
Express.js Learning Notes

Express.js Learning Notes

Tips

  • Always refer to http://expressjs.com/api.html

  • Everything is “middleware”.

  • use means “Run this on ALL requests”

  • get means “Run this on a GET request, for the given URL”

  • in between middleware should return next() or res.end()

  • Ends the response process.

      res.render('/homepage');
      res.send('Hello World!');
      res.json({});
      res.end();
      res.status(404).end();
    
  • middleware and async are different

  • always chain middleware

  • use async inside middleware

  • use async when handling a request, and especially when that involves doing file I/O or talking to a database.

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment