Tutorial by Examples

Express is based on Connect, which is what provides the middleware functionality of Express. To understand what connect is, you can see that it provides the basic app structure that you use when you use express const connect = require('connect') const app = connect() app.listen(3000) This wi...
Middleware are attached to the app object, usually before listen is called. Example of a simple logging middleware: app.use(function (req, res, next) { console.log(`${req.method}: ${req.url}`) next() }) All this will do is log GET: /example if you where to GET localhost:3000/example. ...
If we would like to limit the access to our app, we could write a middleware for that too! This example only grants you access on thrusdays, but a real world example could, for example, be user authentication. A good place to put this would be after the logging middleware but before any content is s...

Page 1 of 1