express-file-cluster 0.10.0 → 0.10.2
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/auth/index.cjs +7 -6
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +5 -5
- package/dist/{chunk-R52CUEGT.js → chunk-3SWI46YK.js} +2 -2
- package/dist/{chunk-DCJOWFVD.cjs → chunk-4GHK27JA.cjs} +3 -3
- package/dist/{chunk-DCJOWFVD.cjs.map → chunk-4GHK27JA.cjs.map} +1 -1
- package/dist/{chunk-NI2BNGGV.js → chunk-5LPRKZPB.js} +2 -2
- package/dist/chunk-74BSJXWD.cjs +220 -0
- package/dist/chunk-74BSJXWD.cjs.map +1 -0
- package/dist/{chunk-7KO4DJRJ.cjs → chunk-7BC3AN7R.cjs} +14 -14
- package/dist/{chunk-7KO4DJRJ.cjs.map → chunk-7BC3AN7R.cjs.map} +1 -1
- package/dist/chunk-AGOYTFRO.cjs +42 -0
- package/dist/chunk-AGOYTFRO.cjs.map +1 -0
- package/dist/{chunk-RAB44UGX.js → chunk-B6MB6HEG.js} +1 -1
- package/dist/{chunk-PGJQK36V.js → chunk-BG4A7Z32.js} +7 -5
- package/dist/{chunk-PGJQK36V.js.map → chunk-BG4A7Z32.js.map} +1 -1
- package/dist/{chunk-ATVD2HGC.js → chunk-C2FOZ7ME.js} +4 -4
- package/dist/chunk-CGY7JU4Y.cjs +8 -0
- package/dist/chunk-CGY7JU4Y.cjs.map +1 -0
- package/dist/{chunk-EGSSZUVO.js → chunk-DN4TCGYB.js} +38 -11
- package/dist/chunk-DN4TCGYB.js.map +1 -0
- package/dist/{chunk-GBI77W5T.cjs → chunk-H2PVWCWC.cjs} +1 -1
- package/dist/{chunk-GBI77W5T.cjs.map → chunk-H2PVWCWC.cjs.map} +1 -1
- package/dist/{chunk-NKLOE4AK.cjs → chunk-IUZ6A7PB.cjs} +20 -53
- package/dist/chunk-IUZ6A7PB.cjs.map +1 -0
- package/dist/{chunk-DUADUR6R.cjs → chunk-JP36TLL4.cjs} +171 -14
- package/dist/chunk-JP36TLL4.cjs.map +1 -0
- package/dist/chunk-KLWL7XSC.js +220 -0
- package/dist/chunk-KLWL7XSC.js.map +1 -0
- package/dist/{chunk-4DOHQU6I.cjs → chunk-M53GODCX.cjs} +39 -12
- package/dist/chunk-M53GODCX.cjs.map +1 -0
- package/dist/{chunk-R4XO4SVM.js → chunk-MUVO7MGS.js} +4 -4
- package/dist/{chunk-HBCY7ILD.cjs → chunk-R2K7AFIB.cjs} +97 -95
- package/dist/chunk-R2K7AFIB.cjs.map +1 -0
- package/dist/{chunk-QDEDOHP7.js → chunk-RETV3GKE.js} +9 -42
- package/dist/chunk-RETV3GKE.js.map +1 -0
- package/dist/{chunk-WBLUGOAG.cjs → chunk-RPL2IFWK.cjs} +8 -5
- package/dist/chunk-RPL2IFWK.cjs.map +1 -0
- package/dist/{chunk-YK4ZM3CA.cjs → chunk-TBIVIR6L.cjs} +15 -15
- package/dist/{chunk-YK4ZM3CA.cjs.map → chunk-TBIVIR6L.cjs.map} +1 -1
- package/dist/{chunk-73XJUT2S.js → chunk-V73R76I4.js} +162 -5
- package/dist/chunk-V73R76I4.js.map +1 -0
- package/dist/chunk-XPY5TQDK.js +42 -0
- package/dist/chunk-XPY5TQDK.js.map +1 -0
- package/dist/{chunk-KFVFP2Q7.cjs → chunk-Y4NKIXUL.cjs} +70 -55
- package/dist/chunk-Y4NKIXUL.cjs.map +1 -0
- package/dist/{chunk-7KC2H76D.js → chunk-Y75V5FCU.js} +62 -47
- package/dist/chunk-Y75V5FCU.js.map +1 -0
- package/dist/cli/db-runner.cjs +81 -42
- package/dist/cli/db-runner.cjs.map +1 -1
- package/dist/cli/db-runner.js +54 -16
- package/dist/cli/db-runner.js.map +1 -1
- package/dist/cli/index.cjs +23 -25
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +12 -17
- package/dist/cli/index.js.map +1 -1
- package/dist/docs/api-reference/auth.md +23 -0
- package/dist/docs/api-reference/compose.md +1 -1
- package/dist/docs/api-reference/db.md +8 -0
- package/dist/docs/api-reference/ignite.md +4 -1
- package/dist/docs/api-reference/testing.md +26 -0
- package/dist/docs/cli/add.md +2 -2
- package/dist/docs/core-concepts/file-based-routing.md +2 -0
- package/dist/docs/core-concepts/middleware.md +2 -2
- package/dist/docs/getting-started/index.md +4 -0
- package/dist/docs/guides/authentication.md +33 -0
- package/dist/docs/guides/caching.md +2 -0
- package/dist/docs/guides/database.md +15 -0
- package/dist/docs/guides/environment-variables.md +6 -0
- package/dist/docs/guides/generated-portals.md +3 -1
- package/dist/docs/guides/logging.md +17 -0
- package/dist/docs/guides/migrations.md +4 -2
- package/dist/docs/guides/testing.md +31 -0
- package/dist/docs/index.md +2 -1
- package/dist/docs/skills/SKILL.md +5 -1
- package/dist/docs/skills/api-surface.md +20 -4
- package/dist/docs/skills/auth-internals.md +14 -1
- package/dist/docs/skills/pre-flight.md +6 -0
- package/dist/docs/skills/routing-rules.md +1 -1
- package/dist/docs/skills/what-not-to-invent.md +9 -1
- package/dist/docs/versioning.md +1 -1
- package/dist/index.cjs +75 -264
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -3
- package/dist/index.d.ts +27 -3
- package/dist/index.js +28 -218
- package/dist/index.js.map +1 -1
- package/dist/pgboss-backend-4X2YT4RB.js +14 -0
- package/dist/pgboss-backend-UXQ3O2WT.cjs +15 -0
- package/dist/pgboss-backend-UXQ3O2WT.cjs.map +1 -0
- package/dist/registry/index.json +27 -3
- package/dist/registry/js-mongo/account-security.json +1 -1
- package/dist/registry/js-mongo/admin-users.json +1 -1
- package/dist/registry/js-mongo/auth.json +1 -1
- package/dist/registry/js-mongo/auth@apple.json +1 -1
- package/dist/registry/js-mongo/auth@google.json +1 -1
- package/dist/registry/js-mongo/forgot-password.json +1 -1
- package/dist/registry/js-mongo/user-profile.json +1 -1
- package/dist/registry/js-mongo-collection/account-security.json +1 -1
- package/dist/registry/js-mongo-collection/admin-users.json +1 -1
- package/dist/registry/js-mongo-collection/auth.json +1 -1
- package/dist/registry/js-mongo-collection/auth@apple.json +1 -1
- package/dist/registry/js-mongo-collection/auth@google.json +1 -1
- package/dist/registry/js-mongo-collection/forgot-password.json +1 -1
- package/dist/registry/js-mongo-collection/user-profile.json +1 -1
- package/dist/registry/js-pg-model/account-security.json +1 -1
- package/dist/registry/js-pg-model/admin-users.json +1 -1
- package/dist/registry/js-pg-model/auth.json +1 -1
- package/dist/registry/js-pg-model/auth@apple.json +1 -1
- package/dist/registry/js-pg-model/auth@google.json +1 -1
- package/dist/registry/js-pg-model/forgot-password.json +1 -1
- package/dist/registry/js-pg-model/user-profile.json +1 -1
- package/dist/registry/js-pg-table/account-security.json +1 -1
- package/dist/registry/js-pg-table/admin-users.json +1 -1
- package/dist/registry/js-pg-table/auth.json +1 -1
- package/dist/registry/js-pg-table/auth@apple.json +1 -1
- package/dist/registry/js-pg-table/auth@google.json +1 -1
- package/dist/registry/js-pg-table/forgot-password.json +1 -1
- package/dist/registry/js-pg-table/user-profile.json +1 -1
- package/dist/registry/ts-mongo/account-security.json +1 -1
- package/dist/registry/ts-mongo/admin-users.json +1 -1
- package/dist/registry/ts-mongo/auth.json +1 -1
- package/dist/registry/ts-mongo/auth@apple.json +1 -1
- package/dist/registry/ts-mongo/auth@google.json +1 -1
- package/dist/registry/ts-mongo/forgot-password.json +1 -1
- package/dist/registry/ts-mongo/user-profile.json +1 -1
- package/dist/registry/ts-mongo-collection/account-security.json +1 -1
- package/dist/registry/ts-mongo-collection/admin-users.json +1 -1
- package/dist/registry/ts-mongo-collection/auth.json +1 -1
- package/dist/registry/ts-mongo-collection/auth@apple.json +1 -1
- package/dist/registry/ts-mongo-collection/auth@google.json +1 -1
- package/dist/registry/ts-mongo-collection/forgot-password.json +1 -1
- package/dist/registry/ts-mongo-collection/user-profile.json +1 -1
- package/dist/registry/ts-pg-model/account-security.json +1 -1
- package/dist/registry/ts-pg-model/admin-users.json +1 -1
- package/dist/registry/ts-pg-model/auth.json +1 -1
- package/dist/registry/ts-pg-model/auth@apple.json +1 -1
- package/dist/registry/ts-pg-model/auth@google.json +1 -1
- package/dist/registry/ts-pg-model/forgot-password.json +1 -1
- package/dist/registry/ts-pg-model/user-profile.json +1 -1
- package/dist/registry/ts-pg-table/account-security.json +1 -1
- package/dist/registry/ts-pg-table/admin-users.json +1 -1
- package/dist/registry/ts-pg-table/auth.json +1 -1
- package/dist/registry/ts-pg-table/auth@apple.json +1 -1
- package/dist/registry/ts-pg-table/auth@google.json +1 -1
- package/dist/registry/ts-pg-table/forgot-password.json +1 -1
- package/dist/registry/ts-pg-table/user-profile.json +1 -1
- package/dist/tasks/index.cjs +3 -2
- package/dist/tasks/index.cjs.map +1 -1
- package/dist/tasks/index.d.cts +1 -1
- package/dist/tasks/index.d.ts +1 -1
- package/dist/tasks/index.js +1 -1
- package/dist/testing-cjs.cjs +5 -0
- package/dist/testing.cjs +59 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +27 -0
- package/dist/testing.d.ts +27 -0
- package/dist/testing.js +58 -0
- package/dist/testing.js.map +1 -0
- package/dist/thread-runner.cjs +4 -3
- package/dist/thread-runner.cjs.map +1 -1
- package/dist/thread-runner.js +2 -2
- package/dist/{types-Bnxvj3l0.d.ts → types-CPMFTVXm.d.cts} +8 -0
- package/dist/{types-Bnxvj3l0.d.cts → types-CPMFTVXm.d.ts} +8 -0
- package/package.json +6 -1
- package/dist/chunk-4DOHQU6I.cjs.map +0 -1
- package/dist/chunk-73XJUT2S.js.map +0 -1
- package/dist/chunk-7KC2H76D.js.map +0 -1
- package/dist/chunk-DUADUR6R.cjs.map +0 -1
- package/dist/chunk-EGSSZUVO.js.map +0 -1
- package/dist/chunk-HBCY7ILD.cjs.map +0 -1
- package/dist/chunk-KFVFP2Q7.cjs.map +0 -1
- package/dist/chunk-NKLOE4AK.cjs.map +0 -1
- package/dist/chunk-QDEDOHP7.js.map +0 -1
- package/dist/chunk-WBLUGOAG.cjs.map +0 -1
- package/dist/pgboss-backend-FW42SBSM.js +0 -14
- package/dist/pgboss-backend-RVHUBJTU.cjs +0 -14
- package/dist/pgboss-backend-RVHUBJTU.cjs.map +0 -1
- /package/dist/{chunk-R52CUEGT.js.map → chunk-3SWI46YK.js.map} +0 -0
- /package/dist/{chunk-NI2BNGGV.js.map → chunk-5LPRKZPB.js.map} +0 -0
- /package/dist/{chunk-RAB44UGX.js.map → chunk-B6MB6HEG.js.map} +0 -0
- /package/dist/{chunk-ATVD2HGC.js.map → chunk-C2FOZ7ME.js.map} +0 -0
- /package/dist/{chunk-R4XO4SVM.js.map → chunk-MUVO7MGS.js.map} +0 -0
- /package/dist/{pgboss-backend-FW42SBSM.js.map → pgboss-backend-4X2YT4RB.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -2,198 +2,71 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
var _chunk74BSJXWDcjs = require('./chunk-74BSJXWD.cjs');
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
var _chunkKFVFP2Q7cjs = require('./chunk-KFVFP2Q7.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var _chunkDCJOWFVDcjs = require('./chunk-DCJOWFVD.cjs');
|
|
13
12
|
|
|
14
13
|
|
|
14
|
+
var _chunkY4NKIXULcjs = require('./chunk-Y4NKIXUL.cjs');
|
|
15
15
|
|
|
16
|
-
var _chunkYK4ZM3CAcjs = require('./chunk-YK4ZM3CA.cjs');
|
|
17
16
|
|
|
17
|
+
var _chunk4GHK27JAcjs = require('./chunk-4GHK27JA.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
|
|
21
|
+
var _chunkTBIVIR6Lcjs = require('./chunk-TBIVIR6L.cjs');
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
|
|
26
|
-
var _chunkHBCY7ILDcjs = require('./chunk-HBCY7ILD.cjs');
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
var _chunkR2K7AFIBcjs = require('./chunk-R2K7AFIB.cjs');
|
|
31
32
|
|
|
32
33
|
|
|
33
|
-
var _chunkNKLOE4AKcjs = require('./chunk-NKLOE4AK.cjs');
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
var _chunkIUZ6A7PBcjs = require('./chunk-IUZ6A7PB.cjs');
|
|
36
37
|
|
|
37
|
-
var _chunk7KO4DJRJcjs = require('./chunk-7KO4DJRJ.cjs');
|
|
38
|
-
require('./chunk-WBLUGOAG.cjs');
|
|
39
38
|
|
|
40
39
|
|
|
40
|
+
var _chunkAGOYTFROcjs = require('./chunk-AGOYTFRO.cjs');
|
|
41
41
|
|
|
42
|
-
var _chunkGBI77W5Tcjs = require('./chunk-GBI77W5T.cjs');
|
|
43
42
|
|
|
44
43
|
|
|
44
|
+
var _chunk7BC3AN7Rcjs = require('./chunk-7BC3AN7R.cjs');
|
|
45
|
+
require('./chunk-RPL2IFWK.cjs');
|
|
45
46
|
|
|
46
47
|
|
|
47
48
|
|
|
49
|
+
var _chunkH2PVWCWCcjs = require('./chunk-H2PVWCWC.cjs');
|
|
48
50
|
|
|
49
51
|
|
|
50
52
|
|
|
51
53
|
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
var _chunkJP36TLL4cjs = require('./chunk-JP36TLL4.cjs');
|
|
61
|
+
require('./chunk-CGY7JU4Y.cjs');
|
|
54
62
|
|
|
55
63
|
// src/index.ts
|
|
56
64
|
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
57
65
|
var _express = require('express'); var _express2 = _interopRequireDefault(_express);
|
|
58
|
-
var _cors = require('cors'); var _cors2 = _interopRequireDefault(_cors);
|
|
59
|
-
var _cookieparser = require('cookie-parser'); var _cookieparser2 = _interopRequireDefault(_cookieparser);
|
|
60
66
|
var _cluster = require('cluster'); var _cluster2 = _interopRequireDefault(_cluster);
|
|
61
67
|
var _os = require('os'); var _os2 = _interopRequireDefault(_os);
|
|
62
68
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
63
69
|
|
|
64
|
-
// src/router/validate.ts
|
|
65
|
-
var LOCATIONS = ["params", "query", "body"];
|
|
66
|
-
function isRequestSchema(value) {
|
|
67
|
-
return value != null && typeof value === "object" && LOCATIONS.some((loc) => loc in value);
|
|
68
|
-
}
|
|
69
|
-
function schemaFor(schema, method) {
|
|
70
|
-
if (!schema) return void 0;
|
|
71
|
-
const byMethod = schema[method];
|
|
72
|
-
if (isRequestSchema(byMethod)) return byMethod;
|
|
73
|
-
return isRequestSchema(schema) ? schema : void 0;
|
|
74
|
-
}
|
|
75
|
-
function pathToString(path3) {
|
|
76
|
-
if (!path3) return "";
|
|
77
|
-
return path3.map((p) => typeof p === "object" && p !== null && "key" in p ? p.key : p).map(String).join(".");
|
|
78
|
-
}
|
|
79
|
-
async function run(validator, input) {
|
|
80
|
-
const std = validator["~standard"];
|
|
81
|
-
if (std && typeof std.validate === "function") {
|
|
82
|
-
return await std.validate(input);
|
|
83
|
-
}
|
|
84
|
-
const v = validator;
|
|
85
|
-
const parse = _nullishCoalesce(v.safeParseAsync, () => ( v.safeParse));
|
|
86
|
-
if (typeof parse !== "function") {
|
|
87
|
-
throw new Error("[EFC] Route schema entries must be Standard Schema validators (e.g. zod)");
|
|
88
|
-
}
|
|
89
|
-
const r = await parse.call(validator, input);
|
|
90
|
-
return r.success ? { value: r.data } : { issues: _nullishCoalesce(_optionalChain([r, 'access', _ => _.error, 'optionalAccess', _2 => _2.issues]), () => ( [{ message: "Invalid" }])) };
|
|
91
|
-
}
|
|
92
|
-
function validateRequest(schema) {
|
|
93
|
-
return (req, res, next) => {
|
|
94
|
-
void (async () => {
|
|
95
|
-
const issues = [];
|
|
96
|
-
const parsed = {};
|
|
97
|
-
for (const location of LOCATIONS) {
|
|
98
|
-
const validator = schema[location];
|
|
99
|
-
if (!validator) continue;
|
|
100
|
-
const result = await run(validator, req[location]);
|
|
101
|
-
if (result.issues) {
|
|
102
|
-
for (const issue of result.issues) {
|
|
103
|
-
issues.push({ location, path: pathToString(issue.path), message: issue.message });
|
|
104
|
-
}
|
|
105
|
-
} else {
|
|
106
|
-
parsed[location] = result.value;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if (issues.length > 0) {
|
|
110
|
-
res.status(400).json({ error: "Validation failed", statusCode: 400, issues });
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
for (const location of LOCATIONS) {
|
|
114
|
-
if (location in parsed) {
|
|
115
|
-
Object.defineProperty(req, location, {
|
|
116
|
-
value: parsed[location],
|
|
117
|
-
writable: true,
|
|
118
|
-
configurable: true,
|
|
119
|
-
enumerable: true
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
next();
|
|
124
|
-
})().catch(next);
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// src/router/mount.ts
|
|
129
|
-
var HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
|
|
130
|
-
function asyncWrap(handler) {
|
|
131
|
-
return (req, res, next) => {
|
|
132
|
-
Promise.resolve(handler(req, res, next)).catch(next);
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function namedParams(route) {
|
|
136
|
-
const catchAlls = new Set([...route.urlPath.matchAll(/:([A-Za-z0-9_$]+)\*/g)].map((m) => m[1]));
|
|
137
|
-
return (req, _res, next) => {
|
|
138
|
-
const positional = req.params;
|
|
139
|
-
const named = {};
|
|
140
|
-
route.params.forEach((name, i) => {
|
|
141
|
-
const value = positional[String(i)];
|
|
142
|
-
if (value === void 0 || value === "") {
|
|
143
|
-
named[name] = catchAlls.has(name) ? [] : void 0;
|
|
144
|
-
} else if (catchAlls.has(name)) {
|
|
145
|
-
named[name] = value.split("/").filter(Boolean).map(decodeURIComponent);
|
|
146
|
-
} else {
|
|
147
|
-
named[name] = decodeURIComponent(value);
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
req.params = named;
|
|
151
|
-
next();
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
async function mountRoutes(app, routes) {
|
|
155
|
-
const mounted = [];
|
|
156
|
-
for (const route of routes) {
|
|
157
|
-
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require(route.filePath)));
|
|
158
|
-
const routeMiddlewares = Array.isArray(mod["middlewares"]) ? mod["middlewares"] : [];
|
|
159
|
-
const raw = mod["meta"];
|
|
160
|
-
const meta = raw != null && typeof raw === "object" && !Array.isArray(raw) ? raw : void 0;
|
|
161
|
-
const schema = mod["schema"] != null && typeof mod["schema"] === "object" ? mod["schema"] : void 0;
|
|
162
|
-
const routePath = _nullishCoalesce(route.pattern, () => ( route.urlPath));
|
|
163
|
-
const paramMapper = route.pattern ? [namedParams(route)] : [];
|
|
164
|
-
const implemented = [];
|
|
165
|
-
const unimplemented = [];
|
|
166
|
-
for (const method of HTTP_METHODS) {
|
|
167
|
-
if (typeof mod[method] === "function") {
|
|
168
|
-
implemented.push(method);
|
|
169
|
-
const methodSchema = schemaFor(schema, method);
|
|
170
|
-
const validation = methodSchema ? [validateRequest(methodSchema)] : [];
|
|
171
|
-
app[method.toLowerCase()](
|
|
172
|
-
routePath,
|
|
173
|
-
...paramMapper,
|
|
174
|
-
...routeMiddlewares,
|
|
175
|
-
...validation,
|
|
176
|
-
asyncWrap(mod[method])
|
|
177
|
-
);
|
|
178
|
-
} else {
|
|
179
|
-
unimplemented.push(method);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (implemented.length > 0 && unimplemented.length > 0) {
|
|
183
|
-
const allowHeader = implemented.join(", ");
|
|
184
|
-
app.all(routePath, (req, res, next) => {
|
|
185
|
-
if (unimplemented.includes(req.method)) {
|
|
186
|
-
res.set("Allow", allowHeader).status(405).json({ error: "Method Not Allowed" });
|
|
187
|
-
} else {
|
|
188
|
-
next();
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
mounted.push({ ...route, methods: implemented, ...meta !== void 0 && { meta } });
|
|
193
|
-
}
|
|
194
|
-
return mounted;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
70
|
// src/cluster/index.ts
|
|
198
71
|
|
|
199
72
|
var isShuttingDown = false;
|
|
@@ -202,33 +75,33 @@ function workerCount() {
|
|
|
202
75
|
}
|
|
203
76
|
function shutdownMaster() {
|
|
204
77
|
isShuttingDown = true;
|
|
205
|
-
|
|
78
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).info(`Cluster primary (pid=${process.pid}) shutting down, waiting for workers\u2026`);
|
|
206
79
|
if (workerCount() === 0) process.exit(0);
|
|
207
80
|
for (const worker of Object.values(_nullishCoalesce(_cluster2.default.workers, () => ( {})))) {
|
|
208
|
-
_optionalChain([worker, 'optionalAccess',
|
|
81
|
+
_optionalChain([worker, 'optionalAccess', _ => _.process, 'access', _2 => _2.kill, 'call', _3 => _3("SIGTERM")]);
|
|
209
82
|
}
|
|
210
83
|
}
|
|
211
84
|
function runMaster(options = {}) {
|
|
212
85
|
const count = _nullishCoalesce(options.workers, () => ( 1));
|
|
213
|
-
|
|
86
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).info(`Primary ${process.pid} starting ${count} workers`);
|
|
214
87
|
for (let i = 0; i < count; i++) {
|
|
215
88
|
_cluster2.default.fork();
|
|
216
89
|
}
|
|
217
90
|
_cluster2.default.on("online", (worker) => {
|
|
218
|
-
_optionalChain([options, 'access',
|
|
91
|
+
_optionalChain([options, 'access', _4 => _4.onWorkerReady, 'optionalCall', _5 => _5(worker.id)]);
|
|
219
92
|
});
|
|
220
93
|
_cluster2.default.on("exit", (worker, code, signal) => {
|
|
221
94
|
const exitCode = _nullishCoalesce(code, () => ( (signal ? -1 : 0)));
|
|
222
95
|
if (isShuttingDown) {
|
|
223
|
-
|
|
96
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).info(`Worker ${worker.id} gracefully exited`);
|
|
224
97
|
if (workerCount() === 0) {
|
|
225
|
-
|
|
98
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).info("All workers exited. Primary exiting.");
|
|
226
99
|
process.exit(0);
|
|
227
100
|
}
|
|
228
101
|
return;
|
|
229
102
|
}
|
|
230
|
-
|
|
231
|
-
_optionalChain([options, 'access',
|
|
103
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).warn(`Worker ${worker.id} exited (code=${exitCode}), respawning\u2026`);
|
|
104
|
+
_optionalChain([options, 'access', _6 => _6.onWorkerCrash, 'optionalCall', _7 => _7(worker.id, exitCode)]);
|
|
232
105
|
_cluster2.default.fork();
|
|
233
106
|
});
|
|
234
107
|
}
|
|
@@ -246,13 +119,13 @@ async function scanTasks(tasksDir) {
|
|
|
246
119
|
const mod = await Promise.resolve().then(() => _interopRequireWildcard(require(filePath)));
|
|
247
120
|
const def = mod["default"];
|
|
248
121
|
if (!def || typeof def.handler !== "function") {
|
|
249
|
-
|
|
122
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).warn(`Task file ${file} has no valid default export \u2014 skipping`);
|
|
250
123
|
continue;
|
|
251
124
|
}
|
|
252
|
-
|
|
253
|
-
|
|
125
|
+
_chunkH2PVWCWCcjs.registerTask.call(void 0, taskName, { ...def, filePath });
|
|
126
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).debug(`Registered task: ${taskName}`);
|
|
254
127
|
} catch (err) {
|
|
255
|
-
|
|
128
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).warn({ err }, `Failed to load task ${file}`);
|
|
256
129
|
}
|
|
257
130
|
}
|
|
258
131
|
}
|
|
@@ -879,21 +752,21 @@ function rateLimit(options) {
|
|
|
879
752
|
void (async () => {
|
|
880
753
|
const who = keyOf(req);
|
|
881
754
|
if (who === void 0) return next();
|
|
882
|
-
if (!
|
|
755
|
+
if (!_chunkY4NKIXULcjs.isCacheConfigured.call(void 0, )) {
|
|
883
756
|
throw new Error("[EFC] rateLimit needs a cache \u2014 pass cache: { backend } to ignite()");
|
|
884
757
|
}
|
|
885
|
-
const bucket = _nullishCoalesce(options.name, () => ( req.baseUrl + (_nullishCoalesce(_optionalChain([req, 'access',
|
|
758
|
+
const bucket = _nullishCoalesce(options.name, () => ( req.baseUrl + (_nullishCoalesce(_optionalChain([req, 'access', _8 => _8.route, 'optionalAccess', _9 => _9.path]), () => ( req.path)))));
|
|
886
759
|
const windowMs = windowSeconds * 1e3;
|
|
887
760
|
const now = Date.now();
|
|
888
761
|
const slot = Math.floor(now / windowMs);
|
|
889
762
|
const resetMs = (slot + 1) * windowMs - now;
|
|
890
763
|
let count;
|
|
891
764
|
try {
|
|
892
|
-
count = (await
|
|
765
|
+
count = (await _chunkY4NKIXULcjs.rawIncr.call(void 0, `rl:${bucket}:${who}:${slot}`, Math.ceil(resetMs / 1e3) + 1)).value;
|
|
893
766
|
} catch (err) {
|
|
894
767
|
if (Date.now() - lastCacheError > 3e4) {
|
|
895
768
|
lastCacheError = Date.now();
|
|
896
|
-
|
|
769
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).error(
|
|
897
770
|
{ err },
|
|
898
771
|
`rateLimit: cache unavailable \u2014 ${options.onCacheError === "reject" ? "rejecting with 503" : "allowing requests"}`
|
|
899
772
|
);
|
|
@@ -928,14 +801,14 @@ function cacheResponse(options) {
|
|
|
928
801
|
if (req.method !== "GET" && req.method !== "HEAD") return next();
|
|
929
802
|
let scope = "";
|
|
930
803
|
if (opts.perUser) {
|
|
931
|
-
const user =
|
|
932
|
-
const id = _nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
804
|
+
const user = _chunkJP36TLL4cjs.getCurrentUser.call(void 0, );
|
|
805
|
+
const id = _nullishCoalesce(_optionalChain([user, 'optionalAccess', _10 => _10["sub"]]), () => ( _optionalChain([user, 'optionalAccess', _11 => _11["id"]])));
|
|
933
806
|
if (id === void 0) return next();
|
|
934
807
|
scope = `u:${String(id)}:`;
|
|
935
808
|
}
|
|
936
809
|
const key = RESPONSE_PREFIX + scope + (opts.key ? opts.key(req) : req.originalUrl);
|
|
937
810
|
void (async () => {
|
|
938
|
-
const hit = await
|
|
811
|
+
const hit = await _chunkY4NKIXULcjs.cache.get(key);
|
|
939
812
|
if (hit) {
|
|
940
813
|
res.setHeader("X-Cache", "HIT");
|
|
941
814
|
res.status(hit.status).json(hit.body);
|
|
@@ -944,7 +817,7 @@ function cacheResponse(options) {
|
|
|
944
817
|
res.setHeader("X-Cache", "MISS");
|
|
945
818
|
const json = res.json.bind(res);
|
|
946
819
|
res.json = (body) => {
|
|
947
|
-
if (res.statusCode === 200) void
|
|
820
|
+
if (res.statusCode === 200) void _chunkY4NKIXULcjs.cache.set(key, { status: 200, body }, { ttl: opts.ttl });
|
|
948
821
|
return json(body);
|
|
949
822
|
};
|
|
950
823
|
next();
|
|
@@ -966,7 +839,9 @@ function compose(...handlers) {
|
|
|
966
839
|
return;
|
|
967
840
|
}
|
|
968
841
|
try {
|
|
969
|
-
Promise.resolve(
|
|
842
|
+
Promise.resolve(
|
|
843
|
+
handler(req, res, (err) => err ? next(err) : dispatch(i + 1))
|
|
844
|
+
).catch(next);
|
|
970
845
|
} catch (err) {
|
|
971
846
|
next(err);
|
|
972
847
|
}
|
|
@@ -983,14 +858,7 @@ function detectDatabase(url) {
|
|
|
983
858
|
return void 0;
|
|
984
859
|
}
|
|
985
860
|
async function ignite(config) {
|
|
986
|
-
const {
|
|
987
|
-
port: _port,
|
|
988
|
-
workers,
|
|
989
|
-
globalMiddlewares = [],
|
|
990
|
-
onWorkerReady,
|
|
991
|
-
onWorkerCrash,
|
|
992
|
-
onError
|
|
993
|
-
} = config;
|
|
861
|
+
const { port: _port, workers, onWorkerReady, onWorkerCrash, onError } = config;
|
|
994
862
|
function resolveConventionDir(name) {
|
|
995
863
|
const candidates = [
|
|
996
864
|
...process.argv[1] ? [_path2.default.join(_path2.default.dirname(process.argv[1]), name)] : [],
|
|
@@ -1018,21 +886,21 @@ async function ignite(config) {
|
|
|
1018
886
|
const jwtSecret = config.jwtSecret;
|
|
1019
887
|
const authStrategy = _nullishCoalesce(config.authStrategy, () => ( "http-only"));
|
|
1020
888
|
const clusterEnabled = _nullishCoalesce(config.cluster, () => ( process.env["NODE_ENV"] === "production"));
|
|
1021
|
-
|
|
889
|
+
_chunkJP36TLL4cjs.configureLogger.call(void 0, config.logging);
|
|
1022
890
|
if (!["http-only", "bearer", "localStorage"].includes(authStrategy) && (!clusterEnabled || _cluster2.default.isPrimary)) {
|
|
1023
|
-
|
|
891
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).warn(
|
|
1024
892
|
`[EFC] Unknown authStrategy "${String(authStrategy)}" \u2014 treated as 'bearer'. Use 'http-only' or 'bearer'; this will be an error in 1.0.`
|
|
1025
893
|
);
|
|
1026
894
|
}
|
|
1027
895
|
if (jwtSecret && Buffer.byteLength(jwtSecret) < 32 && process.env["NODE_ENV"] === "production" && (!clusterEnabled || _cluster2.default.isPrimary)) {
|
|
1028
|
-
|
|
896
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).warn(
|
|
1029
897
|
`[EFC] jwtSecret is ${Buffer.byteLength(jwtSecret)} bytes \u2014 use at least 32 random bytes in production (openssl rand -hex 64).`
|
|
1030
898
|
);
|
|
1031
899
|
}
|
|
1032
|
-
|
|
900
|
+
_chunkJP36TLL4cjs.configureQueryLog.call(void 0, config.logging);
|
|
1033
901
|
if (clusterEnabled && _cluster2.default.isPrimary) {
|
|
1034
902
|
if (config.cache && config.cache.backend === "memory") {
|
|
1035
|
-
|
|
903
|
+
_chunkY4NKIXULcjs.servePrimaryCache.call(void 0, _nullishCoalesce(config.cache.maxEntries, () => ( 1e4)));
|
|
1036
904
|
}
|
|
1037
905
|
runMaster({
|
|
1038
906
|
workers: _nullishCoalesce(workers, () => ( _os2.default.cpus().length)),
|
|
@@ -1041,68 +909,35 @@ async function ignite(config) {
|
|
|
1041
909
|
});
|
|
1042
910
|
return;
|
|
1043
911
|
}
|
|
1044
|
-
const app =
|
|
1045
|
-
if (
|
|
1046
|
-
|
|
1047
|
-
"json replacer",
|
|
1048
|
-
(_key, value) => typeof value === "bigint" ? value.toString() : value
|
|
1049
|
-
);
|
|
1050
|
-
app.use((_req, _res, next) => {
|
|
1051
|
-
_chunkDUADUR6Rcjs.runWithContext.call(void 0, {}, next);
|
|
1052
|
-
});
|
|
1053
|
-
app.use(_chunkDUADUR6Rcjs.requestLogger.call(void 0, ));
|
|
1054
|
-
if (config.requestTimeout) {
|
|
1055
|
-
const ms = config.requestTimeout;
|
|
1056
|
-
app.use((_req, res, next) => {
|
|
1057
|
-
const timer = setTimeout(() => {
|
|
1058
|
-
if (!res.headersSent) res.status(408).json({ error: "Request Timeout", statusCode: 408 });
|
|
1059
|
-
}, ms);
|
|
1060
|
-
const clear = () => clearTimeout(timer);
|
|
1061
|
-
res.once("finish", clear);
|
|
1062
|
-
res.once("close", clear);
|
|
1063
|
-
next();
|
|
1064
|
-
});
|
|
1065
|
-
}
|
|
1066
|
-
const corsOption = _nullishCoalesce(config.cors, () => ( true));
|
|
1067
|
-
if (corsOption !== false) {
|
|
1068
|
-
const origin = typeof corsOption === "object" && corsOption.origin !== void 0 ? corsOption.origin : true;
|
|
1069
|
-
const corsOpts = typeof corsOption === "object" ? { ...corsOption, origin } : { origin };
|
|
1070
|
-
app.use(_cors2.default.call(void 0, corsOpts));
|
|
1071
|
-
}
|
|
1072
|
-
app.use(_express2.default.json());
|
|
1073
|
-
app.use(_express2.default.urlencoded({ extended: true }));
|
|
1074
|
-
app.use(_cookieparser2.default.call(void 0, ));
|
|
1075
|
-
for (const mw of globalMiddlewares) {
|
|
1076
|
-
app.use(mw);
|
|
1077
|
-
}
|
|
1078
|
-
if (database) _chunkNKLOE4AKcjs.setDbEngine.call(void 0, database);
|
|
1079
|
-
_chunkNKLOE4AKcjs.setAutoSync.call(void 0, _nullishCoalesce(config.autoSync, () => ( true)));
|
|
912
|
+
const app = _chunk74BSJXWDcjs.createHttpApp.call(void 0, config);
|
|
913
|
+
if (database) _chunkIUZ6A7PBcjs.setDbEngine.call(void 0, database);
|
|
914
|
+
_chunkIUZ6A7PBcjs.setAutoSync.call(void 0, _nullishCoalesce(config.autoSync, () => ( true)));
|
|
1080
915
|
const poolWorkers = clusterEnabled ? _nullishCoalesce(workers, () => ( _os2.default.cpus().length)) : 1;
|
|
1081
|
-
const reportsPools = !clusterEnabled || _optionalChain([_cluster2.default, 'access',
|
|
916
|
+
const reportsPools = !clusterEnabled || _optionalChain([_cluster2.default, 'access', _12 => _12.worker, 'optionalAccess', _13 => _13.id]) === 1;
|
|
1082
917
|
if (database === "mongodb" && databaseUrl) {
|
|
1083
|
-
const conn = await
|
|
1084
|
-
|
|
918
|
+
const conn = await _chunkR2K7AFIBcjs.connectMongo.call(void 0, databaseUrl, config.databasePool);
|
|
919
|
+
_chunkR2K7AFIBcjs.setDbClient.call(void 0, conn);
|
|
1085
920
|
if (reportsPools) {
|
|
1086
|
-
const max = _nullishCoalesce(_optionalChain([config, 'access',
|
|
1087
|
-
|
|
921
|
+
const max = _nullishCoalesce(_optionalChain([config, 'access', _14 => _14.databasePool, 'optionalAccess', _15 => _15.max]), () => ( 100));
|
|
922
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).info(
|
|
1088
923
|
`MongoDB connections: up to ${poolWorkers * max} from this machine (${poolWorkers} worker(s) \xD7 maxPoolSize ${max})`
|
|
1089
924
|
);
|
|
1090
925
|
}
|
|
1091
926
|
} else if (database === "postgresql" && databaseUrl) {
|
|
1092
|
-
const pool = await
|
|
1093
|
-
|
|
927
|
+
const pool = await _chunkJP36TLL4cjs.connectPostgres.call(void 0, databaseUrl, config.databasePool);
|
|
928
|
+
_chunkR2K7AFIBcjs.setDbClient.call(void 0, pool);
|
|
1094
929
|
if (reportsPools) {
|
|
1095
|
-
const max = _nullishCoalesce(_optionalChain([config, 'access',
|
|
930
|
+
const max = _nullishCoalesce(_optionalChain([config, 'access', _16 => _16.databasePool, 'optionalAccess', _17 => _17.max]), () => ( 10));
|
|
1096
931
|
const boss = config.tasks && config.tasks.backend === "pg-boss" && !config.tasks.connectionString ? 10 : 0;
|
|
1097
932
|
const breakdown = `${poolWorkers} worker(s) \xD7 (pool ${max}${boss ? ` + pg-boss ${boss}` : ""})`;
|
|
1098
|
-
await
|
|
933
|
+
await _chunkJP36TLL4cjs.checkConnectionBudget.call(void 0, poolWorkers * (max + boss), breakdown);
|
|
1099
934
|
}
|
|
1100
935
|
}
|
|
1101
936
|
if (config.cache) {
|
|
1102
|
-
await
|
|
937
|
+
await _chunkY4NKIXULcjs.configureCache.call(void 0, config.cache);
|
|
1103
938
|
}
|
|
1104
939
|
if (jwtSecret) {
|
|
1105
|
-
|
|
940
|
+
_chunkY4NKIXULcjs.configureAuth.call(void 0, {
|
|
1106
941
|
secret: jwtSecret,
|
|
1107
942
|
strategy: authStrategy,
|
|
1108
943
|
expiresIn: _nullishCoalesce(config.jwtExpiresIn, () => ( "7d")),
|
|
@@ -1114,7 +949,7 @@ async function ignite(config) {
|
|
|
1114
949
|
}
|
|
1115
950
|
if (config.tasks) {
|
|
1116
951
|
if (config.tasks.backend === "bullmq") {
|
|
1117
|
-
await
|
|
952
|
+
await _chunkTBIVIR6Lcjs.initBullMQ.call(void 0, {
|
|
1118
953
|
redisUrl: _nullishCoalesce(config.tasks.redisUrl, () => ( "redis://localhost:6379")),
|
|
1119
954
|
concurrency: _nullishCoalesce(config.tasks.concurrency, () => ( 5)),
|
|
1120
955
|
enqueueTimeout: _nullishCoalesce(config.tasks.enqueueTimeout, () => ( 5e3)),
|
|
@@ -1127,7 +962,7 @@ async function ignite(config) {
|
|
|
1127
962
|
'[EFC] tasks.backend "pg-boss" needs tasks.connectionString or databaseUrl'
|
|
1128
963
|
);
|
|
1129
964
|
}
|
|
1130
|
-
await
|
|
965
|
+
await _chunk7BC3AN7Rcjs.initPgBoss.call(void 0, {
|
|
1131
966
|
connectionString,
|
|
1132
967
|
concurrency: _nullishCoalesce(config.tasks.concurrency, () => ( 5)),
|
|
1133
968
|
enqueueTimeout: _nullishCoalesce(config.tasks.enqueueTimeout, () => ( 5e3)),
|
|
@@ -1136,9 +971,9 @@ async function ignite(config) {
|
|
|
1136
971
|
});
|
|
1137
972
|
}
|
|
1138
973
|
}
|
|
1139
|
-
const routes =
|
|
974
|
+
const routes = _chunk4GHK27JAcjs.scanDir.call(void 0, apiDir);
|
|
1140
975
|
const apiRouter = _express2.default.Router();
|
|
1141
|
-
const mounted = await mountRoutes(apiRouter, routes);
|
|
976
|
+
const mounted = await _chunk74BSJXWDcjs.mountRoutes.call(void 0, apiRouter, routes);
|
|
1142
977
|
app.use(basePath, apiRouter);
|
|
1143
978
|
if (config.dashboard !== false && process.env["NODE_ENV"] === "development") {
|
|
1144
979
|
app.get("/", (_req, res) => {
|
|
@@ -1147,39 +982,13 @@ async function ignite(config) {
|
|
|
1147
982
|
res.send(generateDashboard(mounted, basePath, port, name, version));
|
|
1148
983
|
});
|
|
1149
984
|
}
|
|
1150
|
-
|
|
1151
|
-
app.use(onError);
|
|
1152
|
-
} else {
|
|
1153
|
-
app.use(
|
|
1154
|
-
(err, _req, res, _next) => {
|
|
1155
|
-
if (res.headersSent) {
|
|
1156
|
-
_chunkDUADUR6Rcjs.getLogger.call(void 0, ).warn({ err }, "Error after the response was sent");
|
|
1157
|
-
return;
|
|
1158
|
-
}
|
|
1159
|
-
const status = _optionalChain([err, 'optionalAccess', _20 => _20.statusCode]);
|
|
1160
|
-
const duckTyped = err instanceof Error && typeof status === "number" && status >= 400 && status < 500 ? err : null;
|
|
1161
|
-
if (_chunkNKLOE4AKcjs.isHttpError.call(void 0, err)) {
|
|
1162
|
-
const issues = err.issues;
|
|
1163
|
-
res.status(err.statusCode).json({
|
|
1164
|
-
error: err.message,
|
|
1165
|
-
statusCode: err.statusCode,
|
|
1166
|
-
...issues !== void 0 && { issues }
|
|
1167
|
-
});
|
|
1168
|
-
} else if (duckTyped) {
|
|
1169
|
-
res.status(duckTyped.statusCode).json({ error: duckTyped.message, statusCode: duckTyped.statusCode });
|
|
1170
|
-
} else {
|
|
1171
|
-
_chunkDUADUR6Rcjs.getLogger.call(void 0, ).error({ err }, "Unhandled error");
|
|
1172
|
-
res.status(500).json({ error: "Internal Server Error", statusCode: 500 });
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
);
|
|
1176
|
-
}
|
|
985
|
+
_chunk74BSJXWDcjs.mountErrorHandler.call(void 0, app, onError);
|
|
1177
986
|
return new Promise((resolve, reject) => {
|
|
1178
987
|
const server = app.listen(port);
|
|
1179
988
|
server.once("listening", () => {
|
|
1180
|
-
const wid = _nullishCoalesce(_optionalChain([_cluster2.default, 'access',
|
|
989
|
+
const wid = _nullishCoalesce(_optionalChain([_cluster2.default, 'access', _18 => _18.worker, 'optionalAccess', _19 => _19.id]), () => ( "primary"));
|
|
1181
990
|
const addr = server.address();
|
|
1182
|
-
|
|
991
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).info(`Worker ${wid} listening on :${_nullishCoalesce(_optionalChain([addr, 'optionalAccess', _20 => _20.port]), () => ( port))}`);
|
|
1183
992
|
resolve(server);
|
|
1184
993
|
});
|
|
1185
994
|
server.once("error", reject);
|
|
@@ -1190,21 +999,21 @@ function gracefulShutdown(server, timeoutMs = 1e4) {
|
|
|
1190
999
|
const shutdown = (signal) => {
|
|
1191
1000
|
if (shuttingDown) return;
|
|
1192
1001
|
shuttingDown = true;
|
|
1193
|
-
|
|
1002
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).info(`${signal} received \u2014 closing server gracefully\u2026`);
|
|
1194
1003
|
if (server) {
|
|
1195
1004
|
server.closeIdleConnections();
|
|
1196
1005
|
server.close(() => {
|
|
1197
|
-
|
|
1198
|
-
Promise.all([
|
|
1006
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).info("Server closed");
|
|
1007
|
+
Promise.all([_chunkTBIVIR6Lcjs.closeBullMQ.call(void 0, ), _chunk7BC3AN7Rcjs.closePgBoss.call(void 0, ), _chunkY4NKIXULcjs.closeCache.call(void 0, )]).catch((err) => _chunkJP36TLL4cjs.getLogger.call(void 0, ).error({ err }, "Task backend close failed")).finally(() => process.exit(0));
|
|
1199
1008
|
});
|
|
1200
1009
|
setTimeout(() => {
|
|
1201
|
-
|
|
1010
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).error("Forced exit after timeout");
|
|
1202
1011
|
process.exit(1);
|
|
1203
1012
|
}, timeoutMs).unref();
|
|
1204
1013
|
} else {
|
|
1205
1014
|
shutdownMaster();
|
|
1206
1015
|
setTimeout(() => {
|
|
1207
|
-
|
|
1016
|
+
_chunkJP36TLL4cjs.getLogger.call(void 0, ).error("Workers did not exit in time \u2014 forcing primary exit");
|
|
1208
1017
|
process.exit(1);
|
|
1209
1018
|
}, timeoutMs + 2e3).unref();
|
|
1210
1019
|
}
|
|
@@ -1234,5 +1043,7 @@ function gracefulShutdown(server, timeoutMs = 1e4) {
|
|
|
1234
1043
|
|
|
1235
1044
|
|
|
1236
1045
|
|
|
1237
|
-
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
exports.HttpError = _chunkAGOYTFROcjs.HttpError; exports.ModelValidationError = _chunkIUZ6A7PBcjs.ModelValidationError; exports.cache = _chunkY4NKIXULcjs.cache; exports.cacheResponse = cacheResponse; exports.compose = compose; exports.db = _chunkR2K7AFIBcjs.db; exports.defineCollection = _chunkR2K7AFIBcjs.defineCollection; exports.defineModel = _chunkR2K7AFIBcjs.defineModel; exports.defineTable = _chunkR2K7AFIBcjs.defineTable; exports.getDbClient = _chunkR2K7AFIBcjs.getDbClient; exports.getLogger = _chunkJP36TLL4cjs.getLogger; exports.getQueryMetrics = _chunkJP36TLL4cjs.getQueryMetrics; exports.gracefulShutdown = gracefulShutdown; exports.ignite = ignite; exports.isHttpError = _chunkAGOYTFROcjs.isHttpError; exports.listTasks = _chunkH2PVWCWCcjs.listTasks; exports.logger = _chunkJP36TLL4cjs.logger; exports.rateLimit = rateLimit; exports.resetQueryMetrics = _chunkJP36TLL4cjs.resetQueryMetrics; exports.scanDir = _chunk4GHK27JAcjs.scanDir; exports.setDbClient = _chunkR2K7AFIBcjs.setDbClient; exports.transaction = _chunkR2K7AFIBcjs.transaction; exports.workerCount = workerCount;
|
|
1238
1049
|
//# sourceMappingURL=index.cjs.map
|