Skip to content

Commit b75eeb7

Browse files
committed
chore: bump deps, fixed compress ordering
1 parent 9a6d557 commit b75eeb7

2 files changed

Lines changed: 25 additions & 9 deletions

File tree

index.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@ const process = require('node:process');
22
const http = require('node:http');
33
const https = require('node:https');
44
const util = require('node:util');
5+
const zlib = require('node:zlib');
56
const Cabin = require('cabin');
67
const I18N = require('@ladjs/i18n');
7-
const Passport = require('@ladjs/passport');
88
const Koa = require('koa');
9+
const Passport = require('@ladjs/passport');
910
const Redis = require('@ladjs/redis');
1011
const StoreIPAddress = require('@ladjs/store-ip-address');
1112
const Timeout = require('koa-better-timeout');
1213
const _ = require('lodash');
1314
const auth = require('koa-basic-auth');
1415
const bodyParser = require('koa-bodyparser');
16+
const compress = require('koa-compress');
1517
const conditional = require('koa-conditional-get');
1618
const cors = require('kcors');
1719
const errorHandler = require('koa-better-error-handler');
@@ -49,6 +51,17 @@ class API {
4951
prettyPrintedJSON: process.env.PRETTY_PRINTED_JSON
5052
? Boolean(process.env.PRETTY_PRINTED_JSON)
5153
: false,
54+
55+
// https://github.com/koajs/compress
56+
compress: {
57+
br: {
58+
params: {
59+
[zlib.constants.BROTLI_PARAM_MODE]: zlib.constants.BROTLI_MODE_TEXT,
60+
[zlib.constants.BROTLI_PARAM_QUALITY]: 4
61+
}
62+
}
63+
},
64+
5265
...config
5366
};
5467

@@ -135,6 +148,9 @@ class API {
135148
app.use(i18n.middleware);
136149
}
137150

151+
// compress/gzip
152+
if (this.config.compress) app.use(compress(this.config.compress));
153+
138154
// Conditional-get
139155
app.use(conditional());
140156

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"dependencies": {
1414
"@koa/router": "^13.1.1",
15-
"@ladjs/i18n": "^8.0.3",
15+
"@ladjs/i18n": "^10.0.0",
1616
"@ladjs/koa-simple-ratelimit": "^4.1.1",
1717
"@ladjs/passport": "^5.1.4",
1818
"@ladjs/redis": "^1.1.1",
@@ -23,21 +23,21 @@
2323
"cabin": "^14.0.0",
2424
"express-request-id": "1.4.1",
2525
"kcors": "^2.2.2",
26-
"koa": "2.16.0",
26+
"koa": "3.1.1",
2727
"koa-404-handler": "^0.1.0",
2828
"koa-basic-auth": "^4.0.0",
29-
"koa-better-error-handler": "^11.0.4",
29+
"koa-better-error-handler": "^12.0.0",
3030
"koa-better-timeout": "^0.0.6",
3131
"koa-bodyparser": "^4.4.1",
3232
"koa-compress": "^5.1.1",
3333
"koa-conditional-get": "^3.0.0",
3434
"koa-connect": "^2.1.0",
35-
"koa-etag": "^4.0.0",
35+
"koa-etag": "4.0.0",
3636
"koa-json": "^2.0.2",
3737
"lodash": "^4.17.21",
3838
"multimatch": "5",
3939
"request-received": "^0.0.3",
40-
"response-time": "^2.3.3"
40+
"response-time": "^2.3.4"
4141
},
4242
"devDependencies": {
4343
"@commitlint/cli": "^19.8.1",
@@ -48,14 +48,14 @@
4848
"eslint-config-xo-lass": "^2.0.1",
4949
"fixpack": "^4.0.0",
5050
"husky": "^9.1.7",
51-
"ioredis": "^5.6.1",
52-
"ioredis-mock": "^8.9.0",
51+
"ioredis": "^5.8.2",
52+
"ioredis-mock": "^8.13.1",
5353
"lint-staged": "^15.4.3",
5454
"mongoose": "6",
5555
"nyc": "^17.1.0",
5656
"remark-cli": "11",
5757
"remark-preset-github": "^4.0.4",
58-
"supertest": "^7.1.3",
58+
"supertest": "^7.1.4",
5959
"xo": "^0.56.0"
6060
},
6161
"engines": {

0 commit comments

Comments
 (0)