@ladjs/api 14.2.0 → 14.2.1
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.
- package/index.js +18 -2
- package/package.json +9 -9
package/index.js
CHANGED
|
@@ -2,20 +2,22 @@ const process = require('node:process');
|
|
|
2
2
|
const http = require('node:http');
|
|
3
3
|
const https = require('node:https');
|
|
4
4
|
const util = require('node:util');
|
|
5
|
+
const zlib = require('node:zlib');
|
|
5
6
|
const Cabin = require('cabin');
|
|
6
7
|
const I18N = require('@ladjs/i18n');
|
|
7
|
-
const Passport = require('@ladjs/passport');
|
|
8
8
|
const Koa = require('koa');
|
|
9
|
+
const Passport = require('@ladjs/passport');
|
|
9
10
|
const Redis = require('@ladjs/redis');
|
|
10
11
|
const StoreIPAddress = require('@ladjs/store-ip-address');
|
|
11
12
|
const Timeout = require('koa-better-timeout');
|
|
12
13
|
const _ = require('lodash');
|
|
13
14
|
const auth = require('koa-basic-auth');
|
|
14
15
|
const bodyParser = require('koa-bodyparser');
|
|
16
|
+
const compress = require('koa-compress');
|
|
15
17
|
const conditional = require('koa-conditional-get');
|
|
16
18
|
const cors = require('kcors');
|
|
17
19
|
const errorHandler = require('koa-better-error-handler');
|
|
18
|
-
const etag = require('koa
|
|
20
|
+
const etag = require('@koa/etag');
|
|
19
21
|
const json = require('koa-json');
|
|
20
22
|
const koa404Handler = require('koa-404-handler');
|
|
21
23
|
const koaConnect = require('koa-connect');
|
|
@@ -49,6 +51,17 @@ class API {
|
|
|
49
51
|
prettyPrintedJSON: process.env.PRETTY_PRINTED_JSON
|
|
50
52
|
? Boolean(process.env.PRETTY_PRINTED_JSON)
|
|
51
53
|
: 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
|
+
|
|
52
65
|
...config
|
|
53
66
|
};
|
|
54
67
|
|
|
@@ -135,6 +148,9 @@ class API {
|
|
|
135
148
|
app.use(i18n.middleware);
|
|
136
149
|
}
|
|
137
150
|
|
|
151
|
+
// compress/gzip
|
|
152
|
+
if (this.config.compress) app.use(compress(this.config.compress));
|
|
153
|
+
|
|
138
154
|
// Conditional-get
|
|
139
155
|
app.use(conditional());
|
|
140
156
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ladjs/api",
|
|
3
3
|
"description": "API server for Lad",
|
|
4
|
-
"version": "14.2.
|
|
4
|
+
"version": "14.2.1",
|
|
5
5
|
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/ladjs/api/issues",
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
"Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
+
"@koa/etag": "^5.0.2",
|
|
14
15
|
"@koa/router": "^13.1.1",
|
|
15
|
-
"@ladjs/i18n": "^
|
|
16
|
+
"@ladjs/i18n": "^10.0.0",
|
|
16
17
|
"@ladjs/koa-simple-ratelimit": "^4.1.1",
|
|
17
18
|
"@ladjs/passport": "^5.1.4",
|
|
18
19
|
"@ladjs/redis": "^1.1.1",
|
|
@@ -23,21 +24,20 @@
|
|
|
23
24
|
"cabin": "^14.0.0",
|
|
24
25
|
"express-request-id": "1.4.1",
|
|
25
26
|
"kcors": "^2.2.2",
|
|
26
|
-
"koa": "
|
|
27
|
+
"koa": "3.1.1",
|
|
27
28
|
"koa-404-handler": "^0.1.0",
|
|
28
29
|
"koa-basic-auth": "^4.0.0",
|
|
29
|
-
"koa-better-error-handler": "^
|
|
30
|
+
"koa-better-error-handler": "^12.0.0",
|
|
30
31
|
"koa-better-timeout": "^0.0.6",
|
|
31
32
|
"koa-bodyparser": "^4.4.1",
|
|
32
33
|
"koa-compress": "^5.1.1",
|
|
33
34
|
"koa-conditional-get": "^3.0.0",
|
|
34
35
|
"koa-connect": "^2.1.0",
|
|
35
|
-
"koa-etag": "^4.0.0",
|
|
36
36
|
"koa-json": "^2.0.2",
|
|
37
37
|
"lodash": "^4.17.21",
|
|
38
38
|
"multimatch": "5",
|
|
39
39
|
"request-received": "^0.0.3",
|
|
40
|
-
"response-time": "^2.3.
|
|
40
|
+
"response-time": "^2.3.4"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@commitlint/cli": "^19.8.1",
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
"eslint-config-xo-lass": "^2.0.1",
|
|
49
49
|
"fixpack": "^4.0.0",
|
|
50
50
|
"husky": "^9.1.7",
|
|
51
|
-
"ioredis": "^5.
|
|
52
|
-
"ioredis-mock": "^8.
|
|
51
|
+
"ioredis": "^5.8.2",
|
|
52
|
+
"ioredis-mock": "^8.13.1",
|
|
53
53
|
"lint-staged": "^15.4.3",
|
|
54
54
|
"mongoose": "6",
|
|
55
55
|
"nyc": "^17.1.0",
|
|
56
56
|
"remark-cli": "11",
|
|
57
57
|
"remark-preset-github": "^4.0.4",
|
|
58
|
-
"supertest": "^7.1.
|
|
58
|
+
"supertest": "^7.1.4",
|
|
59
59
|
"xo": "^0.56.0"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|