@ladjs/web 14.0.9 → 15.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +20 -12
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -344,15 +344,22 @@ class Web {
344
344
 
345
345
  // session store
346
346
  app.keys = this.config.sessionKeys;
347
- app.use(
348
- session({
349
- store: redisStore({ client: this.client }),
350
- key: this.config.cookiesKey,
351
- cookie: this.config.cookies,
352
- genSid: this.config.genSid,
353
- ...this.config.session
354
- })
355
- );
347
+ app.use(async (ctx, next) => {
348
+ try {
349
+ await session({
350
+ store: redisStore({ client: this.client }),
351
+ key: this.config.cookiesKey,
352
+ cookie: this.config.cookies,
353
+ genSid: this.config.genSid,
354
+ ...this.config.session
355
+ })(ctx, () => Promise.resolve());
356
+ } catch (err) {
357
+ // this would indicate that redis is down
358
+ ctx.logger.error(err);
359
+ }
360
+
361
+ return next();
362
+ });
356
363
 
357
364
  // redirect loop (must come after sessions added)
358
365
  if (this.config.redirectLoop) {
@@ -400,11 +407,12 @@ class Web {
400
407
  try {
401
408
  await csrf(ctx, next);
402
409
  } catch (err) {
410
+ ctx.logger.error(err);
403
411
  let error = err;
404
- if (err.name && err.name === 'ForbiddenError') {
412
+ // this would indicate that redis is down
413
+ if (!ctx.session) error = Boom.clientTimeout();
414
+ else if (err.name && err.name === 'ForbiddenError')
405
415
  error = Boom.forbidden(err.message);
406
- if (err.stack) error.stack = err.stack;
407
- }
408
416
 
409
417
  ctx.throw(error);
410
418
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ladjs/web",
3
3
  "description": "Web server for Lad",
4
- "version": "14.0.9",
4
+ "version": "15.0.0",
5
5
  "author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/ladjs/web/issues",