@zintrust/cloudflare-containers-proxy 0.4.27 → 0.4.38
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/build-manifest.json +8 -8
- package/dist/index.js +42 -11
- package/package.json +4 -4
package/dist/build-manifest.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/cloudflare-containers-proxy",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"buildDate": "2026-03-
|
|
3
|
+
"version": "0.4.38",
|
|
4
|
+
"buildDate": "2026-03-30T20:01:48.249Z",
|
|
5
5
|
"buildEnvironment": {
|
|
6
6
|
"node": "v22.22.1",
|
|
7
7
|
"platform": "darwin",
|
|
8
8
|
"arch": "arm64"
|
|
9
9
|
},
|
|
10
10
|
"git": {
|
|
11
|
-
"commit": "
|
|
12
|
-
"branch": "
|
|
11
|
+
"commit": "b929eccf",
|
|
12
|
+
"branch": "release"
|
|
13
13
|
},
|
|
14
14
|
"package": {
|
|
15
15
|
"engines": {
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
},
|
|
26
26
|
"files": {
|
|
27
27
|
"build-manifest.json": {
|
|
28
|
-
"size":
|
|
29
|
-
"sha256": "
|
|
28
|
+
"size": 912,
|
|
29
|
+
"sha256": "fbca03fcd929b4f4a2dc218bd8a68cc2e152da4b64cb9e8391f28a49b1b60e30"
|
|
30
30
|
},
|
|
31
31
|
"index.d.ts": {
|
|
32
32
|
"size": 4240,
|
|
33
33
|
"sha256": "866be0a22a8c83d88dc3c93251530ed2ac47bfc12b8640ec43e0429759d7cef8"
|
|
34
34
|
},
|
|
35
35
|
"index.js": {
|
|
36
|
-
"size":
|
|
37
|
-
"sha256": "
|
|
36
|
+
"size": 17927,
|
|
37
|
+
"sha256": "e5fcd5738bcb3e91f989b9918524382d6d88f0cb96a203957d60c7ec6fb4de61"
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
package/dist/index.js
CHANGED
|
@@ -345,13 +345,46 @@ const fetchWithContainerRetry = async (stub, request, attempt = 1) => {
|
|
|
345
345
|
}
|
|
346
346
|
};
|
|
347
347
|
const ROUTES = Object.freeze({
|
|
348
|
-
mysql: { binding: 'ZT_PROXY_MYSQL', prefix: '/mysql' },
|
|
349
|
-
postgres: {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
348
|
+
mysql: { binding: 'ZT_PROXY_MYSQL', prefix: '/mysql', internalPrefix: '/zin/mysql' },
|
|
349
|
+
postgres: {
|
|
350
|
+
binding: 'ZT_PROXY_POSTGRES',
|
|
351
|
+
prefix: '/postgres',
|
|
352
|
+
internalPrefix: '/zin/postgres',
|
|
353
|
+
},
|
|
354
|
+
redis: { binding: 'ZT_PROXY_REDIS', prefix: '/redis', internalPrefix: '/zin/redis' },
|
|
355
|
+
mongodb: {
|
|
356
|
+
binding: 'ZT_PROXY_MONGODB',
|
|
357
|
+
prefix: '/mongodb',
|
|
358
|
+
internalPrefix: '/zin/mongodb',
|
|
359
|
+
},
|
|
360
|
+
sqlserver: {
|
|
361
|
+
binding: 'ZT_PROXY_SQLSERVER',
|
|
362
|
+
prefix: '/sqlserver',
|
|
363
|
+
internalPrefix: '/zin/sqlserver',
|
|
364
|
+
},
|
|
365
|
+
smtp: { binding: 'ZT_PROXY_SMTP', prefix: '/smtp', internalPrefix: '/zin/smtp' },
|
|
354
366
|
});
|
|
367
|
+
const matchesPrefix = (pathname, prefix) => {
|
|
368
|
+
return pathname === prefix || pathname.startsWith(`${prefix}/`);
|
|
369
|
+
};
|
|
370
|
+
const resolveRoute = (request) => {
|
|
371
|
+
const pathname = new URL(request.url).pathname;
|
|
372
|
+
for (const def of Object.values(ROUTES)) {
|
|
373
|
+
if (matchesPrefix(pathname, def.prefix)) {
|
|
374
|
+
return {
|
|
375
|
+
def,
|
|
376
|
+
nextRequest: rewritePrefix(request, def.prefix),
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
if (matchesPrefix(pathname, def.internalPrefix)) {
|
|
380
|
+
return {
|
|
381
|
+
def,
|
|
382
|
+
nextRequest: request,
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return undefined;
|
|
387
|
+
};
|
|
355
388
|
export default {
|
|
356
389
|
async fetch(request, env) {
|
|
357
390
|
const url = new URL(request.url);
|
|
@@ -365,12 +398,11 @@ export default {
|
|
|
365
398
|
routes: Object.keys(ROUTES).map((k) => `/${k}/*`),
|
|
366
399
|
}, { status: 200 });
|
|
367
400
|
}
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
const def = ROUTES[firstSegment];
|
|
371
|
-
if (!def) {
|
|
401
|
+
const resolved = resolveRoute(request);
|
|
402
|
+
if (!resolved) {
|
|
372
403
|
return createJson({ error: 'not_found', message: 'Unknown proxy route' }, { status: 404 });
|
|
373
404
|
}
|
|
405
|
+
const { def, nextRequest } = resolved;
|
|
374
406
|
const namespace = env[def.binding];
|
|
375
407
|
if (!namespace || typeof namespace.getByName !== 'function') {
|
|
376
408
|
return createJson({
|
|
@@ -381,7 +413,6 @@ export default {
|
|
|
381
413
|
}, { status: 500 });
|
|
382
414
|
}
|
|
383
415
|
const stub = namespace.getByName(CONTAINER_INSTANCE_NAME);
|
|
384
|
-
const nextRequest = rewritePrefix(request, def.prefix);
|
|
385
416
|
return fetchWithContainerRetry(stub, nextRequest);
|
|
386
417
|
},
|
|
387
418
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/cloudflare-containers-proxy",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.38",
|
|
4
4
|
"description": "Cloudflare Containers gateway package for the ZinTrust proxy stack.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"workers"
|
|
28
28
|
],
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@zintrust/core": "^0.4.
|
|
30
|
+
"@zintrust/core": "^0.4.38"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@cloudflare/containers": "^0.
|
|
34
|
-
"@cloudflare/workers-types": "^4.
|
|
33
|
+
"@cloudflare/containers": "^0.2.0",
|
|
34
|
+
"@cloudflare/workers-types": "^4.20260329.1"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json",
|