Bootstrapping ExpressJS

ExpressJS is a web server composed mainly of routes, middlewares, and views. However, since we are aiming to build a Single Page Applications (SPA), we are going to use ExpressJS as a REST endpoint and Angular's views. So from ExpressJS, we are only going to use the routes and middleware.

When the server receives a request, it goes through all the registered middlewares one by one. The middlewares are functions with three parameters; request, reponse, and next. If no error is found, it hands over the request to the next middleware in the chain. Middlewares are very diverse: they can log information, process cookies, sessions, do authentication, and so on. Similarly, routes too are functions that process requests, but they ...

Get Web Application Development with MEAN now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.