Skip to content

Express router ready for async/await in the route methods

Notifications You must be signed in to change notification settings

tgriesser/promise-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

promise-router

yarn add @tgriesser/promise-router

Express Router, attaching a .catch(next) on any promise-returning routes to ensure unhandled exceptions don't hang the process.

Allows for use of async / await in express middleware without worrying

Use:

import { promiseRouter } from '@tgriesser/promise-router'
// Alternatively: const { promiseRouter } = require('@tgriesser/promise-router')

const app = express();
const router = promiseRouter();

router.get('/some-route', async (req, res) => {
  const val = await someAsyncFunction()
  res.json(val);
});

app.use(router);

License

MIT

About

Express router ready for async/await in the route methods

Resources

Stars

Watchers

Forks

Packages

No packages published