Skip to content

Latest commit

 

History

History
41 lines (32 loc) · 1.05 KB

middlewares.md

File metadata and controls

41 lines (32 loc) · 1.05 KB

Middlewares

{% hint style="warning" %} We moved all middlewares to separate @nanoexpress/middlewares repository {% endhint %}

Tested Express/Connect like Middlewares

Basic example

app.use((req, res, next) => {
  req.appId = 'MY_APP_ID';
  next();
});

Method defining

function lazyEnd(end) {
  setTimeout(() => this.end(end), 0);
}
app.use((req, res, next) => {
  res.lazyEnd = lazyEnd;
  next();
});

{% hint style="info" %} Error which comes from Async Middleware automacilly will be handled by nanoexpress {% endhint %}