express-file-cluster 0.9.6 → 0.10.0
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 +5 -5
- package/dist/auth/index.d.cts +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +4 -4
- package/dist/{chunk-QL6EWT4B.cjs → chunk-4DOHQU6I.cjs} +9 -7
- package/dist/chunk-4DOHQU6I.cjs.map +1 -0
- package/dist/{chunk-2SETEVMO.js → chunk-7KC2H76D.js} +42 -2
- package/dist/chunk-7KC2H76D.js.map +1 -0
- package/dist/{chunk-6KHBJOLB.cjs → chunk-7KO4DJRJ.cjs} +7 -7
- package/dist/{chunk-6KHBJOLB.cjs.map → chunk-7KO4DJRJ.cjs.map} +1 -1
- package/dist/{chunk-45BWAR6P.js → chunk-ATVD2HGC.js} +3 -3
- package/dist/{chunk-BBSZLGZW.js → chunk-EGSSZUVO.js} +8 -6
- package/dist/chunk-EGSSZUVO.js.map +1 -0
- package/dist/{chunk-TI24L4XE.cjs → chunk-GBI77W5T.cjs} +6 -2
- package/dist/chunk-GBI77W5T.cjs.map +1 -0
- package/dist/{chunk-VWSUQKCJ.cjs → chunk-HBCY7ILD.cjs} +274 -107
- package/dist/chunk-HBCY7ILD.cjs.map +1 -0
- package/dist/{chunk-RGT4ZVHL.cjs → chunk-KFVFP2Q7.cjs} +45 -5
- package/dist/chunk-KFVFP2Q7.cjs.map +1 -0
- package/dist/{chunk-TYCYYLLM.cjs → chunk-NKLOE4AK.cjs} +1 -1
- package/dist/chunk-NKLOE4AK.cjs.map +1 -0
- package/dist/{chunk-OFA7OGN5.js → chunk-PGJQK36V.js} +171 -4
- package/dist/chunk-PGJQK36V.js.map +1 -0
- package/dist/{chunk-ULWNHN6P.js → chunk-QDEDOHP7.js} +1 -1
- package/dist/chunk-QDEDOHP7.js.map +1 -0
- package/dist/{chunk-7ZESZG3J.js → chunk-R4XO4SVM.js} +3 -3
- package/dist/chunk-R52CUEGT.js +74 -0
- package/dist/chunk-R52CUEGT.js.map +1 -0
- package/dist/{chunk-HBYSKULC.js → chunk-RAB44UGX.js} +5 -1
- package/dist/chunk-RAB44UGX.js.map +1 -0
- package/dist/{chunk-7YEX4MQV.cjs → chunk-WBLUGOAG.cjs} +42 -6
- package/dist/chunk-WBLUGOAG.cjs.map +1 -0
- package/dist/{chunk-FMA76PRH.cjs → chunk-YK4ZM3CA.cjs} +8 -8
- package/dist/{chunk-FMA76PRH.cjs.map → chunk-YK4ZM3CA.cjs.map} +1 -1
- package/dist/cli/db-runner.cjs +2010 -116
- package/dist/cli/db-runner.cjs.map +1 -1
- package/dist/cli/db-runner.js +1987 -93
- package/dist/cli/db-runner.js.map +1 -1
- package/dist/cli/index.cjs +36 -13
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +33 -10
- package/dist/cli/index.js.map +1 -1
- package/dist/docs/api-reference/collection.md +44 -1
- package/dist/docs/api-reference/ignite.md +9 -0
- package/dist/docs/api-reference/types.md +99 -0
- package/dist/docs/cli/add.md +1 -1
- package/dist/docs/cli/db.md +2 -2
- package/dist/docs/core-concepts/background-tasks.md +6 -3
- package/dist/docs/getting-started/index.md +2 -1
- package/dist/docs/guides/caching.md +32 -1
- package/dist/docs/guides/database.md +2 -0
- package/dist/docs/guides/feature-matrix.md +58 -0
- package/dist/docs/guides/migrations.md +23 -2
- package/dist/docs/guides/which-api.md +2 -2
- package/dist/docs/index.md +3 -1
- package/dist/docs/skills/SKILL.md +1 -1
- package/dist/docs/skills/api-surface.md +5 -0
- package/dist/docs/skills/tasks-internals.md +4 -3
- package/dist/docs/skills/what-not-to-invent.md +4 -3
- package/dist/index.cjs +99 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +204 -3
- package/dist/index.d.ts +204 -3
- package/dist/index.js +76 -7
- package/dist/index.js.map +1 -1
- package/dist/pgboss-backend-FW42SBSM.js +14 -0
- package/dist/pgboss-backend-RVHUBJTU.cjs +14 -0
- package/dist/{pgboss-backend-DSO3QTNK.cjs.map → pgboss-backend-RVHUBJTU.cjs.map} +1 -1
- package/dist/registry/index.json +13 -1
- package/dist/registry/js-mongo/auth.json +1 -1
- package/dist/registry/js-mongo/forgot-password.json +1 -1
- package/dist/registry/js-mongo-collection/_base.json +1 -0
- package/dist/registry/js-mongo-collection/account-security.json +1 -0
- package/dist/registry/js-mongo-collection/account-settings.json +1 -0
- package/dist/registry/js-mongo-collection/admin-admins.json +1 -0
- package/dist/registry/js-mongo-collection/admin-analytics.json +1 -0
- package/dist/registry/js-mongo-collection/admin-billing.json +1 -0
- package/dist/registry/js-mongo-collection/admin-content.json +1 -0
- package/dist/registry/js-mongo-collection/admin-logs.json +1 -0
- package/dist/registry/js-mongo-collection/admin-support.json +1 -0
- package/dist/registry/js-mongo-collection/admin-system.json +1 -0
- package/dist/registry/js-mongo-collection/admin-users.json +1 -0
- package/dist/registry/js-mongo-collection/admin.json +1 -0
- package/dist/registry/js-mongo-collection/auth.json +1 -0
- package/dist/registry/js-mongo-collection/auth@apple.json +1 -0
- package/dist/registry/js-mongo-collection/auth@google.json +1 -0
- package/dist/registry/js-mongo-collection/billing.json +1 -0
- package/dist/registry/js-mongo-collection/email-client.json +1 -0
- package/dist/registry/js-mongo-collection/email-verification.json +1 -0
- package/dist/registry/js-mongo-collection/files.json +1 -0
- package/dist/registry/js-mongo-collection/forgot-password.json +1 -0
- package/dist/registry/js-mongo-collection/notifications.json +1 -0
- package/dist/registry/js-mongo-collection/support.json +1 -0
- package/dist/registry/js-mongo-collection/user-profile.json +1 -0
- package/dist/registry/js-pg-model/auth.json +1 -1
- package/dist/registry/js-pg-model/forgot-password.json +1 -1
- package/dist/registry/js-pg-table/auth.json +1 -1
- package/dist/registry/js-pg-table/forgot-password.json +1 -1
- package/dist/registry/ts-mongo/auth.json +1 -1
- package/dist/registry/ts-mongo/forgot-password.json +1 -1
- package/dist/registry/ts-mongo-collection/_base.json +1 -0
- package/dist/registry/ts-mongo-collection/account-security.json +1 -0
- package/dist/registry/ts-mongo-collection/account-settings.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-admins.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-analytics.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-billing.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-content.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-logs.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-support.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-system.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-users.json +1 -0
- package/dist/registry/ts-mongo-collection/admin.json +1 -0
- package/dist/registry/ts-mongo-collection/auth.json +1 -0
- package/dist/registry/ts-mongo-collection/auth@apple.json +1 -0
- package/dist/registry/ts-mongo-collection/auth@google.json +1 -0
- package/dist/registry/ts-mongo-collection/billing.json +1 -0
- package/dist/registry/ts-mongo-collection/email-client.json +1 -0
- package/dist/registry/ts-mongo-collection/email-verification.json +1 -0
- package/dist/registry/ts-mongo-collection/files.json +1 -0
- package/dist/registry/ts-mongo-collection/forgot-password.json +1 -0
- package/dist/registry/ts-mongo-collection/notifications.json +1 -0
- package/dist/registry/ts-mongo-collection/support.json +1 -0
- package/dist/registry/ts-mongo-collection/user-profile.json +1 -0
- package/dist/registry/ts-pg-model/auth.json +1 -1
- package/dist/registry/ts-pg-model/forgot-password.json +1 -1
- package/dist/registry/ts-pg-table/auth.json +1 -1
- package/dist/registry/ts-pg-table/forgot-password.json +1 -1
- package/dist/tasks/index.cjs +4 -2
- package/dist/tasks/index.cjs.map +1 -1
- package/dist/tasks/index.d.cts +4 -2
- package/dist/tasks/index.d.ts +4 -2
- package/dist/tasks/index.js +3 -1
- package/dist/thread-runner.cjs +8 -0
- package/dist/thread-runner.cjs.map +1 -0
- package/dist/thread-runner.d.cts +3 -0
- package/dist/thread-runner.d.ts +3 -0
- package/dist/thread-runner.js +8 -0
- package/dist/thread-runner.js.map +1 -0
- package/dist/{types-DAsBKVM-.d.cts → types-Bnxvj3l0.d.cts} +7 -1
- package/dist/{types-DAsBKVM-.d.ts → types-Bnxvj3l0.d.ts} +7 -1
- package/package.json +1 -1
- package/dist/chunk-2SETEVMO.js.map +0 -1
- package/dist/chunk-7YEX4MQV.cjs.map +0 -1
- package/dist/chunk-BBSZLGZW.js.map +0 -1
- package/dist/chunk-HBYSKULC.js.map +0 -1
- package/dist/chunk-LJNSJFOL.js +0 -38
- package/dist/chunk-LJNSJFOL.js.map +0 -1
- package/dist/chunk-OFA7OGN5.js.map +0 -1
- package/dist/chunk-QL6EWT4B.cjs.map +0 -1
- package/dist/chunk-RGT4ZVHL.cjs.map +0 -1
- package/dist/chunk-TI24L4XE.cjs.map +0 -1
- package/dist/chunk-TYCYYLLM.cjs.map +0 -1
- package/dist/chunk-ULWNHN6P.js.map +0 -1
- package/dist/chunk-VWSUQKCJ.cjs.map +0 -1
- package/dist/pgboss-backend-DSO3QTNK.cjs +0 -14
- package/dist/pgboss-backend-I6DFUNRM.js +0 -14
- /package/dist/{chunk-45BWAR6P.js.map → chunk-ATVD2HGC.js.map} +0 -0
- /package/dist/{chunk-7ZESZG3J.js.map → chunk-R4XO4SVM.js.map} +0 -0
- /package/dist/{pgboss-backend-I6DFUNRM.js.map → pgboss-backend-FW42SBSM.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkKFVFP2Q7cjs = require('./chunk-KFVFP2Q7.cjs');
|
|
8
10
|
|
|
9
11
|
|
|
10
12
|
var _chunkDCJOWFVDcjs = require('./chunk-DCJOWFVD.cjs');
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var _chunkYK4ZM3CAcjs = require('./chunk-YK4ZM3CA.cjs');
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
|
|
@@ -21,23 +23,23 @@ var _chunkFMA76PRHcjs = require('./chunk-FMA76PRH.cjs');
|
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
|
|
24
|
-
var
|
|
26
|
+
var _chunkHBCY7ILDcjs = require('./chunk-HBCY7ILD.cjs');
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
|
|
30
32
|
|
|
31
|
-
var
|
|
33
|
+
var _chunkNKLOE4AKcjs = require('./chunk-NKLOE4AK.cjs');
|
|
32
34
|
|
|
33
35
|
|
|
34
36
|
|
|
35
|
-
var
|
|
36
|
-
require('./chunk-
|
|
37
|
+
var _chunk7KO4DJRJcjs = require('./chunk-7KO4DJRJ.cjs');
|
|
38
|
+
require('./chunk-WBLUGOAG.cjs');
|
|
37
39
|
|
|
38
40
|
|
|
39
41
|
|
|
40
|
-
var
|
|
42
|
+
var _chunkGBI77W5Tcjs = require('./chunk-GBI77W5T.cjs');
|
|
41
43
|
|
|
42
44
|
|
|
43
45
|
|
|
@@ -247,7 +249,7 @@ async function scanTasks(tasksDir) {
|
|
|
247
249
|
_chunkDUADUR6Rcjs.getLogger.call(void 0, ).warn(`Task file ${file} has no valid default export \u2014 skipping`);
|
|
248
250
|
continue;
|
|
249
251
|
}
|
|
250
|
-
|
|
252
|
+
_chunkGBI77W5Tcjs.registerTask.call(void 0, taskName, { ...def, filePath });
|
|
251
253
|
_chunkDUADUR6Rcjs.getLogger.call(void 0, ).debug(`Registered task: ${taskName}`);
|
|
252
254
|
} catch (err) {
|
|
253
255
|
_chunkDUADUR6Rcjs.getLogger.call(void 0, ).warn({ err }, `Failed to load task ${file}`);
|
|
@@ -853,6 +855,71 @@ function generateDashboard(routes, basePath, port, projectName, projectVersion)
|
|
|
853
855
|
</html>`;
|
|
854
856
|
}
|
|
855
857
|
|
|
858
|
+
// src/rate-limit.ts
|
|
859
|
+
var UNITS = { s: 1, m: 60, h: 3600, d: 86400 };
|
|
860
|
+
function parseWindow(window) {
|
|
861
|
+
if (typeof window === "number") {
|
|
862
|
+
if (window > 0) return window;
|
|
863
|
+
} else {
|
|
864
|
+
const m = /^(\d+(?:\.\d+)?)\s*(s|m|h|d)$/.exec(window.trim());
|
|
865
|
+
if (m) return Number(m[1]) * UNITS[m[2]];
|
|
866
|
+
}
|
|
867
|
+
throw new Error(`[EFC] rateLimit: window must be seconds or like '15m' \u2014 got ${String(window)}`);
|
|
868
|
+
}
|
|
869
|
+
var lastCacheError = 0;
|
|
870
|
+
function rateLimit(options) {
|
|
871
|
+
const windowSeconds = parseWindow(options.window);
|
|
872
|
+
if (!Number.isInteger(options.max) || options.max < 1) {
|
|
873
|
+
throw new Error("[EFC] rateLimit: max must be a positive integer");
|
|
874
|
+
}
|
|
875
|
+
const keyOf = _nullishCoalesce(options.key, () => ( ((req) => _nullishCoalesce(req.ip, () => ( req.socket.remoteAddress)))));
|
|
876
|
+
const message = _nullishCoalesce(options.message, () => ( "Too many requests, try again later"));
|
|
877
|
+
const headers = _nullishCoalesce(options.headers, () => ( true));
|
|
878
|
+
return (req, res, next) => {
|
|
879
|
+
void (async () => {
|
|
880
|
+
const who = keyOf(req);
|
|
881
|
+
if (who === void 0) return next();
|
|
882
|
+
if (!_chunkKFVFP2Q7cjs.isCacheConfigured.call(void 0, )) {
|
|
883
|
+
throw new Error("[EFC] rateLimit needs a cache \u2014 pass cache: { backend } to ignite()");
|
|
884
|
+
}
|
|
885
|
+
const bucket = _nullishCoalesce(options.name, () => ( req.baseUrl + (_nullishCoalesce(_optionalChain([req, 'access', _10 => _10.route, 'optionalAccess', _11 => _11.path]), () => ( req.path)))));
|
|
886
|
+
const windowMs = windowSeconds * 1e3;
|
|
887
|
+
const now = Date.now();
|
|
888
|
+
const slot = Math.floor(now / windowMs);
|
|
889
|
+
const resetMs = (slot + 1) * windowMs - now;
|
|
890
|
+
let count;
|
|
891
|
+
try {
|
|
892
|
+
count = (await _chunkKFVFP2Q7cjs.rawIncr.call(void 0, `rl:${bucket}:${who}:${slot}`, Math.ceil(resetMs / 1e3) + 1)).value;
|
|
893
|
+
} catch (err) {
|
|
894
|
+
if (Date.now() - lastCacheError > 3e4) {
|
|
895
|
+
lastCacheError = Date.now();
|
|
896
|
+
_chunkDUADUR6Rcjs.getLogger.call(void 0, ).error(
|
|
897
|
+
{ err },
|
|
898
|
+
`rateLimit: cache unavailable \u2014 ${options.onCacheError === "reject" ? "rejecting with 503" : "allowing requests"}`
|
|
899
|
+
);
|
|
900
|
+
}
|
|
901
|
+
if (options.onCacheError === "reject") {
|
|
902
|
+
res.status(503).json({ error: "Service Unavailable", statusCode: 503 });
|
|
903
|
+
return;
|
|
904
|
+
}
|
|
905
|
+
return next();
|
|
906
|
+
}
|
|
907
|
+
const resetSeconds = Math.max(1, Math.ceil(resetMs / 1e3));
|
|
908
|
+
if (headers) {
|
|
909
|
+
res.setHeader("RateLimit-Limit", String(options.max));
|
|
910
|
+
res.setHeader("RateLimit-Remaining", String(Math.max(0, options.max - count)));
|
|
911
|
+
res.setHeader("RateLimit-Reset", String(resetSeconds));
|
|
912
|
+
}
|
|
913
|
+
if (count > options.max) {
|
|
914
|
+
if (headers) res.setHeader("Retry-After", String(resetSeconds));
|
|
915
|
+
res.status(429).json({ error: message, statusCode: 429 });
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
next();
|
|
919
|
+
})().catch(next);
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
|
|
856
923
|
// src/cache/response.ts
|
|
857
924
|
var RESPONSE_PREFIX = "res:";
|
|
858
925
|
function cacheResponse(options) {
|
|
@@ -862,13 +929,13 @@ function cacheResponse(options) {
|
|
|
862
929
|
let scope = "";
|
|
863
930
|
if (opts.perUser) {
|
|
864
931
|
const user = _chunkDUADUR6Rcjs.getCurrentUser.call(void 0, );
|
|
865
|
-
const id = _nullishCoalesce(_optionalChain([user, 'optionalAccess',
|
|
932
|
+
const id = _nullishCoalesce(_optionalChain([user, 'optionalAccess', _12 => _12["sub"]]), () => ( _optionalChain([user, 'optionalAccess', _13 => _13["id"]])));
|
|
866
933
|
if (id === void 0) return next();
|
|
867
934
|
scope = `u:${String(id)}:`;
|
|
868
935
|
}
|
|
869
936
|
const key = RESPONSE_PREFIX + scope + (opts.key ? opts.key(req) : req.originalUrl);
|
|
870
937
|
void (async () => {
|
|
871
|
-
const hit = await
|
|
938
|
+
const hit = await _chunkKFVFP2Q7cjs.cache.get(key);
|
|
872
939
|
if (hit) {
|
|
873
940
|
res.setHeader("X-Cache", "HIT");
|
|
874
941
|
res.status(hit.status).json(hit.body);
|
|
@@ -877,7 +944,7 @@ function cacheResponse(options) {
|
|
|
877
944
|
res.setHeader("X-Cache", "MISS");
|
|
878
945
|
const json = res.json.bind(res);
|
|
879
946
|
res.json = (body) => {
|
|
880
|
-
if (res.statusCode === 200) void
|
|
947
|
+
if (res.statusCode === 200) void _chunkKFVFP2Q7cjs.cache.set(key, { status: 200, body }, { ttl: opts.ttl });
|
|
881
948
|
return json(body);
|
|
882
949
|
};
|
|
883
950
|
next();
|
|
@@ -965,7 +1032,7 @@ async function ignite(config) {
|
|
|
965
1032
|
_chunkDUADUR6Rcjs.configureQueryLog.call(void 0, config.logging);
|
|
966
1033
|
if (clusterEnabled && _cluster2.default.isPrimary) {
|
|
967
1034
|
if (config.cache && config.cache.backend === "memory") {
|
|
968
|
-
|
|
1035
|
+
_chunkKFVFP2Q7cjs.servePrimaryCache.call(void 0, _nullishCoalesce(config.cache.maxEntries, () => ( 1e4)));
|
|
969
1036
|
}
|
|
970
1037
|
runMaster({
|
|
971
1038
|
workers: _nullishCoalesce(workers, () => ( _os2.default.cpus().length)),
|
|
@@ -975,6 +1042,7 @@ async function ignite(config) {
|
|
|
975
1042
|
return;
|
|
976
1043
|
}
|
|
977
1044
|
const app = _express2.default.call(void 0, );
|
|
1045
|
+
if (config.trustProxy !== void 0) app.set("trust proxy", config.trustProxy);
|
|
978
1046
|
app.set(
|
|
979
1047
|
"json replacer",
|
|
980
1048
|
(_key, value) => typeof value === "bigint" ? value.toString() : value
|
|
@@ -1007,34 +1075,34 @@ async function ignite(config) {
|
|
|
1007
1075
|
for (const mw of globalMiddlewares) {
|
|
1008
1076
|
app.use(mw);
|
|
1009
1077
|
}
|
|
1010
|
-
if (database)
|
|
1011
|
-
|
|
1078
|
+
if (database) _chunkNKLOE4AKcjs.setDbEngine.call(void 0, database);
|
|
1079
|
+
_chunkNKLOE4AKcjs.setAutoSync.call(void 0, _nullishCoalesce(config.autoSync, () => ( true)));
|
|
1012
1080
|
const poolWorkers = clusterEnabled ? _nullishCoalesce(workers, () => ( _os2.default.cpus().length)) : 1;
|
|
1013
|
-
const reportsPools = !clusterEnabled || _optionalChain([_cluster2.default, 'access',
|
|
1081
|
+
const reportsPools = !clusterEnabled || _optionalChain([_cluster2.default, 'access', _14 => _14.worker, 'optionalAccess', _15 => _15.id]) === 1;
|
|
1014
1082
|
if (database === "mongodb" && databaseUrl) {
|
|
1015
|
-
const conn = await
|
|
1016
|
-
|
|
1083
|
+
const conn = await _chunkHBCY7ILDcjs.connectMongo.call(void 0, databaseUrl, config.databasePool);
|
|
1084
|
+
_chunkHBCY7ILDcjs.setDbClient.call(void 0, conn);
|
|
1017
1085
|
if (reportsPools) {
|
|
1018
|
-
const max = _nullishCoalesce(_optionalChain([config, 'access',
|
|
1086
|
+
const max = _nullishCoalesce(_optionalChain([config, 'access', _16 => _16.databasePool, 'optionalAccess', _17 => _17.max]), () => ( 100));
|
|
1019
1087
|
_chunkDUADUR6Rcjs.getLogger.call(void 0, ).info(
|
|
1020
1088
|
`MongoDB connections: up to ${poolWorkers * max} from this machine (${poolWorkers} worker(s) \xD7 maxPoolSize ${max})`
|
|
1021
1089
|
);
|
|
1022
1090
|
}
|
|
1023
1091
|
} else if (database === "postgresql" && databaseUrl) {
|
|
1024
1092
|
const pool = await _chunkDUADUR6Rcjs.connectPostgres.call(void 0, databaseUrl, config.databasePool);
|
|
1025
|
-
|
|
1093
|
+
_chunkHBCY7ILDcjs.setDbClient.call(void 0, pool);
|
|
1026
1094
|
if (reportsPools) {
|
|
1027
|
-
const max = _nullishCoalesce(_optionalChain([config, 'access',
|
|
1095
|
+
const max = _nullishCoalesce(_optionalChain([config, 'access', _18 => _18.databasePool, 'optionalAccess', _19 => _19.max]), () => ( 10));
|
|
1028
1096
|
const boss = config.tasks && config.tasks.backend === "pg-boss" && !config.tasks.connectionString ? 10 : 0;
|
|
1029
1097
|
const breakdown = `${poolWorkers} worker(s) \xD7 (pool ${max}${boss ? ` + pg-boss ${boss}` : ""})`;
|
|
1030
1098
|
await _chunkDUADUR6Rcjs.checkConnectionBudget.call(void 0, poolWorkers * (max + boss), breakdown);
|
|
1031
1099
|
}
|
|
1032
1100
|
}
|
|
1033
1101
|
if (config.cache) {
|
|
1034
|
-
await
|
|
1102
|
+
await _chunkKFVFP2Q7cjs.configureCache.call(void 0, config.cache);
|
|
1035
1103
|
}
|
|
1036
1104
|
if (jwtSecret) {
|
|
1037
|
-
|
|
1105
|
+
_chunkKFVFP2Q7cjs.configureAuth.call(void 0, {
|
|
1038
1106
|
secret: jwtSecret,
|
|
1039
1107
|
strategy: authStrategy,
|
|
1040
1108
|
expiresIn: _nullishCoalesce(config.jwtExpiresIn, () => ( "7d")),
|
|
@@ -1046,7 +1114,7 @@ async function ignite(config) {
|
|
|
1046
1114
|
}
|
|
1047
1115
|
if (config.tasks) {
|
|
1048
1116
|
if (config.tasks.backend === "bullmq") {
|
|
1049
|
-
await
|
|
1117
|
+
await _chunkYK4ZM3CAcjs.initBullMQ.call(void 0, {
|
|
1050
1118
|
redisUrl: _nullishCoalesce(config.tasks.redisUrl, () => ( "redis://localhost:6379")),
|
|
1051
1119
|
concurrency: _nullishCoalesce(config.tasks.concurrency, () => ( 5)),
|
|
1052
1120
|
enqueueTimeout: _nullishCoalesce(config.tasks.enqueueTimeout, () => ( 5e3)),
|
|
@@ -1059,7 +1127,7 @@ async function ignite(config) {
|
|
|
1059
1127
|
'[EFC] tasks.backend "pg-boss" needs tasks.connectionString or databaseUrl'
|
|
1060
1128
|
);
|
|
1061
1129
|
}
|
|
1062
|
-
await
|
|
1130
|
+
await _chunk7KO4DJRJcjs.initPgBoss.call(void 0, {
|
|
1063
1131
|
connectionString,
|
|
1064
1132
|
concurrency: _nullishCoalesce(config.tasks.concurrency, () => ( 5)),
|
|
1065
1133
|
enqueueTimeout: _nullishCoalesce(config.tasks.enqueueTimeout, () => ( 5e3)),
|
|
@@ -1088,9 +1156,9 @@ async function ignite(config) {
|
|
|
1088
1156
|
_chunkDUADUR6Rcjs.getLogger.call(void 0, ).warn({ err }, "Error after the response was sent");
|
|
1089
1157
|
return;
|
|
1090
1158
|
}
|
|
1091
|
-
const status = _optionalChain([err, 'optionalAccess',
|
|
1159
|
+
const status = _optionalChain([err, 'optionalAccess', _20 => _20.statusCode]);
|
|
1092
1160
|
const duckTyped = err instanceof Error && typeof status === "number" && status >= 400 && status < 500 ? err : null;
|
|
1093
|
-
if (
|
|
1161
|
+
if (_chunkNKLOE4AKcjs.isHttpError.call(void 0, err)) {
|
|
1094
1162
|
const issues = err.issues;
|
|
1095
1163
|
res.status(err.statusCode).json({
|
|
1096
1164
|
error: err.message,
|
|
@@ -1109,9 +1177,9 @@ async function ignite(config) {
|
|
|
1109
1177
|
return new Promise((resolve, reject) => {
|
|
1110
1178
|
const server = app.listen(port);
|
|
1111
1179
|
server.once("listening", () => {
|
|
1112
|
-
const wid = _nullishCoalesce(_optionalChain([_cluster2.default, 'access',
|
|
1180
|
+
const wid = _nullishCoalesce(_optionalChain([_cluster2.default, 'access', _21 => _21.worker, 'optionalAccess', _22 => _22.id]), () => ( "primary"));
|
|
1113
1181
|
const addr = server.address();
|
|
1114
|
-
_chunkDUADUR6Rcjs.getLogger.call(void 0, ).info(`Worker ${wid} listening on :${_nullishCoalesce(_optionalChain([addr, 'optionalAccess',
|
|
1182
|
+
_chunkDUADUR6Rcjs.getLogger.call(void 0, ).info(`Worker ${wid} listening on :${_nullishCoalesce(_optionalChain([addr, 'optionalAccess', _23 => _23.port]), () => ( port))}`);
|
|
1115
1183
|
resolve(server);
|
|
1116
1184
|
});
|
|
1117
1185
|
server.once("error", reject);
|
|
@@ -1127,7 +1195,7 @@ function gracefulShutdown(server, timeoutMs = 1e4) {
|
|
|
1127
1195
|
server.closeIdleConnections();
|
|
1128
1196
|
server.close(() => {
|
|
1129
1197
|
_chunkDUADUR6Rcjs.getLogger.call(void 0, ).info("Server closed");
|
|
1130
|
-
Promise.all([
|
|
1198
|
+
Promise.all([_chunkYK4ZM3CAcjs.closeBullMQ.call(void 0, ), _chunk7KO4DJRJcjs.closePgBoss.call(void 0, ), _chunkKFVFP2Q7cjs.closeCache.call(void 0, )]).catch((err) => _chunkDUADUR6Rcjs.getLogger.call(void 0, ).error({ err }, "Task backend close failed")).finally(() => process.exit(0));
|
|
1131
1199
|
});
|
|
1132
1200
|
setTimeout(() => {
|
|
1133
1201
|
_chunkDUADUR6Rcjs.getLogger.call(void 0, ).error("Forced exit after timeout");
|
|
@@ -1165,5 +1233,6 @@ function gracefulShutdown(server, timeoutMs = 1e4) {
|
|
|
1165
1233
|
|
|
1166
1234
|
|
|
1167
1235
|
|
|
1168
|
-
|
|
1236
|
+
|
|
1237
|
+
exports.HttpError = _chunkNKLOE4AKcjs.HttpError; exports.ModelValidationError = _chunkNKLOE4AKcjs.ModelValidationError; exports.cache = _chunkKFVFP2Q7cjs.cache; exports.cacheResponse = cacheResponse; exports.compose = compose; exports.db = _chunkHBCY7ILDcjs.db; exports.defineCollection = _chunkHBCY7ILDcjs.defineCollection; exports.defineModel = _chunkHBCY7ILDcjs.defineModel; exports.defineTable = _chunkHBCY7ILDcjs.defineTable; exports.getDbClient = _chunkHBCY7ILDcjs.getDbClient; exports.getLogger = _chunkDUADUR6Rcjs.getLogger; exports.gracefulShutdown = gracefulShutdown; exports.ignite = ignite; exports.isHttpError = _chunkNKLOE4AKcjs.isHttpError; exports.listTasks = _chunkGBI77W5Tcjs.listTasks; exports.logger = _chunkDUADUR6Rcjs.logger; exports.rateLimit = rateLimit; exports.scanDir = _chunkDCJOWFVDcjs.scanDir; exports.setDbClient = _chunkHBCY7ILDcjs.setDbClient; exports.transaction = _chunkHBCY7ILDcjs.transaction; exports.workerCount = workerCount;
|
|
1169
1238
|
//# sourceMappingURL=index.cjs.map
|