express-file-cluster 0.10.0 → 0.11.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.
Files changed (194) hide show
  1. package/dist/auth/index.cjs +7 -6
  2. package/dist/auth/index.cjs.map +1 -1
  3. package/dist/auth/index.d.cts +3 -1
  4. package/dist/auth/index.d.ts +3 -1
  5. package/dist/auth/index.js +5 -5
  6. package/dist/{chunk-73XJUT2S.js → chunk-2IDRC7RK.js} +163 -5
  7. package/dist/chunk-2IDRC7RK.js.map +1 -0
  8. package/dist/{chunk-QDEDOHP7.js → chunk-336IU55W.js} +9 -42
  9. package/dist/chunk-336IU55W.js.map +1 -0
  10. package/dist/{chunk-R52CUEGT.js → chunk-3SWI46YK.js} +2 -2
  11. package/dist/{chunk-7KO4DJRJ.cjs → chunk-6WTMRZS7.cjs} +14 -14
  12. package/dist/{chunk-7KO4DJRJ.cjs.map → chunk-6WTMRZS7.cjs.map} +1 -1
  13. package/dist/chunk-AGOYTFRO.cjs +42 -0
  14. package/dist/chunk-AGOYTFRO.cjs.map +1 -0
  15. package/dist/{chunk-RAB44UGX.js → chunk-B6MB6HEG.js} +1 -1
  16. package/dist/chunk-CGY7JU4Y.cjs +8 -0
  17. package/dist/chunk-CGY7JU4Y.cjs.map +1 -0
  18. package/dist/chunk-DGYPIIJE.cjs +845 -0
  19. package/dist/chunk-DGYPIIJE.cjs.map +1 -0
  20. package/dist/{chunk-EGSSZUVO.js → chunk-DN4TCGYB.js} +38 -11
  21. package/dist/chunk-DN4TCGYB.js.map +1 -0
  22. package/dist/{chunk-YK4ZM3CA.cjs → chunk-DTMDJGRW.cjs} +15 -15
  23. package/dist/{chunk-YK4ZM3CA.cjs.map → chunk-DTMDJGRW.cjs.map} +1 -1
  24. package/dist/{chunk-R4XO4SVM.js → chunk-EJDZZ4KX.js} +4 -4
  25. package/dist/{chunk-NKLOE4AK.cjs → chunk-GWMW6XY7.cjs} +20 -53
  26. package/dist/chunk-GWMW6XY7.cjs.map +1 -0
  27. package/dist/{chunk-GBI77W5T.cjs → chunk-H2PVWCWC.cjs} +1 -1
  28. package/dist/{chunk-GBI77W5T.cjs.map → chunk-H2PVWCWC.cjs.map} +1 -1
  29. package/dist/{chunk-KFVFP2Q7.cjs → chunk-IEF6AEK3.cjs} +70 -55
  30. package/dist/chunk-IEF6AEK3.cjs.map +1 -0
  31. package/dist/{chunk-PGJQK36V.js → chunk-JBOMTZT5.js} +7 -5
  32. package/dist/{chunk-PGJQK36V.js.map → chunk-JBOMTZT5.js.map} +1 -1
  33. package/dist/chunk-LECHRAU3.js +845 -0
  34. package/dist/chunk-LECHRAU3.js.map +1 -0
  35. package/dist/{chunk-4DOHQU6I.cjs → chunk-M53GODCX.cjs} +39 -12
  36. package/dist/chunk-M53GODCX.cjs.map +1 -0
  37. package/dist/{chunk-NI2BNGGV.js → chunk-O2E7H2XA.js} +2 -2
  38. package/dist/{chunk-ATVD2HGC.js → chunk-OM2XJJWX.js} +4 -4
  39. package/dist/{chunk-DUADUR6R.cjs → chunk-QSIP7YLW.cjs} +172 -14
  40. package/dist/chunk-QSIP7YLW.cjs.map +1 -0
  41. package/dist/{chunk-7KC2H76D.js → chunk-R6GPQZLI.js} +62 -47
  42. package/dist/chunk-R6GPQZLI.js.map +1 -0
  43. package/dist/{chunk-WBLUGOAG.cjs → chunk-RPL2IFWK.cjs} +8 -5
  44. package/dist/chunk-RPL2IFWK.cjs.map +1 -0
  45. package/dist/{chunk-HBCY7ILD.cjs → chunk-SOU3PBJC.cjs} +97 -95
  46. package/dist/chunk-SOU3PBJC.cjs.map +1 -0
  47. package/dist/{chunk-DCJOWFVD.cjs → chunk-WHBSVYUY.cjs} +3 -3
  48. package/dist/{chunk-DCJOWFVD.cjs.map → chunk-WHBSVYUY.cjs.map} +1 -1
  49. package/dist/chunk-XPY5TQDK.js +42 -0
  50. package/dist/chunk-XPY5TQDK.js.map +1 -0
  51. package/dist/cli/db-runner.cjs +81 -42
  52. package/dist/cli/db-runner.cjs.map +1 -1
  53. package/dist/cli/db-runner.js +54 -16
  54. package/dist/cli/db-runner.js.map +1 -1
  55. package/dist/cli/index.cjs +23 -25
  56. package/dist/cli/index.cjs.map +1 -1
  57. package/dist/cli/index.js +12 -17
  58. package/dist/cli/index.js.map +1 -1
  59. package/dist/docs/api-reference/auth.md +23 -0
  60. package/dist/docs/api-reference/compose.md +1 -1
  61. package/dist/docs/api-reference/db.md +8 -0
  62. package/dist/docs/api-reference/ignite.md +8 -1
  63. package/dist/docs/api-reference/openapi.md +36 -0
  64. package/dist/docs/api-reference/testing.md +28 -0
  65. package/dist/docs/api-reference/websockets.md +23 -0
  66. package/dist/docs/cli/add.md +2 -2
  67. package/dist/docs/core-concepts/clustering.md +2 -0
  68. package/dist/docs/core-concepts/file-based-routing.md +4 -0
  69. package/dist/docs/core-concepts/middleware.md +2 -2
  70. package/dist/docs/getting-started/index.md +4 -0
  71. package/dist/docs/guides/authentication.md +33 -0
  72. package/dist/docs/guides/caching.md +2 -0
  73. package/dist/docs/guides/database.md +15 -0
  74. package/dist/docs/guides/environment-variables.md +6 -0
  75. package/dist/docs/guides/feature-matrix.md +9 -0
  76. package/dist/docs/guides/generated-portals.md +3 -1
  77. package/dist/docs/guides/logging.md +17 -0
  78. package/dist/docs/guides/migrations.md +4 -2
  79. package/dist/docs/guides/openapi.md +57 -0
  80. package/dist/docs/guides/testing.md +31 -0
  81. package/dist/docs/guides/validation.md +2 -0
  82. package/dist/docs/guides/websockets.md +60 -0
  83. package/dist/docs/index.md +4 -1
  84. package/dist/docs/skills/SKILL.md +8 -2
  85. package/dist/docs/skills/api-surface.md +30 -4
  86. package/dist/docs/skills/auth-internals.md +14 -1
  87. package/dist/docs/skills/pre-flight.md +8 -0
  88. package/dist/docs/skills/routing-rules.md +5 -1
  89. package/dist/docs/skills/what-not-to-invent.md +11 -1
  90. package/dist/docs/versioning.md +1 -1
  91. package/dist/index.cjs +100 -267
  92. package/dist/index.cjs.map +1 -1
  93. package/dist/index.d.cts +28 -3
  94. package/dist/index.d.ts +28 -3
  95. package/dist/index.js +52 -221
  96. package/dist/index.js.map +1 -1
  97. package/dist/openapi-cjs.cjs +5 -0
  98. package/dist/pgboss-backend-PQW6I3VF.js +14 -0
  99. package/dist/pgboss-backend-QVXISTLP.cjs +15 -0
  100. package/dist/pgboss-backend-QVXISTLP.cjs.map +1 -0
  101. package/dist/registry/index.json +27 -3
  102. package/dist/registry/js-mongo/account-security.json +1 -1
  103. package/dist/registry/js-mongo/admin-users.json +1 -1
  104. package/dist/registry/js-mongo/auth.json +1 -1
  105. package/dist/registry/js-mongo/auth@apple.json +1 -1
  106. package/dist/registry/js-mongo/auth@google.json +1 -1
  107. package/dist/registry/js-mongo/forgot-password.json +1 -1
  108. package/dist/registry/js-mongo/user-profile.json +1 -1
  109. package/dist/registry/js-mongo-collection/account-security.json +1 -1
  110. package/dist/registry/js-mongo-collection/admin-users.json +1 -1
  111. package/dist/registry/js-mongo-collection/auth.json +1 -1
  112. package/dist/registry/js-mongo-collection/auth@apple.json +1 -1
  113. package/dist/registry/js-mongo-collection/auth@google.json +1 -1
  114. package/dist/registry/js-mongo-collection/forgot-password.json +1 -1
  115. package/dist/registry/js-mongo-collection/user-profile.json +1 -1
  116. package/dist/registry/js-pg-model/account-security.json +1 -1
  117. package/dist/registry/js-pg-model/admin-users.json +1 -1
  118. package/dist/registry/js-pg-model/auth.json +1 -1
  119. package/dist/registry/js-pg-model/auth@apple.json +1 -1
  120. package/dist/registry/js-pg-model/auth@google.json +1 -1
  121. package/dist/registry/js-pg-model/forgot-password.json +1 -1
  122. package/dist/registry/js-pg-model/user-profile.json +1 -1
  123. package/dist/registry/js-pg-table/account-security.json +1 -1
  124. package/dist/registry/js-pg-table/admin-users.json +1 -1
  125. package/dist/registry/js-pg-table/auth.json +1 -1
  126. package/dist/registry/js-pg-table/auth@apple.json +1 -1
  127. package/dist/registry/js-pg-table/auth@google.json +1 -1
  128. package/dist/registry/js-pg-table/forgot-password.json +1 -1
  129. package/dist/registry/js-pg-table/user-profile.json +1 -1
  130. package/dist/registry/ts-mongo/account-security.json +1 -1
  131. package/dist/registry/ts-mongo/admin-users.json +1 -1
  132. package/dist/registry/ts-mongo/auth.json +1 -1
  133. package/dist/registry/ts-mongo/auth@apple.json +1 -1
  134. package/dist/registry/ts-mongo/auth@google.json +1 -1
  135. package/dist/registry/ts-mongo/forgot-password.json +1 -1
  136. package/dist/registry/ts-mongo/user-profile.json +1 -1
  137. package/dist/registry/ts-mongo-collection/account-security.json +1 -1
  138. package/dist/registry/ts-mongo-collection/admin-users.json +1 -1
  139. package/dist/registry/ts-mongo-collection/auth.json +1 -1
  140. package/dist/registry/ts-mongo-collection/auth@apple.json +1 -1
  141. package/dist/registry/ts-mongo-collection/auth@google.json +1 -1
  142. package/dist/registry/ts-mongo-collection/forgot-password.json +1 -1
  143. package/dist/registry/ts-mongo-collection/user-profile.json +1 -1
  144. package/dist/registry/ts-pg-model/account-security.json +1 -1
  145. package/dist/registry/ts-pg-model/admin-users.json +1 -1
  146. package/dist/registry/ts-pg-model/auth.json +1 -1
  147. package/dist/registry/ts-pg-model/auth@apple.json +1 -1
  148. package/dist/registry/ts-pg-model/auth@google.json +1 -1
  149. package/dist/registry/ts-pg-model/forgot-password.json +1 -1
  150. package/dist/registry/ts-pg-model/user-profile.json +1 -1
  151. package/dist/registry/ts-pg-table/account-security.json +1 -1
  152. package/dist/registry/ts-pg-table/admin-users.json +1 -1
  153. package/dist/registry/ts-pg-table/auth.json +1 -1
  154. package/dist/registry/ts-pg-table/auth@apple.json +1 -1
  155. package/dist/registry/ts-pg-table/auth@google.json +1 -1
  156. package/dist/registry/ts-pg-table/forgot-password.json +1 -1
  157. package/dist/registry/ts-pg-table/user-profile.json +1 -1
  158. package/dist/tasks/index.cjs +3 -2
  159. package/dist/tasks/index.cjs.map +1 -1
  160. package/dist/tasks/index.d.cts +3 -1
  161. package/dist/tasks/index.d.ts +3 -1
  162. package/dist/tasks/index.js +1 -1
  163. package/dist/testing-cjs.cjs +5 -0
  164. package/dist/testing.cjs +65 -0
  165. package/dist/testing.cjs.map +1 -0
  166. package/dist/testing.d.cts +30 -0
  167. package/dist/testing.d.ts +30 -0
  168. package/dist/testing.js +64 -0
  169. package/dist/testing.js.map +1 -0
  170. package/dist/thread-runner.cjs +4 -3
  171. package/dist/thread-runner.cjs.map +1 -1
  172. package/dist/thread-runner.js +2 -2
  173. package/dist/{types-Bnxvj3l0.d.ts → types-D3QmZgeX.d.cts} +88 -2
  174. package/dist/{types-Bnxvj3l0.d.cts → types-D3QmZgeX.d.ts} +88 -2
  175. package/package.json +11 -4
  176. package/dist/chunk-4DOHQU6I.cjs.map +0 -1
  177. package/dist/chunk-73XJUT2S.js.map +0 -1
  178. package/dist/chunk-7KC2H76D.js.map +0 -1
  179. package/dist/chunk-DUADUR6R.cjs.map +0 -1
  180. package/dist/chunk-EGSSZUVO.js.map +0 -1
  181. package/dist/chunk-HBCY7ILD.cjs.map +0 -1
  182. package/dist/chunk-KFVFP2Q7.cjs.map +0 -1
  183. package/dist/chunk-NKLOE4AK.cjs.map +0 -1
  184. package/dist/chunk-QDEDOHP7.js.map +0 -1
  185. package/dist/chunk-WBLUGOAG.cjs.map +0 -1
  186. package/dist/pgboss-backend-FW42SBSM.js +0 -14
  187. package/dist/pgboss-backend-RVHUBJTU.cjs +0 -14
  188. package/dist/pgboss-backend-RVHUBJTU.cjs.map +0 -1
  189. /package/dist/{chunk-R52CUEGT.js.map → chunk-3SWI46YK.js.map} +0 -0
  190. /package/dist/{chunk-RAB44UGX.js.map → chunk-B6MB6HEG.js.map} +0 -0
  191. /package/dist/{chunk-R4XO4SVM.js.map → chunk-EJDZZ4KX.js.map} +0 -0
  192. /package/dist/{chunk-NI2BNGGV.js.map → chunk-O2E7H2XA.js.map} +0 -0
  193. /package/dist/{chunk-ATVD2HGC.js.map → chunk-OM2XJJWX.js.map} +0 -0
  194. /package/dist/{pgboss-backend-FW42SBSM.js.map → pgboss-backend-PQW6I3VF.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -6,194 +6,72 @@
6
6
 
7
7
 
8
8
 
9
- var _chunkKFVFP2Q7cjs = require('./chunk-KFVFP2Q7.cjs');
9
+ var _chunkDGYPIIJEcjs = require('./chunk-DGYPIIJE.cjs');
10
10
 
11
11
 
12
- var _chunkDCJOWFVDcjs = require('./chunk-DCJOWFVD.cjs');
13
12
 
14
13
 
15
14
 
16
- var _chunkYK4ZM3CAcjs = require('./chunk-YK4ZM3CA.cjs');
17
15
 
18
16
 
19
17
 
18
+ var _chunkIEF6AEK3cjs = require('./chunk-IEF6AEK3.cjs');
20
19
 
21
20
 
21
+ var _chunkWHBSVYUYcjs = require('./chunk-WHBSVYUY.cjs');
22
22
 
23
23
 
24
24
 
25
+ var _chunkDTMDJGRWcjs = require('./chunk-DTMDJGRW.cjs');
25
26
 
26
- var _chunkHBCY7ILDcjs = require('./chunk-HBCY7ILD.cjs');
27
27
 
28
28
 
29
29
 
30
30
 
31
31
 
32
32
 
33
- var _chunkNKLOE4AKcjs = require('./chunk-NKLOE4AK.cjs');
34
33
 
35
34
 
35
+ var _chunkSOU3PBJCcjs = require('./chunk-SOU3PBJC.cjs');
36
36
 
37
- var _chunk7KO4DJRJcjs = require('./chunk-7KO4DJRJ.cjs');
38
- require('./chunk-WBLUGOAG.cjs');
39
37
 
40
38
 
41
39
 
42
- var _chunkGBI77W5Tcjs = require('./chunk-GBI77W5T.cjs');
40
+ var _chunkGWMW6XY7cjs = require('./chunk-GWMW6XY7.cjs');
43
41
 
44
42
 
45
43
 
44
+ var _chunkAGOYTFROcjs = require('./chunk-AGOYTFRO.cjs');
46
45
 
47
46
 
48
47
 
48
+ var _chunk6WTMRZS7cjs = require('./chunk-6WTMRZS7.cjs');
49
+ require('./chunk-RPL2IFWK.cjs');
49
50
 
50
51
 
51
52
 
53
+ var _chunkH2PVWCWCcjs = require('./chunk-H2PVWCWC.cjs');
52
54
 
53
- var _chunkDUADUR6Rcjs = require('./chunk-DUADUR6R.cjs');
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+ var _chunkQSIP7YLWcjs = require('./chunk-QSIP7YLW.cjs');
65
+ require('./chunk-CGY7JU4Y.cjs');
54
66
 
55
67
  // src/index.ts
68
+ var _http = require('http'); var _http2 = _interopRequireDefault(_http);
56
69
  var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
57
70
  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
71
  var _cluster = require('cluster'); var _cluster2 = _interopRequireDefault(_cluster);
61
72
  var _os = require('os'); var _os2 = _interopRequireDefault(_os);
62
73
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
63
74
 
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
75
  // src/cluster/index.ts
198
76
 
199
77
  var isShuttingDown = false;
@@ -202,33 +80,33 @@ function workerCount() {
202
80
  }
203
81
  function shutdownMaster() {
204
82
  isShuttingDown = true;
205
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).info(`Cluster primary (pid=${process.pid}) shutting down, waiting for workers\u2026`);
83
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).info(`Cluster primary (pid=${process.pid}) shutting down, waiting for workers\u2026`);
206
84
  if (workerCount() === 0) process.exit(0);
207
85
  for (const worker of Object.values(_nullishCoalesce(_cluster2.default.workers, () => ( {})))) {
208
- _optionalChain([worker, 'optionalAccess', _3 => _3.process, 'access', _4 => _4.kill, 'call', _5 => _5("SIGTERM")]);
86
+ _optionalChain([worker, 'optionalAccess', _ => _.process, 'access', _2 => _2.kill, 'call', _3 => _3("SIGTERM")]);
209
87
  }
210
88
  }
211
89
  function runMaster(options = {}) {
212
90
  const count = _nullishCoalesce(options.workers, () => ( 1));
213
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).info(`Primary ${process.pid} starting ${count} workers`);
91
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).info(`Primary ${process.pid} starting ${count} workers`);
214
92
  for (let i = 0; i < count; i++) {
215
93
  _cluster2.default.fork();
216
94
  }
217
95
  _cluster2.default.on("online", (worker) => {
218
- _optionalChain([options, 'access', _6 => _6.onWorkerReady, 'optionalCall', _7 => _7(worker.id)]);
96
+ _optionalChain([options, 'access', _4 => _4.onWorkerReady, 'optionalCall', _5 => _5(worker.id)]);
219
97
  });
220
98
  _cluster2.default.on("exit", (worker, code, signal) => {
221
99
  const exitCode = _nullishCoalesce(code, () => ( (signal ? -1 : 0)));
222
100
  if (isShuttingDown) {
223
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).info(`Worker ${worker.id} gracefully exited`);
101
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).info(`Worker ${worker.id} gracefully exited`);
224
102
  if (workerCount() === 0) {
225
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).info("All workers exited. Primary exiting.");
103
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).info("All workers exited. Primary exiting.");
226
104
  process.exit(0);
227
105
  }
228
106
  return;
229
107
  }
230
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).warn(`Worker ${worker.id} exited (code=${exitCode}), respawning\u2026`);
231
- _optionalChain([options, 'access', _8 => _8.onWorkerCrash, 'optionalCall', _9 => _9(worker.id, exitCode)]);
108
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).warn(`Worker ${worker.id} exited (code=${exitCode}), respawning\u2026`);
109
+ _optionalChain([options, 'access', _6 => _6.onWorkerCrash, 'optionalCall', _7 => _7(worker.id, exitCode)]);
232
110
  _cluster2.default.fork();
233
111
  });
234
112
  }
@@ -246,13 +124,13 @@ async function scanTasks(tasksDir) {
246
124
  const mod = await Promise.resolve().then(() => _interopRequireWildcard(require(filePath)));
247
125
  const def = mod["default"];
248
126
  if (!def || typeof def.handler !== "function") {
249
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).warn(`Task file ${file} has no valid default export \u2014 skipping`);
127
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).warn(`Task file ${file} has no valid default export \u2014 skipping`);
250
128
  continue;
251
129
  }
252
- _chunkGBI77W5Tcjs.registerTask.call(void 0, taskName, { ...def, filePath });
253
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).debug(`Registered task: ${taskName}`);
130
+ _chunkH2PVWCWCcjs.registerTask.call(void 0, taskName, { ...def, filePath });
131
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).debug(`Registered task: ${taskName}`);
254
132
  } catch (err) {
255
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).warn({ err }, `Failed to load task ${file}`);
133
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).warn({ err }, `Failed to load task ${file}`);
256
134
  }
257
135
  }
258
136
  }
@@ -277,7 +155,7 @@ function generateDashboard(routes, basePath, port, projectName, projectVersion)
277
155
  const safeRoutes = JSON.stringify(
278
156
  routes.map((r) => ({
279
157
  urlPath: r.urlPath,
280
- methods: r.methods,
158
+ methods: r.websocket ? [...r.methods, "WS"] : r.methods,
281
159
  params: r.params,
282
160
  meta: _nullishCoalesce(r.meta, () => ( null))
283
161
  }))
@@ -879,21 +757,21 @@ function rateLimit(options) {
879
757
  void (async () => {
880
758
  const who = keyOf(req);
881
759
  if (who === void 0) return next();
882
- if (!_chunkKFVFP2Q7cjs.isCacheConfigured.call(void 0, )) {
760
+ if (!_chunkIEF6AEK3cjs.isCacheConfigured.call(void 0, )) {
883
761
  throw new Error("[EFC] rateLimit needs a cache \u2014 pass cache: { backend } to ignite()");
884
762
  }
885
- const bucket = _nullishCoalesce(options.name, () => ( req.baseUrl + (_nullishCoalesce(_optionalChain([req, 'access', _10 => _10.route, 'optionalAccess', _11 => _11.path]), () => ( req.path)))));
763
+ const bucket = _nullishCoalesce(options.name, () => ( req.baseUrl + (_nullishCoalesce(_optionalChain([req, 'access', _8 => _8.route, 'optionalAccess', _9 => _9.path]), () => ( req.path)))));
886
764
  const windowMs = windowSeconds * 1e3;
887
765
  const now = Date.now();
888
766
  const slot = Math.floor(now / windowMs);
889
767
  const resetMs = (slot + 1) * windowMs - now;
890
768
  let count;
891
769
  try {
892
- count = (await _chunkKFVFP2Q7cjs.rawIncr.call(void 0, `rl:${bucket}:${who}:${slot}`, Math.ceil(resetMs / 1e3) + 1)).value;
770
+ count = (await _chunkIEF6AEK3cjs.rawIncr.call(void 0, `rl:${bucket}:${who}:${slot}`, Math.ceil(resetMs / 1e3) + 1)).value;
893
771
  } catch (err) {
894
772
  if (Date.now() - lastCacheError > 3e4) {
895
773
  lastCacheError = Date.now();
896
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).error(
774
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).error(
897
775
  { err },
898
776
  `rateLimit: cache unavailable \u2014 ${options.onCacheError === "reject" ? "rejecting with 503" : "allowing requests"}`
899
777
  );
@@ -928,14 +806,14 @@ function cacheResponse(options) {
928
806
  if (req.method !== "GET" && req.method !== "HEAD") return next();
929
807
  let scope = "";
930
808
  if (opts.perUser) {
931
- const user = _chunkDUADUR6Rcjs.getCurrentUser.call(void 0, );
932
- const id = _nullishCoalesce(_optionalChain([user, 'optionalAccess', _12 => _12["sub"]]), () => ( _optionalChain([user, 'optionalAccess', _13 => _13["id"]])));
809
+ const user = _chunkQSIP7YLWcjs.getCurrentUser.call(void 0, );
810
+ const id = _nullishCoalesce(_optionalChain([user, 'optionalAccess', _10 => _10["sub"]]), () => ( _optionalChain([user, 'optionalAccess', _11 => _11["id"]])));
933
811
  if (id === void 0) return next();
934
812
  scope = `u:${String(id)}:`;
935
813
  }
936
814
  const key = RESPONSE_PREFIX + scope + (opts.key ? opts.key(req) : req.originalUrl);
937
815
  void (async () => {
938
- const hit = await _chunkKFVFP2Q7cjs.cache.get(key);
816
+ const hit = await _chunkIEF6AEK3cjs.cache.get(key);
939
817
  if (hit) {
940
818
  res.setHeader("X-Cache", "HIT");
941
819
  res.status(hit.status).json(hit.body);
@@ -944,7 +822,7 @@ function cacheResponse(options) {
944
822
  res.setHeader("X-Cache", "MISS");
945
823
  const json = res.json.bind(res);
946
824
  res.json = (body) => {
947
- if (res.statusCode === 200) void _chunkKFVFP2Q7cjs.cache.set(key, { status: 200, body }, { ttl: opts.ttl });
825
+ if (res.statusCode === 200) void _chunkIEF6AEK3cjs.cache.set(key, { status: 200, body }, { ttl: opts.ttl });
948
826
  return json(body);
949
827
  };
950
828
  next();
@@ -966,7 +844,9 @@ function compose(...handlers) {
966
844
  return;
967
845
  }
968
846
  try {
969
- Promise.resolve(handler(req, res, () => dispatch(i + 1))).catch(next);
847
+ Promise.resolve(
848
+ handler(req, res, (err) => err ? next(err) : dispatch(i + 1))
849
+ ).catch(next);
970
850
  } catch (err) {
971
851
  next(err);
972
852
  }
@@ -983,14 +863,7 @@ function detectDatabase(url) {
983
863
  return void 0;
984
864
  }
985
865
  async function ignite(config) {
986
- const {
987
- port: _port,
988
- workers,
989
- globalMiddlewares = [],
990
- onWorkerReady,
991
- onWorkerCrash,
992
- onError
993
- } = config;
866
+ const { port: _port, workers, onWorkerReady, onWorkerCrash, onError } = config;
994
867
  function resolveConventionDir(name) {
995
868
  const candidates = [
996
869
  ...process.argv[1] ? [_path2.default.join(_path2.default.dirname(process.argv[1]), name)] : [],
@@ -1018,21 +891,21 @@ async function ignite(config) {
1018
891
  const jwtSecret = config.jwtSecret;
1019
892
  const authStrategy = _nullishCoalesce(config.authStrategy, () => ( "http-only"));
1020
893
  const clusterEnabled = _nullishCoalesce(config.cluster, () => ( process.env["NODE_ENV"] === "production"));
1021
- _chunkDUADUR6Rcjs.configureLogger.call(void 0, config.logging);
894
+ _chunkQSIP7YLWcjs.configureLogger.call(void 0, config.logging);
1022
895
  if (!["http-only", "bearer", "localStorage"].includes(authStrategy) && (!clusterEnabled || _cluster2.default.isPrimary)) {
1023
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).warn(
896
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).warn(
1024
897
  `[EFC] Unknown authStrategy "${String(authStrategy)}" \u2014 treated as 'bearer'. Use 'http-only' or 'bearer'; this will be an error in 1.0.`
1025
898
  );
1026
899
  }
1027
900
  if (jwtSecret && Buffer.byteLength(jwtSecret) < 32 && process.env["NODE_ENV"] === "production" && (!clusterEnabled || _cluster2.default.isPrimary)) {
1028
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).warn(
901
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).warn(
1029
902
  `[EFC] jwtSecret is ${Buffer.byteLength(jwtSecret)} bytes \u2014 use at least 32 random bytes in production (openssl rand -hex 64).`
1030
903
  );
1031
904
  }
1032
- _chunkDUADUR6Rcjs.configureQueryLog.call(void 0, config.logging);
905
+ _chunkQSIP7YLWcjs.configureQueryLog.call(void 0, config.logging);
1033
906
  if (clusterEnabled && _cluster2.default.isPrimary) {
1034
907
  if (config.cache && config.cache.backend === "memory") {
1035
- _chunkKFVFP2Q7cjs.servePrimaryCache.call(void 0, _nullishCoalesce(config.cache.maxEntries, () => ( 1e4)));
908
+ _chunkIEF6AEK3cjs.servePrimaryCache.call(void 0, _nullishCoalesce(config.cache.maxEntries, () => ( 1e4)));
1036
909
  }
1037
910
  runMaster({
1038
911
  workers: _nullishCoalesce(workers, () => ( _os2.default.cpus().length)),
@@ -1041,68 +914,35 @@ async function ignite(config) {
1041
914
  });
1042
915
  return;
1043
916
  }
1044
- const app = _express2.default.call(void 0, );
1045
- if (config.trustProxy !== void 0) app.set("trust proxy", config.trustProxy);
1046
- app.set(
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)));
917
+ const app = _chunkDGYPIIJEcjs.createHttpApp.call(void 0, config);
918
+ if (database) _chunkGWMW6XY7cjs.setDbEngine.call(void 0, database);
919
+ _chunkGWMW6XY7cjs.setAutoSync.call(void 0, _nullishCoalesce(config.autoSync, () => ( true)));
1080
920
  const poolWorkers = clusterEnabled ? _nullishCoalesce(workers, () => ( _os2.default.cpus().length)) : 1;
1081
- const reportsPools = !clusterEnabled || _optionalChain([_cluster2.default, 'access', _14 => _14.worker, 'optionalAccess', _15 => _15.id]) === 1;
921
+ const reportsPools = !clusterEnabled || _optionalChain([_cluster2.default, 'access', _12 => _12.worker, 'optionalAccess', _13 => _13.id]) === 1;
1082
922
  if (database === "mongodb" && databaseUrl) {
1083
- const conn = await _chunkHBCY7ILDcjs.connectMongo.call(void 0, databaseUrl, config.databasePool);
1084
- _chunkHBCY7ILDcjs.setDbClient.call(void 0, conn);
923
+ const conn = await _chunkSOU3PBJCcjs.connectMongo.call(void 0, databaseUrl, config.databasePool);
924
+ _chunkSOU3PBJCcjs.setDbClient.call(void 0, conn);
1085
925
  if (reportsPools) {
1086
- const max = _nullishCoalesce(_optionalChain([config, 'access', _16 => _16.databasePool, 'optionalAccess', _17 => _17.max]), () => ( 100));
1087
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).info(
926
+ const max = _nullishCoalesce(_optionalChain([config, 'access', _14 => _14.databasePool, 'optionalAccess', _15 => _15.max]), () => ( 100));
927
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).info(
1088
928
  `MongoDB connections: up to ${poolWorkers * max} from this machine (${poolWorkers} worker(s) \xD7 maxPoolSize ${max})`
1089
929
  );
1090
930
  }
1091
931
  } else if (database === "postgresql" && databaseUrl) {
1092
- const pool = await _chunkDUADUR6Rcjs.connectPostgres.call(void 0, databaseUrl, config.databasePool);
1093
- _chunkHBCY7ILDcjs.setDbClient.call(void 0, pool);
932
+ const pool = await _chunkQSIP7YLWcjs.connectPostgres.call(void 0, databaseUrl, config.databasePool);
933
+ _chunkSOU3PBJCcjs.setDbClient.call(void 0, pool);
1094
934
  if (reportsPools) {
1095
- const max = _nullishCoalesce(_optionalChain([config, 'access', _18 => _18.databasePool, 'optionalAccess', _19 => _19.max]), () => ( 10));
935
+ const max = _nullishCoalesce(_optionalChain([config, 'access', _16 => _16.databasePool, 'optionalAccess', _17 => _17.max]), () => ( 10));
1096
936
  const boss = config.tasks && config.tasks.backend === "pg-boss" && !config.tasks.connectionString ? 10 : 0;
1097
937
  const breakdown = `${poolWorkers} worker(s) \xD7 (pool ${max}${boss ? ` + pg-boss ${boss}` : ""})`;
1098
- await _chunkDUADUR6Rcjs.checkConnectionBudget.call(void 0, poolWorkers * (max + boss), breakdown);
938
+ await _chunkQSIP7YLWcjs.checkConnectionBudget.call(void 0, poolWorkers * (max + boss), breakdown);
1099
939
  }
1100
940
  }
1101
941
  if (config.cache) {
1102
- await _chunkKFVFP2Q7cjs.configureCache.call(void 0, config.cache);
942
+ await _chunkIEF6AEK3cjs.configureCache.call(void 0, config.cache);
1103
943
  }
1104
944
  if (jwtSecret) {
1105
- _chunkKFVFP2Q7cjs.configureAuth.call(void 0, {
945
+ _chunkIEF6AEK3cjs.configureAuth.call(void 0, {
1106
946
  secret: jwtSecret,
1107
947
  strategy: authStrategy,
1108
948
  expiresIn: _nullishCoalesce(config.jwtExpiresIn, () => ( "7d")),
@@ -1114,7 +954,7 @@ async function ignite(config) {
1114
954
  }
1115
955
  if (config.tasks) {
1116
956
  if (config.tasks.backend === "bullmq") {
1117
- await _chunkYK4ZM3CAcjs.initBullMQ.call(void 0, {
957
+ await _chunkDTMDJGRWcjs.initBullMQ.call(void 0, {
1118
958
  redisUrl: _nullishCoalesce(config.tasks.redisUrl, () => ( "redis://localhost:6379")),
1119
959
  concurrency: _nullishCoalesce(config.tasks.concurrency, () => ( 5)),
1120
960
  enqueueTimeout: _nullishCoalesce(config.tasks.enqueueTimeout, () => ( 5e3)),
@@ -1127,7 +967,7 @@ async function ignite(config) {
1127
967
  '[EFC] tasks.backend "pg-boss" needs tasks.connectionString or databaseUrl'
1128
968
  );
1129
969
  }
1130
- await _chunk7KO4DJRJcjs.initPgBoss.call(void 0, {
970
+ await _chunk6WTMRZS7cjs.initPgBoss.call(void 0, {
1131
971
  connectionString,
1132
972
  concurrency: _nullishCoalesce(config.tasks.concurrency, () => ( 5)),
1133
973
  enqueueTimeout: _nullishCoalesce(config.tasks.enqueueTimeout, () => ( 5e3)),
@@ -1136,9 +976,18 @@ async function ignite(config) {
1136
976
  });
1137
977
  }
1138
978
  }
1139
- const routes = _chunkDCJOWFVDcjs.scanDir.call(void 0, apiDir);
979
+ const routes = _chunkWHBSVYUYcjs.scanDir.call(void 0, apiDir);
1140
980
  const apiRouter = _express2.default.Router();
1141
- const mounted = await mountRoutes(apiRouter, routes);
981
+ const mounted = await _chunkDGYPIIJEcjs.mountRoutes.call(void 0, apiRouter, routes);
982
+ if (config.openapi) {
983
+ const meta = readProjectMeta();
984
+ const options = config.openapi === true ? {} : config.openapi;
985
+ await _chunkDGYPIIJEcjs.mountOpenAPI.call(void 0, app, mounted, {
986
+ info: { title: meta.name, version: meta.version },
987
+ ...options,
988
+ basePath
989
+ });
990
+ }
1142
991
  app.use(basePath, apiRouter);
1143
992
  if (config.dashboard !== false && process.env["NODE_ENV"] === "development") {
1144
993
  app.get("/", (_req, res) => {
@@ -1147,42 +996,19 @@ async function ignite(config) {
1147
996
  res.send(generateDashboard(mounted, basePath, port, name, version));
1148
997
  });
1149
998
  }
1150
- if (onError) {
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
- }
999
+ _chunkDGYPIIJEcjs.mountErrorHandler.call(void 0, app, onError);
1177
1000
  return new Promise((resolve, reject) => {
1178
- const server = app.listen(port);
1001
+ const server = _http2.default.createServer(app);
1002
+ if (config.websocket !== false && mounted.some((route) => route.websocket))
1003
+ _chunkDGYPIIJEcjs.attachWebSockets.call(void 0, server, app, config.websocket);
1179
1004
  server.once("listening", () => {
1180
- const wid = _nullishCoalesce(_optionalChain([_cluster2.default, 'access', _21 => _21.worker, 'optionalAccess', _22 => _22.id]), () => ( "primary"));
1005
+ const wid = _nullishCoalesce(_optionalChain([_cluster2.default, 'access', _18 => _18.worker, 'optionalAccess', _19 => _19.id]), () => ( "primary"));
1181
1006
  const addr = server.address();
1182
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).info(`Worker ${wid} listening on :${_nullishCoalesce(_optionalChain([addr, 'optionalAccess', _23 => _23.port]), () => ( port))}`);
1007
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).info(`Worker ${wid} listening on :${_nullishCoalesce(_optionalChain([addr, 'optionalAccess', _20 => _20.port]), () => ( port))}`);
1183
1008
  resolve(server);
1184
1009
  });
1185
1010
  server.once("error", reject);
1011
+ server.listen(port);
1186
1012
  });
1187
1013
  }
1188
1014
  function gracefulShutdown(server, timeoutMs = 1e4) {
@@ -1190,21 +1016,22 @@ function gracefulShutdown(server, timeoutMs = 1e4) {
1190
1016
  const shutdown = (signal) => {
1191
1017
  if (shuttingDown) return;
1192
1018
  shuttingDown = true;
1193
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).info(`${signal} received \u2014 closing server gracefully\u2026`);
1019
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).info(`${signal} received \u2014 closing server gracefully\u2026`);
1194
1020
  if (server) {
1021
+ const websocketDrain = _chunkDGYPIIJEcjs.closeWebSockets.call(void 0, server, Math.max(1, Math.min(1e3, timeoutMs / 2)));
1195
1022
  server.closeIdleConnections();
1196
1023
  server.close(() => {
1197
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).info("Server closed");
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));
1024
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).info("Server closed");
1025
+ Promise.all([websocketDrain, _chunkDTMDJGRWcjs.closeBullMQ.call(void 0, ), _chunk6WTMRZS7cjs.closePgBoss.call(void 0, ), _chunkIEF6AEK3cjs.closeCache.call(void 0, )]).catch((err) => _chunkQSIP7YLWcjs.getLogger.call(void 0, ).error({ err }, "Task backend close failed")).finally(() => process.exit(0));
1199
1026
  });
1200
1027
  setTimeout(() => {
1201
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).error("Forced exit after timeout");
1028
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).error("Forced exit after timeout");
1202
1029
  process.exit(1);
1203
1030
  }, timeoutMs).unref();
1204
1031
  } else {
1205
1032
  shutdownMaster();
1206
1033
  setTimeout(() => {
1207
- _chunkDUADUR6Rcjs.getLogger.call(void 0, ).error("Workers did not exit in time \u2014 forcing primary exit");
1034
+ _chunkQSIP7YLWcjs.getLogger.call(void 0, ).error("Workers did not exit in time \u2014 forcing primary exit");
1208
1035
  process.exit(1);
1209
1036
  }, timeoutMs + 2e3).unref();
1210
1037
  }
@@ -1234,5 +1061,11 @@ function gracefulShutdown(server, timeoutMs = 1e4) {
1234
1061
 
1235
1062
 
1236
1063
 
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;
1238
- //# sourceMappingURL=index.cjs.map
1064
+
1065
+
1066
+
1067
+
1068
+
1069
+ exports.HttpError = _chunkAGOYTFROcjs.HttpError; exports.ModelValidationError = _chunkGWMW6XY7cjs.ModelValidationError; exports.attachWebSockets = _chunkDGYPIIJEcjs.attachWebSockets; exports.cache = _chunkIEF6AEK3cjs.cache; exports.cacheResponse = cacheResponse; exports.closeWebSockets = _chunkDGYPIIJEcjs.closeWebSockets; exports.compose = compose; exports.db = _chunkSOU3PBJCcjs.db; exports.defineCollection = _chunkSOU3PBJCcjs.defineCollection; exports.defineModel = _chunkSOU3PBJCcjs.defineModel; exports.defineTable = _chunkSOU3PBJCcjs.defineTable; exports.generateOpenAPI = _chunkDGYPIIJEcjs.generateOpenAPI; exports.getDbClient = _chunkSOU3PBJCcjs.getDbClient; exports.getLogger = _chunkQSIP7YLWcjs.getLogger; exports.getQueryMetrics = _chunkQSIP7YLWcjs.getQueryMetrics; exports.gracefulShutdown = gracefulShutdown; exports.ignite = ignite; exports.isHttpError = _chunkAGOYTFROcjs.isHttpError; exports.listTasks = _chunkH2PVWCWCcjs.listTasks; exports.logger = _chunkQSIP7YLWcjs.logger; exports.rateLimit = rateLimit; exports.resetQueryMetrics = _chunkQSIP7YLWcjs.resetQueryMetrics; exports.scanDir = _chunkWHBSVYUYcjs.scanDir; exports.setDbClient = _chunkSOU3PBJCcjs.setDbClient; exports.transaction = _chunkSOU3PBJCcjs.transaction; exports.workerCount = workerCount;
1070
+ //# sourceMappingURL=index.cjs.map
1071
+ exports.generateOpenAPI = require("./openapi-cjs.cjs").generateOpenAPI;