Sinatra inspired web development framework for node.js -- insanely fast, flexible, and simple
pg_stat_activity
is clean
Unhandled rejection Error: Unable to acquire a connection
at Client_PG.acquireConnection (/app/node_modules/knex/lib/client.js:342:30)
at Runner.ensureConnection (/app/node_modules/knex/lib/runner.js:245:8)
at Runner.run (/app/node_modules/knex/lib/runner.js:25:27)
at Builder.Target.then (/app/node_modules/knex/lib/interface.js:14:43)
at Builder.tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
at doThenable (/app/node_modules/bluebird/js/release/thenables.js:63:38)
at tryConvertToPromise (/app/node_modules/bluebird/js/release/thenables.js:28:20)
at Promise._resolveCallback (/app/node_modules/bluebird/js/release/promise.js:465:24)
at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:559:17)
at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromiseCtx (/app/node_modules/bluebird/js/release/promise.js:641:10)
at _drainQueueStep (/app/node_modules/bluebird/js/release/async.js:97:12)
at _drainQueue (/app/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:439:21)
knex.destroy()
)
or does leaky only apply to keeping unaccessible/non-useful information in memory?
Yeah I guess by that definition it's not a memory leak when you actually need to access the data at some point in the future. Still the two major points remain that store is wiped on restart and might eat up server RAM
throw new Error(...)
. But it is in an async function and so on, which might be an issue. try { await next() }
doesn't help
next()
won't work. Having an error middleware at the end is how it's usually done. You have to pass an argument to next for it to be called next(err)
. More about it here https://expressjs.com/en/guide/error-handling.html
@catchErrors
in the line above the async definition than inserting more parens in my code
req.route.path
to validate some information. Right now, I need to define all my routes like router.get("/path/of/my/route/:someParameter", myMiddlewareFunction, (req, res) => { /* actual route handler */ });
Is there a way for me to avoid having to do this?
req.route.path
in the database. Have you got any suggestions on how to achieve this?
req.route.path
that'll output something like /some/route/with/:param
and that'll validate the request against a JSON schema with the name requests/GET/some/route/with/_param
. I have this part working perfectly fine, it's just that I want to avoid having to manually include the middleware in every controller
const routes = {
use: [s.wrapErrors, v.knexConnected],
'/auth': {
'post /login': [v.user.notLoggedIn, v.user.login, c.user.login],
'post /signup': [v.user.notLoggedIn, v.user.login, v.user.noSignupConflicts, c.user.createAndLogin],
'get /logout': [s.user.login, c.user.logout],
},
...
inversify-express-utils
and I overrode their HTTP decorators to include my middleware.export function all(path: string, ...middleware: interfaces.Middleware[]): interfaces.HandlerDecorator {
middleware.unshift(TYPES.ValidateRequestMiddleware);
// @ts-ignore
return httpMethod.apply(void 0, ["all", path].concat(middleware));
}
res.cookie
seems to do nothing.
res.cookie[...]..redirect(req.path)
as a workaround :/