@ladjs/web 20.0.2 → 20.0.4

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 +17 -10
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -262,6 +262,18 @@ class Web {
262
262
  app.use(i18n.redirect);
263
263
  }
264
264
 
265
+ app.use((ctx, next) => {
266
+ // add limited `ctx` object to the state for views
267
+ ctx.state.ctx = {};
268
+ ctx.state.ctx.get = ctx.get.bind(ctx);
269
+ ctx.state.ctx.locale = ctx.locale;
270
+ ctx.state.ctx.path = ctx.path;
271
+ ctx.state.ctx.pathWithoutLocale = ctx.pathWithoutLocale;
272
+ ctx.state.ctx.query = ctx.query;
273
+ ctx.state.ctx.url = ctx.url;
274
+ return next();
275
+ });
276
+
265
277
  // conditional-get
266
278
  app.use(conditional());
267
279
 
@@ -332,6 +344,11 @@ class Web {
332
344
  })
333
345
  );
334
346
 
347
+ app.use((ctx, next) => {
348
+ ctx.state.ctx.sessionId = ctx.sessionId;
349
+ return next();
350
+ });
351
+
335
352
  // redirect loop (must come after sessions added)
336
353
  if (this.config.redirectLoop) {
337
354
  const redirectLoop = new RedirectLoop({
@@ -375,16 +392,6 @@ class Web {
375
392
  }
376
393
  }
377
394
 
378
- // add limited `ctx` object to the state for views
379
- ctx.state.ctx = {};
380
- ctx.state.ctx.get = ctx.get.bind(ctx);
381
- ctx.state.ctx.locale = ctx.locale;
382
- ctx.state.ctx.path = ctx.path;
383
- ctx.state.ctx.pathWithoutLocale = ctx.pathWithoutLocale;
384
- ctx.state.ctx.query = ctx.query;
385
- ctx.state.ctx.sessionId = ctx.sessionId;
386
- ctx.state.ctx.url = ctx.url;
387
-
388
395
  return next();
389
396
  });
390
397
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ladjs/web",
3
3
  "description": "Web server for Lad",
4
- "version": "20.0.2",
4
+ "version": "20.0.4",
5
5
  "author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)",
6
6
  "bugs": {
7
7
  "url": "https://github.com/ladjs/web/issues",
@@ -29,7 +29,7 @@
29
29
  "koa": "^2.14.1",
30
30
  "koa-404-handler": "^0.1.0",
31
31
  "koa-basic-auth": "^4.0.0",
32
- "koa-better-error-handler": "^11.0.1",
32
+ "koa-better-error-handler": "^11.0.2",
33
33
  "koa-better-flash": "^0.0.4",
34
34
  "koa-better-timeout": "^0.0.6",
35
35
  "koa-bodyparser": "^4.3.0",