Subscribe to our list to receive the latest updates on Node on Fire

Class: Middleware

Middleware

new Middleware()

The middleware module is an express-like middleware system with dependency injection and promise support.

For example, the below create a simple HTTP GET route which returns all Party models:

app.get('/parties', function(PartyModel) {
    return PartyModel.find({});
});

A get route which finds a specific party:

app.get('/parties/:partyID', function(partyID, PartyModel) {
    return PartyModel.findOne({id: partyID});
});

This middleware loads files in the middleware/ folder relative from your project's root directory.

Do you have any questions or comments on this page? Start a discussion below.

comments powered by Disqus
Subscribe to our list to receive the latest updates on Node on Fire