restyped-express-async
restyped-express-async copied to clipboard
Support for express middlewares
So that one e.g. can write:
function firstMiddleware(req, res, next) {}
function secondMiddleware(req, res, next) {}
router.get(
'/permissions',
(req, res) => {
return Promise.resolve().then(() => {
return {
managers: ['someone', 'another']
};
});
},
firstMiddleware, secondMiddleware
);
The router method call signature is backwards compatible but slightly unfortunately the middlewares need to be appended instead of prepended. Experimented with a single array of handlers but that did not turn out so well:
- union objects in the array are not callable unless their call signature is identical https://github.com/Microsoft/TypeScript/issues/7294
- if call signatures are identical, TypeScript won't differentiate the two on return value (since
Handler
hasvoid
), a faultyTypedHandler
is hence interpreted as a Handler and no errors are generated
Relates to #6
This repo is still active ?
:( I really like this project too...
Hey, is this branch working? It's so unfortunate that this project isn't maintained anymore, I really like it too 😕
I merged this branch in ianmartorell/restyped-express and published it to npm under restyped-express
. I also fixed some other issues so it works with the latest version of express.