@khinenw/express-async-router

1.0.0 • Public • Published

express-async-router

An async router for express

Features

  • automatically detects sync / async.
  • supports all methods (use, get, post, delete, ...)
  • supports param

Usage

const createAsyncRouter = require('express-async-router');

const router = createAsyncRouter();
router.get('/', myAsyncMiddleware, syncMiddleware, async (req, res, next) => {
	// whatever

	if(somethingErrornous)
		throw new Error("This does not become unhandled rejection");

	// otherwise call next like usual
	next();
});

Readme

Keywords

Package Sidebar

Install

npm i @khinenw/express-async-router

Weekly Downloads

4

Version

1.0.0

License

MIT

Unpacked Size

2.77 kB

Total Files

3

Last publish

Collaborators

  • khinenw