@ladjs/web 16.0.0 → 16.0.3

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 +11 -21
  2. package/package.json +4 -4
package/index.js CHANGED
@@ -358,13 +358,12 @@ class Web {
358
358
 
359
359
  // add limited `ctx` object to the state for views
360
360
  ctx.state.ctx = {};
361
- ctx.state.ctx.get = ctx.get;
361
+ ctx.state.ctx.get = ctx.get.bind(ctx);
362
362
  ctx.state.ctx.locale = ctx.locale;
363
363
  ctx.state.ctx.params = ctx.params;
364
364
  ctx.state.ctx.path = ctx.path;
365
365
  ctx.state.ctx.pathWithoutLocale = ctx.pathWithoutLocale;
366
366
  ctx.state.ctx.query = ctx.query;
367
- ctx.state.ctx.session = ctx.session;
368
367
  ctx.state.ctx.sessionId = ctx.sessionId;
369
368
  ctx.state.ctx.translate = ctx.translate;
370
369
  ctx.state.ctx.url = ctx.url;
@@ -374,22 +373,15 @@ class Web {
374
373
 
375
374
  // session store
376
375
  app.keys = this.config.sessionKeys;
377
- app.use(async (ctx, next) => {
378
- try {
379
- await session({
380
- store: redisStore({ client: this.client }),
381
- key: this.config.cookiesKey,
382
- cookie: this.config.cookies,
383
- genSid: this.config.genSid,
384
- ...this.config.session
385
- })(ctx, () => Promise.resolve());
386
- } catch (err) {
387
- // this would indicate that redis is down
388
- ctx.logger.error(err);
389
- }
390
-
391
- return next();
392
- });
376
+ app.use(
377
+ session({
378
+ store: redisStore({ client: this.client }),
379
+ key: this.config.cookiesKey,
380
+ cookie: this.config.cookies,
381
+ genSid: this.config.genSid,
382
+ ...this.config.session
383
+ })
384
+ );
393
385
 
394
386
  // redirect loop (must come after sessions added)
395
387
  if (this.config.redirectLoop) {
@@ -439,9 +431,7 @@ class Web {
439
431
  } catch (err) {
440
432
  ctx.logger.error(err);
441
433
  let error = err;
442
- // this would indicate that redis is down
443
- if (!ctx.session) error = Boom.clientTimeout();
444
- else if (err.name && err.name === 'ForbiddenError')
434
+ if (err.name && err.name === 'ForbiddenError')
445
435
  error = Boom.forbidden(err.message);
446
436
 
447
437
  ctx.throw(error);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ladjs/web",
3
3
  "description": "Web server for Lad",
4
- "version": "16.0.0",
4
+ "version": "16.0.3",
5
5
  "author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/ladjs/web/issues",
@@ -20,7 +20,7 @@
20
20
  "@ladjs/koa-simple-ratelimit": "^3.0.0",
21
21
  "@ladjs/redis": "^1.0.7",
22
22
  "@ladjs/shared-config": "^7.0.3",
23
- "@ladjs/state-helper": "^2.0.0",
23
+ "@ladjs/state-helper": "^2.0.1",
24
24
  "@ladjs/store-ip-address": "^0.0.7",
25
25
  "boolean": "^3.2.0",
26
26
  "cabin": "^9.1.2",
@@ -39,7 +39,7 @@
39
39
  "koa-compress": "^5.1.0",
40
40
  "koa-conditional-get": "^3.0.0",
41
41
  "koa-connect": "^2.1.0",
42
- "koa-csrf": "^4.0.0",
42
+ "koa-csrf": "^4.0.1",
43
43
  "koa-etag": "^4.0.0",
44
44
  "koa-favicon": "^2.1.0",
45
45
  "koa-generic-session": "^2.3.0",
@@ -63,7 +63,7 @@
63
63
  "@ladjs/passport": "^5.0.2",
64
64
  "ava": "^4.3.0",
65
65
  "cross-env": "^7.0.3",
66
- "eslint": "^8.18.0",
66
+ "eslint": "^8.19.0",
67
67
  "eslint-config-xo-lass": "^2.0.1",
68
68
  "fixpack": "^4.0.0",
69
69
  "husky": "^8.0.1",