ipx 1.0.0 → 1.0.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/dist/cli.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const consola = require('consola');
|
|
4
4
|
const listhen = require('listhen');
|
|
5
|
-
const middleware = require('./shared/ipx.
|
|
5
|
+
const middleware = require('./shared/ipx.b2d1c1dd.cjs');
|
|
6
6
|
require('defu');
|
|
7
7
|
require('image-meta');
|
|
8
8
|
require('ufo');
|
|
@@ -15,6 +15,10 @@ require('destr');
|
|
|
15
15
|
require('etag');
|
|
16
16
|
require('xss');
|
|
17
17
|
|
|
18
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
19
|
+
|
|
20
|
+
const consola__default = /*#__PURE__*/_interopDefaultCompat(consola);
|
|
21
|
+
|
|
18
22
|
async function main() {
|
|
19
23
|
const ipx = middleware.createIPX({});
|
|
20
24
|
const middleware$1 = middleware.createIPXMiddleware(ipx);
|
|
@@ -23,6 +27,6 @@ async function main() {
|
|
|
23
27
|
});
|
|
24
28
|
}
|
|
25
29
|
main().catch((error) => {
|
|
26
|
-
|
|
30
|
+
consola__default.error(error);
|
|
27
31
|
process.exit(1);
|
|
28
32
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -12,6 +12,14 @@ const destr = require('destr');
|
|
|
12
12
|
const getEtag = require('etag');
|
|
13
13
|
const xss = require('xss');
|
|
14
14
|
|
|
15
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
16
|
+
|
|
17
|
+
const http__default = /*#__PURE__*/_interopDefaultCompat(http);
|
|
18
|
+
const https__default = /*#__PURE__*/_interopDefaultCompat(https);
|
|
19
|
+
const destr__default = /*#__PURE__*/_interopDefaultCompat(destr);
|
|
20
|
+
const getEtag__default = /*#__PURE__*/_interopDefaultCompat(getEtag);
|
|
21
|
+
const xss__default = /*#__PURE__*/_interopDefaultCompat(xss);
|
|
22
|
+
|
|
15
23
|
const Handlers = {
|
|
16
24
|
__proto__: null,
|
|
17
25
|
get b () { return b; },
|
|
@@ -49,7 +57,7 @@ const Handlers = {
|
|
|
49
57
|
};
|
|
50
58
|
|
|
51
59
|
function getEnv(name, defaultValue) {
|
|
52
|
-
return
|
|
60
|
+
return destr__default(process.env[name]) ?? defaultValue;
|
|
53
61
|
}
|
|
54
62
|
function cachedPromise(function_) {
|
|
55
63
|
let p;
|
|
@@ -107,8 +115,8 @@ function isValidPath(fp) {
|
|
|
107
115
|
|
|
108
116
|
const HTTP_RE = /^https?:\/\//;
|
|
109
117
|
const createHTTPSource = (options) => {
|
|
110
|
-
const httpsAgent = new
|
|
111
|
-
const httpAgent = new
|
|
118
|
+
const httpsAgent = new https__default.Agent({ keepAlive: true });
|
|
119
|
+
const httpAgent = new http__default.Agent({ keepAlive: true });
|
|
112
120
|
let _domains = options.domains || [];
|
|
113
121
|
if (typeof _domains === "string") {
|
|
114
122
|
_domains = _domains.split(",").map((s) => s.trim());
|
|
@@ -166,7 +174,7 @@ const createHTTPSource = (options) => {
|
|
|
166
174
|
};
|
|
167
175
|
|
|
168
176
|
function VArg(argument) {
|
|
169
|
-
return
|
|
177
|
+
return destr__default(argument);
|
|
170
178
|
}
|
|
171
179
|
function parseArgs(arguments_, mappers) {
|
|
172
180
|
const vargs = arguments_.split("_");
|
|
@@ -553,7 +561,7 @@ async function _handleRequest(request, ipx) {
|
|
|
553
561
|
res.headers["Cache-Control"] = `max-age=${+source.maxAge}, public, s-maxage=${+source.maxAge}`;
|
|
554
562
|
}
|
|
555
563
|
const { data, format } = await img.data();
|
|
556
|
-
const etag =
|
|
564
|
+
const etag = getEtag__default(data);
|
|
557
565
|
res.headers.ETag = etag;
|
|
558
566
|
if (etag && request.headers["if-none-match"] === etag) {
|
|
559
567
|
res.statusCode = 304;
|
|
@@ -601,7 +609,7 @@ function sanetizeReponse(res) {
|
|
|
601
609
|
statusCode: res.statusCode || 200,
|
|
602
610
|
statusMessage: res.statusMessage ? safeString(res.statusMessage) : "OK",
|
|
603
611
|
headers: safeStringObject(res.headers || {}),
|
|
604
|
-
body: typeof res.body === "string" ?
|
|
612
|
+
body: typeof res.body === "string" ? xss__default(safeString(res.body)) : res.body || ""
|
|
605
613
|
};
|
|
606
614
|
}
|
|
607
615
|
function safeString(input) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ipx",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"repository": "unjs/ipx",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"exports": {
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"test": "pnpm lint && vitest run --coverage"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"consola": "^
|
|
31
|
+
"consola": "^3.0.1",
|
|
32
32
|
"defu": "^6.1.2",
|
|
33
33
|
"destr": "^1.2.2",
|
|
34
34
|
"etag": "^1.8.1",
|
|
35
35
|
"image-meta": "^0.1.1",
|
|
36
36
|
"listhen": "^1.0.4",
|
|
37
|
-
"node-fetch-native": "^1.0
|
|
37
|
+
"node-fetch-native": "^1.1.0",
|
|
38
38
|
"pathe": "^1.1.0",
|
|
39
39
|
"sharp": "^0.32.0",
|
|
40
40
|
"ufo": "^1.1.1",
|
|
@@ -44,17 +44,17 @@
|
|
|
44
44
|
"@types/etag": "^1.8.1",
|
|
45
45
|
"@types/is-valid-path": "^0.1.0",
|
|
46
46
|
"@types/sharp": "^0.31.1",
|
|
47
|
-
"@vitest/coverage-c8": "^0.
|
|
47
|
+
"@vitest/coverage-c8": "^0.30.1",
|
|
48
48
|
"changelogen": "^0.5.2",
|
|
49
|
-
"eslint": "^8.
|
|
49
|
+
"eslint": "^8.38.0",
|
|
50
50
|
"eslint-config-unjs": "^0.1.0",
|
|
51
51
|
"jiti": "^1.18.2",
|
|
52
52
|
"nodemon": "^2.0.22",
|
|
53
53
|
"prettier": "^2.8.7",
|
|
54
54
|
"serve-handler": "^6.1.5",
|
|
55
|
-
"typescript": "^5.0.
|
|
56
|
-
"unbuild": "^1.
|
|
57
|
-
"vitest": "^0.
|
|
55
|
+
"typescript": "^5.0.4",
|
|
56
|
+
"unbuild": "^1.2.0",
|
|
57
|
+
"vitest": "^0.30.1"
|
|
58
58
|
},
|
|
59
|
-
"packageManager": "pnpm@8.
|
|
59
|
+
"packageManager": "pnpm@8.2.0"
|
|
60
60
|
}
|