@ladjs/web 17.0.8 → 18.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 +16 -12
  2. package/package.json +4 -4
package/index.js CHANGED
@@ -226,7 +226,7 @@ class Web {
226
226
  });
227
227
 
228
228
  // override koa's undocumented error handler
229
- app.context.onerror = errorHandler();
229
+ app.context.onerror = errorHandler(this.config.cookiesKey);
230
230
 
231
231
  // adds request received hrtime and date symbols to request object
232
232
  // (which is used by Cabin internally to add `request.timestamp` to logs
@@ -254,16 +254,6 @@ class Web {
254
254
  // basic auth
255
255
  if (this.config.auth) app.use(auth(this.config.auth));
256
256
 
257
- // rate limiting
258
- if (this.config.rateLimit)
259
- app.use(
260
- ratelimit({
261
- ...this.config.rateLimit,
262
- db: this.client,
263
- logger: this.logger
264
- })
265
- );
266
-
267
257
  // remove trailing slashes
268
258
  app.use(removeTrailingSlashes());
269
259
 
@@ -371,7 +361,11 @@ class Web {
371
361
  app.use(
372
362
  session({
373
363
  ...this.config.session,
374
- store: redisStore({ client: this.client }),
364
+ ...(this.client
365
+ ? {
366
+ store: redisStore({ client: this.client })
367
+ }
368
+ : {}),
375
369
  key: this.config.cookiesKey,
376
370
  cookie: this.config.cookies,
377
371
  genSid: this.config.genSid
@@ -423,6 +417,16 @@ class Web {
423
417
  app.use(this.passport.session());
424
418
  }
425
419
 
420
+ // rate limiting
421
+ if (this.client && this.config.rateLimit)
422
+ app.use(
423
+ ratelimit({
424
+ ...this.config.rateLimit,
425
+ db: this.client,
426
+ logger: this.logger
427
+ })
428
+ );
429
+
426
430
  // store the user's last ip address in the background
427
431
  if (this.config.storeIPAddress) {
428
432
  const storeIPAddress = new StoreIPAddress({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ladjs/web",
3
3
  "description": "Web server for Lad",
4
- "version": "17.0.8",
4
+ "version": "18.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",
@@ -12,8 +12,8 @@
12
12
  ],
13
13
  "dependencies": {
14
14
  "@hapi/boom": "^10.0.0",
15
- "@koa/router": "^10.1.1",
16
- "@ladjs/i18n": "^7.2.6",
15
+ "@koa/router": "^11.0.1",
16
+ "@ladjs/i18n": "^8.0.1",
17
17
  "@ladjs/koa-better-static": "^2.0.1",
18
18
  "@ladjs/koa-cache-responses": "^0.0.3",
19
19
  "@ladjs/koa-isajax": "^2.0.0",
@@ -31,7 +31,7 @@
31
31
  "koa": "^2.13.4",
32
32
  "koa-404-handler": "^0.1.0",
33
33
  "koa-basic-auth": "^4.0.0",
34
- "koa-better-error-handler": "^10.0.5",
34
+ "koa-better-error-handler": "^10.0.6",
35
35
  "koa-better-flash": "^0.0.4",
36
36
  "koa-better-timeout": "^0.0.6",
37
37
  "koa-bodyparser": "^4.3.0",