KristerV / heliumpay-budgetweb-backend

2 stars 2 forks source link

Add errors middleware #3

Closed jschr closed 7 years ago

jschr commented 7 years ago

This PR adds errors middleware for capturing errors that occur inside all routes.

This is just the initial structure, going forward it should be trivial to add other common http errors (401s, 403s, 404s etc...)

To avoid wrapping all route handlers with try / catches I addedexpress-promise-router, which captures unresolved promises and passes the error to the middleware.

I also added child-process-promise to clean up the dash-cli command execution.

There is a TODO to complete when we add logging. Typically in production you don't want to pass stack traces to the client nor error messages with >500 code because they likely contain sensitive info about the code.

KristerV commented 7 years ago

oh wow nice, so there's no more middleware(routeHandler) stuff needed?

jschr commented 7 years ago

Nope! express-promise-router takes care of that for us now which makes async routes a breeze