1.0.2 • Published 5 years ago

ts-async-express-middleware v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

ts-async-express-middleware

Adds express middleware that works with typescript

To install run

npm install ts-async-express-middleware

Including async middleware will handle exceptions from futures correctly so you do not need to wrap every request in a try/catch for async operations

import asyncMiddleware from 'ts-async-express-middleware';

function delay(ms: number) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

app.get(
  '/pass',
  asyncMiddleware(async (req, res, next) => {
    await delay(500);
    res.send('this passed');
  })
);