@abtnode/blocklet-services 1.16.14-beta-c81e5ca0 → 1.16.14-beta-c308dc3b
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/api/libs/image.js +4 -3
- package/api/services/image/index.js +2 -6
- package/package.json +19 -19
package/api/libs/image.js
CHANGED
|
@@ -88,7 +88,8 @@ const schema = Joi.object({
|
|
|
88
88
|
.options({ stripUnknown: true, allowUnknown: true, noDefaults: false });
|
|
89
89
|
|
|
90
90
|
const isImageAccepted = (req) => {
|
|
91
|
-
|
|
91
|
+
const extension = path.extname(req.path).slice(1);
|
|
92
|
+
return FORMATS.includes(EXTENSIONS[extension]) && FORMATS.some((x) => req.accepts(`image/${x}`));
|
|
92
93
|
};
|
|
93
94
|
|
|
94
95
|
const isImageRequest = (req) => {
|
|
@@ -121,7 +122,7 @@ const processAndRespond = (req, res, cacheDir, getSrc) => {
|
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
124
|
|
|
124
|
-
const cacheKey = md5(stringify({ target: req.target, path: req.
|
|
125
|
+
const cacheKey = md5(stringify({ target: req.target, path: req.originalUrl, params }));
|
|
125
126
|
const destPath = path.join(cacheDir, `${cacheKey}.${params.f || extension}`);
|
|
126
127
|
if (fs.existsSync(destPath)) {
|
|
127
128
|
res.header('Content-Type', `image/${params.f || extension}`);
|
|
@@ -140,7 +141,7 @@ const processAndRespond = (req, res, cacheDir, getSrc) => {
|
|
|
140
141
|
|
|
141
142
|
tasks[cacheKey]
|
|
142
143
|
.then(() => {
|
|
143
|
-
logger.info('image filter succeed', { params, url: req.
|
|
144
|
+
logger.info('image filter succeed', { params, url: req.originalUrl, destPath });
|
|
144
145
|
res.header('Content-Type', `image/${params.f || extension}`);
|
|
145
146
|
res.sendFile(destPath, { maxAge: '356d', immutable: true });
|
|
146
147
|
})
|
|
@@ -5,12 +5,12 @@ const path = require('path');
|
|
|
5
5
|
|
|
6
6
|
const logger = require('@abtnode/logger')(require('../../../package.json').name);
|
|
7
7
|
|
|
8
|
-
const { isImageAccepted, isImageRequest, processAndRespond
|
|
8
|
+
const { isImageAccepted, isImageRequest, processAndRespond } = require('../../libs/image');
|
|
9
9
|
|
|
10
10
|
const createImageService = ({ node }) => {
|
|
11
11
|
const getUpstreamImage = (req) => {
|
|
12
12
|
return new Promise((resolve, reject) => {
|
|
13
|
-
const upstream = new URL(req.
|
|
13
|
+
const upstream = new URL(req.originalUrl, req.target);
|
|
14
14
|
http
|
|
15
15
|
.request(
|
|
16
16
|
{
|
|
@@ -32,10 +32,6 @@ const createImageService = ({ node }) => {
|
|
|
32
32
|
reject(new Error('upstream response is not an image'));
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
if (extension !== EXTENSIONS[path.extname(req.path).slice(1)]) {
|
|
36
|
-
reject(new Error('upstream response type and file extension mismatch'));
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
35
|
|
|
40
36
|
resolve([res, extension]);
|
|
41
37
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.14-beta-
|
|
6
|
+
"version": "1.16.14-beta-c308dc3b",
|
|
7
7
|
"description": "Provide unified services for every blocklet",
|
|
8
8
|
"main": "api/index.js",
|
|
9
9
|
"files": [
|
|
@@ -33,18 +33,18 @@
|
|
|
33
33
|
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
34
34
|
"license": "Apache-2.0",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@abtnode/analytics": "1.16.14-beta-
|
|
37
|
-
"@abtnode/auth": "1.16.14-beta-
|
|
38
|
-
"@abtnode/client": "1.16.14-beta-
|
|
39
|
-
"@abtnode/connect-storage": "1.16.14-beta-
|
|
40
|
-
"@abtnode/constant": "1.16.14-beta-
|
|
41
|
-
"@abtnode/core": "1.16.14-beta-
|
|
42
|
-
"@abtnode/cron": "1.16.14-beta-
|
|
43
|
-
"@abtnode/logger": "1.16.14-beta-
|
|
44
|
-
"@abtnode/models": "1.16.14-beta-
|
|
45
|
-
"@abtnode/router-adapter": "1.16.14-beta-
|
|
46
|
-
"@abtnode/router-templates": "1.16.14-beta-
|
|
47
|
-
"@abtnode/util": "1.16.14-beta-
|
|
36
|
+
"@abtnode/analytics": "1.16.14-beta-c308dc3b",
|
|
37
|
+
"@abtnode/auth": "1.16.14-beta-c308dc3b",
|
|
38
|
+
"@abtnode/client": "1.16.14-beta-c308dc3b",
|
|
39
|
+
"@abtnode/connect-storage": "1.16.14-beta-c308dc3b",
|
|
40
|
+
"@abtnode/constant": "1.16.14-beta-c308dc3b",
|
|
41
|
+
"@abtnode/core": "1.16.14-beta-c308dc3b",
|
|
42
|
+
"@abtnode/cron": "1.16.14-beta-c308dc3b",
|
|
43
|
+
"@abtnode/logger": "1.16.14-beta-c308dc3b",
|
|
44
|
+
"@abtnode/models": "1.16.14-beta-c308dc3b",
|
|
45
|
+
"@abtnode/router-adapter": "1.16.14-beta-c308dc3b",
|
|
46
|
+
"@abtnode/router-templates": "1.16.14-beta-c308dc3b",
|
|
47
|
+
"@abtnode/util": "1.16.14-beta-c308dc3b",
|
|
48
48
|
"@arcblock/did": "^1.18.88",
|
|
49
49
|
"@arcblock/did-auth": "1.18.88",
|
|
50
50
|
"@arcblock/did-ext": "^1.18.88",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"@arcblock/jwt": "1.18.88",
|
|
54
54
|
"@arcblock/validator": "^1.18.88",
|
|
55
55
|
"@arcblock/ws": "1.18.88",
|
|
56
|
-
"@blocklet/constant": "1.16.14-beta-
|
|
56
|
+
"@blocklet/constant": "1.16.14-beta-c308dc3b",
|
|
57
57
|
"@blocklet/form-builder": "^0.1.11",
|
|
58
58
|
"@blocklet/form-collector": "^0.1.6",
|
|
59
|
-
"@blocklet/meta": "1.16.14-beta-
|
|
60
|
-
"@blocklet/sdk": "1.16.14-beta-
|
|
59
|
+
"@blocklet/meta": "1.16.14-beta-c308dc3b",
|
|
60
|
+
"@blocklet/sdk": "1.16.14-beta-c308dc3b",
|
|
61
61
|
"@did-connect/authenticator": "^2.2.0",
|
|
62
62
|
"@did-connect/relay-adapter-express": "^2.2.0",
|
|
63
63
|
"@did-connect/storage-nedb": "^2.2.0",
|
|
@@ -95,12 +95,12 @@
|
|
|
95
95
|
"@nedb/core": "^2.1.2"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@abtnode/ux": "1.16.14-beta-
|
|
98
|
+
"@abtnode/ux": "1.16.14-beta-c308dc3b",
|
|
99
99
|
"@arcblock/did-connect": "^2.6.8",
|
|
100
100
|
"@arcblock/icons": "^2.6.8",
|
|
101
101
|
"@arcblock/ux": "^2.6.8",
|
|
102
102
|
"@blocklet/launcher-layout": "2.1.83",
|
|
103
|
-
"@blocklet/tracker": "1.16.14-beta-
|
|
103
|
+
"@blocklet/tracker": "1.16.14-beta-c308dc3b",
|
|
104
104
|
"@blocklet/ui-react": "^2.6.8",
|
|
105
105
|
"@emotion/react": "^11.10.4",
|
|
106
106
|
"@emotion/styled": "^11.10.4",
|
|
@@ -170,5 +170,5 @@
|
|
|
170
170
|
"url": "https://github.com/ArcBlock/blocklet-server/issues",
|
|
171
171
|
"email": "shijun@arcblock.io"
|
|
172
172
|
},
|
|
173
|
-
"gitHead": "
|
|
173
|
+
"gitHead": "c08aaac7fb25d0f1c81c8866baf5579714416485"
|
|
174
174
|
}
|