Comments (6)
Perhaps Express can add a hook to register a function to wrap middleware, which could be used to automatically wrap the middleware / handers for this and whatever other purposes. The details for how the interaction will be done with routers will need to be hammered out, but a high-level idea is:
app.wrap(function (fn) {
return function (req, res, next) {
fn(req, res, next).catch(next)
}
})
This is very high-level thought, but figured I'd start a discussion here from the comment in Express repo to get a feeling of if this could be a solution or not.
from kraken-js.
@dougwilson I think at this stage with async/await finally built-in to the platform, it should just become a core express/kraken feature to support promise-based middleware (without even having to opt-in via app.wrap
).
It sounds like express 5 is stalling pretty hard (which is fine), so our best bet will be to add this support directly into kraken I think.
from kraken-js.
Yea, and it should, but there are still unresolved issues on how exactly we should deal with the resolved values, for example, and how to deal with the Bluebird warnings, as another.
from kraken-js.
On the kraken side there a few ways to implement this. One place we may want to look at is in express-enrouten
such as here:
https://github.com/krakenjs/express-enrouten/blob/v1.x/lib/directory.js#L69
from kraken-js.
Another thing we could do is put this monkey-patching script into its own module and just require it in as needed (either in kraken core or as wanted by various teams):
https://gist.github.com/q42jaap/f2fb93d96fda6384d3e3fc51977dec90
from kraken-js.
We could potentially integrate with this module:
https://github.com/davidbanham/express-async-errors
from kraken-js.
Related Issues (20)
- How to access image from directory located outside the workspace? HOT 1
- Uglify-js has security issues HOT 1
- Templates in public directory? HOT 2
- remove bluebird 🔥 HOT 5
- Is it alive? HOT 3
- remove domains? HOT 16
- formidable events not firing properly in kraken HOT 1
- Koa port HOT 1
- Ajax with krakenjs HOT 1
- Upload multiple images krakenjs using ajax HOT 1
- Creating New Project using yo for Ubuntu 16.04 HOT 6
- Server is starting (status 503) HOT 3
- Dead? HOT 6
- Add node 12 in travis CI
- [Devdeps][security] replace jade with pug
- Yo Kraken Error HOT 9
- Kraken.js - yo kraken Error kraken primordials is not defined HOT 3
- Name of this library HOT 1
- Feature request: ability to use `config/*.js` instead of json
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kraken-js.