express-file-cluster 0.10.2 → 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 (86) hide show
  1. package/dist/auth/index.cjs +4 -4
  2. package/dist/auth/index.d.cts +3 -1
  3. package/dist/auth/index.d.ts +3 -1
  4. package/dist/auth/index.js +3 -3
  5. package/dist/{chunk-V73R76I4.js → chunk-2IDRC7RK.js} +2 -1
  6. package/dist/{chunk-RETV3GKE.js → chunk-336IU55W.js} +2 -2
  7. package/dist/{chunk-7BC3AN7R.cjs → chunk-6WTMRZS7.cjs} +8 -8
  8. package/dist/{chunk-7BC3AN7R.cjs.map → chunk-6WTMRZS7.cjs.map} +1 -1
  9. package/dist/chunk-DGYPIIJE.cjs +845 -0
  10. package/dist/chunk-DGYPIIJE.cjs.map +1 -0
  11. package/dist/{chunk-TBIVIR6L.cjs → chunk-DTMDJGRW.cjs} +8 -8
  12. package/dist/{chunk-TBIVIR6L.cjs.map → chunk-DTMDJGRW.cjs.map} +1 -1
  13. package/dist/{chunk-MUVO7MGS.js → chunk-EJDZZ4KX.js} +2 -2
  14. package/dist/{chunk-IUZ6A7PB.cjs → chunk-GWMW6XY7.cjs} +13 -13
  15. package/dist/{chunk-IUZ6A7PB.cjs.map → chunk-GWMW6XY7.cjs.map} +1 -1
  16. package/dist/{chunk-Y4NKIXUL.cjs → chunk-IEF6AEK3.cjs} +13 -13
  17. package/dist/{chunk-Y4NKIXUL.cjs.map → chunk-IEF6AEK3.cjs.map} +1 -1
  18. package/dist/{chunk-BG4A7Z32.js → chunk-JBOMTZT5.js} +3 -3
  19. package/dist/chunk-LECHRAU3.js +845 -0
  20. package/dist/chunk-LECHRAU3.js.map +1 -0
  21. package/dist/{chunk-5LPRKZPB.js → chunk-O2E7H2XA.js} +2 -2
  22. package/dist/{chunk-C2FOZ7ME.js → chunk-OM2XJJWX.js} +2 -2
  23. package/dist/{chunk-JP36TLL4.cjs → chunk-QSIP7YLW.cjs} +3 -2
  24. package/dist/chunk-QSIP7YLW.cjs.map +1 -0
  25. package/dist/{chunk-Y75V5FCU.js → chunk-R6GPQZLI.js} +3 -3
  26. package/dist/{chunk-R2K7AFIB.cjs → chunk-SOU3PBJC.cjs} +89 -89
  27. package/dist/{chunk-R2K7AFIB.cjs.map → chunk-SOU3PBJC.cjs.map} +1 -1
  28. package/dist/{chunk-4GHK27JA.cjs → chunk-WHBSVYUY.cjs} +3 -3
  29. package/dist/{chunk-4GHK27JA.cjs.map → chunk-WHBSVYUY.cjs.map} +1 -1
  30. package/dist/cli/db-runner.cjs +24 -24
  31. package/dist/cli/db-runner.js +3 -3
  32. package/dist/cli/index.cjs +8 -8
  33. package/dist/cli/index.js +5 -5
  34. package/dist/docs/api-reference/ignite.md +4 -0
  35. package/dist/docs/api-reference/openapi.md +36 -0
  36. package/dist/docs/api-reference/testing.md +2 -0
  37. package/dist/docs/api-reference/websockets.md +23 -0
  38. package/dist/docs/cli/add.md +1 -1
  39. package/dist/docs/core-concepts/clustering.md +2 -0
  40. package/dist/docs/core-concepts/file-based-routing.md +2 -0
  41. package/dist/docs/guides/feature-matrix.md +9 -0
  42. package/dist/docs/guides/openapi.md +57 -0
  43. package/dist/docs/guides/validation.md +2 -0
  44. package/dist/docs/guides/websockets.md +60 -0
  45. package/dist/docs/index.md +3 -1
  46. package/dist/docs/skills/SKILL.md +4 -2
  47. package/dist/docs/skills/api-surface.md +10 -0
  48. package/dist/docs/skills/pre-flight.md +2 -0
  49. package/dist/docs/skills/routing-rules.md +4 -0
  50. package/dist/docs/skills/what-not-to-invent.md +2 -0
  51. package/dist/index.cjs +75 -53
  52. package/dist/index.cjs.map +1 -1
  53. package/dist/index.d.cts +3 -2
  54. package/dist/index.d.ts +3 -2
  55. package/dist/index.js +32 -11
  56. package/dist/index.js.map +1 -1
  57. package/dist/openapi-cjs.cjs +5 -0
  58. package/dist/{pgboss-backend-4X2YT4RB.js → pgboss-backend-PQW6I3VF.js} +3 -3
  59. package/dist/pgboss-backend-QVXISTLP.cjs +15 -0
  60. package/dist/{pgboss-backend-UXQ3O2WT.cjs.map → pgboss-backend-QVXISTLP.cjs.map} +1 -1
  61. package/dist/registry/index.json +1 -1
  62. package/dist/tasks/index.d.cts +3 -1
  63. package/dist/tasks/index.d.ts +3 -1
  64. package/dist/testing.cjs +16 -10
  65. package/dist/testing.cjs.map +1 -1
  66. package/dist/testing.d.cts +4 -1
  67. package/dist/testing.d.ts +4 -1
  68. package/dist/testing.js +12 -6
  69. package/dist/testing.js.map +1 -1
  70. package/dist/{types-CPMFTVXm.d.cts → types-D3QmZgeX.d.cts} +80 -2
  71. package/dist/{types-CPMFTVXm.d.ts → types-D3QmZgeX.d.ts} +80 -2
  72. package/package.json +6 -4
  73. package/dist/chunk-74BSJXWD.cjs +0 -220
  74. package/dist/chunk-74BSJXWD.cjs.map +0 -1
  75. package/dist/chunk-JP36TLL4.cjs.map +0 -1
  76. package/dist/chunk-KLWL7XSC.js +0 -220
  77. package/dist/chunk-KLWL7XSC.js.map +0 -1
  78. package/dist/pgboss-backend-UXQ3O2WT.cjs +0 -15
  79. /package/dist/{chunk-V73R76I4.js.map → chunk-2IDRC7RK.js.map} +0 -0
  80. /package/dist/{chunk-RETV3GKE.js.map → chunk-336IU55W.js.map} +0 -0
  81. /package/dist/{chunk-MUVO7MGS.js.map → chunk-EJDZZ4KX.js.map} +0 -0
  82. /package/dist/{chunk-BG4A7Z32.js.map → chunk-JBOMTZT5.js.map} +0 -0
  83. /package/dist/{chunk-5LPRKZPB.js.map → chunk-O2E7H2XA.js.map} +0 -0
  84. /package/dist/{chunk-C2FOZ7ME.js.map → chunk-OM2XJJWX.js.map} +0 -0
  85. /package/dist/{chunk-Y75V5FCU.js.map → chunk-R6GPQZLI.js.map} +0 -0
  86. /package/dist/{pgboss-backend-4X2YT4RB.js.map → pgboss-backend-PQW6I3VF.js.map} +0 -0
@@ -1,220 +0,0 @@
1
- import {
2
- isHttpError
3
- } from "./chunk-XPY5TQDK.js";
4
- import {
5
- getLogger,
6
- requestLogger,
7
- runWithContext
8
- } from "./chunk-V73R76I4.js";
9
-
10
- // src/router/validate.ts
11
- var LOCATIONS = ["params", "query", "body"];
12
- function isRequestSchema(value) {
13
- return value != null && typeof value === "object" && LOCATIONS.some((loc) => loc in value);
14
- }
15
- function schemaFor(schema, method) {
16
- if (!schema) return void 0;
17
- const byMethod = schema[method];
18
- if (isRequestSchema(byMethod)) return byMethod;
19
- return isRequestSchema(schema) ? schema : void 0;
20
- }
21
- function pathToString(path) {
22
- if (!path) return "";
23
- return path.map((p) => typeof p === "object" && p !== null && "key" in p ? p.key : p).map(String).join(".");
24
- }
25
- async function run(validator, input) {
26
- const std = validator["~standard"];
27
- if (std && typeof std.validate === "function") {
28
- return await std.validate(input);
29
- }
30
- const v = validator;
31
- const parse = v.safeParseAsync ?? v.safeParse;
32
- if (typeof parse !== "function") {
33
- throw new Error("[EFC] Route schema entries must be Standard Schema validators (e.g. zod)");
34
- }
35
- const r = await parse.call(validator, input);
36
- return r.success ? { value: r.data } : { issues: r.error?.issues ?? [{ message: "Invalid" }] };
37
- }
38
- function validateRequest(schema) {
39
- return (req, res, next) => {
40
- void (async () => {
41
- const issues = [];
42
- const parsed = {};
43
- for (const location of LOCATIONS) {
44
- const validator = schema[location];
45
- if (!validator) continue;
46
- const result = await run(validator, req[location]);
47
- if (result.issues) {
48
- for (const issue of result.issues) {
49
- issues.push({ location, path: pathToString(issue.path), message: issue.message });
50
- }
51
- } else {
52
- parsed[location] = result.value;
53
- }
54
- }
55
- if (issues.length > 0) {
56
- res.status(400).json({ error: "Validation failed", statusCode: 400, issues });
57
- return;
58
- }
59
- for (const location of LOCATIONS) {
60
- if (location in parsed) {
61
- Object.defineProperty(req, location, {
62
- value: parsed[location],
63
- writable: true,
64
- configurable: true,
65
- enumerable: true
66
- });
67
- }
68
- }
69
- next();
70
- })().catch(next);
71
- };
72
- }
73
-
74
- // src/router/mount.ts
75
- var HTTP_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"];
76
- function asyncWrap(handler) {
77
- return (req, res, next) => {
78
- Promise.resolve(handler(req, res, next)).catch(next);
79
- };
80
- }
81
- function namedParams(route) {
82
- const catchAlls = new Set([...route.urlPath.matchAll(/:([A-Za-z0-9_$]+)\*/g)].map((m) => m[1]));
83
- return (req, _res, next) => {
84
- const captures = route.pattern.exec(req.path);
85
- const named = {};
86
- route.params.forEach((name, i) => {
87
- const value = captures?.[i + 1];
88
- if (value === void 0 || value === "") {
89
- named[name] = catchAlls.has(name) ? [] : void 0;
90
- } else if (catchAlls.has(name)) {
91
- named[name] = value.split("/").filter(Boolean).map(decodeURIComponent);
92
- } else {
93
- named[name] = decodeURIComponent(value);
94
- }
95
- });
96
- req.params = named;
97
- next();
98
- };
99
- }
100
- async function mountRoutes(app, routes) {
101
- const mounted = [];
102
- for (const route of routes) {
103
- const mod = await import(route.filePath);
104
- const routeMiddlewares = Array.isArray(mod["middlewares"]) ? mod["middlewares"] : [];
105
- const raw = mod["meta"];
106
- const meta = raw != null && typeof raw === "object" && !Array.isArray(raw) ? raw : void 0;
107
- const schema = mod["schema"] != null && typeof mod["schema"] === "object" ? mod["schema"] : void 0;
108
- const routePath = route.pattern ?? route.urlPath;
109
- const paramMapper = route.pattern ? [namedParams(route)] : [];
110
- const implemented = [];
111
- const unimplemented = [];
112
- for (const method of HTTP_METHODS) {
113
- if (typeof mod[method] === "function") {
114
- implemented.push(method);
115
- const methodSchema = schemaFor(schema, method);
116
- const validation = methodSchema ? [validateRequest(methodSchema)] : [];
117
- app[method.toLowerCase()](
118
- routePath,
119
- ...paramMapper,
120
- ...routeMiddlewares,
121
- ...validation,
122
- asyncWrap(mod[method])
123
- );
124
- } else {
125
- unimplemented.push(method);
126
- }
127
- }
128
- if (implemented.length > 0 && unimplemented.length > 0) {
129
- const allowHeader = implemented.join(", ");
130
- app.all(routePath, (req, res, next) => {
131
- if (unimplemented.includes(req.method)) {
132
- res.set("Allow", allowHeader).status(405).json({ error: "Method Not Allowed" });
133
- } else {
134
- next();
135
- }
136
- });
137
- }
138
- mounted.push({ ...route, methods: implemented, ...meta !== void 0 && { meta } });
139
- }
140
- return mounted;
141
- }
142
-
143
- // src/http-app.ts
144
- import express from "express";
145
- import cors from "cors";
146
- import cookieParser from "cookie-parser";
147
- function createHttpApp(config) {
148
- const globalMiddlewares = config.globalMiddlewares ?? [];
149
- const app = express();
150
- if (config.trustProxy !== void 0) app.set("trust proxy", config.trustProxy);
151
- app.set(
152
- "json replacer",
153
- (_key, value) => typeof value === "bigint" ? value.toString() : value
154
- );
155
- app.use((_req, _res, next) => {
156
- runWithContext({}, next);
157
- });
158
- app.use(requestLogger());
159
- if (config.requestTimeout) {
160
- const ms = config.requestTimeout;
161
- app.use((_req, res, next) => {
162
- const timer = setTimeout(() => {
163
- if (!res.headersSent) res.status(408).json({ error: "Request Timeout", statusCode: 408 });
164
- }, ms);
165
- const clear = () => clearTimeout(timer);
166
- res.once("finish", clear);
167
- res.once("close", clear);
168
- next();
169
- });
170
- }
171
- const corsOption = config.cors ?? true;
172
- if (corsOption !== false) {
173
- const origin = typeof corsOption === "object" && corsOption.origin !== void 0 ? corsOption.origin : true;
174
- const corsOpts = typeof corsOption === "object" ? { ...corsOption, origin } : { origin };
175
- app.use(cors(corsOpts));
176
- }
177
- app.use(express.json());
178
- app.use(express.urlencoded({ extended: true }));
179
- app.use(cookieParser());
180
- for (const mw of globalMiddlewares) {
181
- app.use(mw);
182
- }
183
- return app;
184
- }
185
- function mountErrorHandler(app, onError) {
186
- if (onError) {
187
- app.use(onError);
188
- } else {
189
- app.use(
190
- (err, _req, res, _next) => {
191
- if (res.headersSent) {
192
- getLogger().warn({ err }, "Error after the response was sent");
193
- return;
194
- }
195
- const status = err?.statusCode;
196
- const duckTyped = err instanceof Error && typeof status === "number" && status >= 400 && status < 500 ? err : null;
197
- if (isHttpError(err)) {
198
- const issues = err.issues;
199
- res.status(err.statusCode).json({
200
- error: err.message,
201
- statusCode: err.statusCode,
202
- ...issues !== void 0 && { issues }
203
- });
204
- } else if (duckTyped) {
205
- res.status(duckTyped.statusCode).json({ error: duckTyped.message, statusCode: duckTyped.statusCode });
206
- } else {
207
- getLogger().error({ err }, "Unhandled error");
208
- res.status(500).json({ error: "Internal Server Error", statusCode: 500 });
209
- }
210
- }
211
- );
212
- }
213
- }
214
-
215
- export {
216
- mountRoutes,
217
- createHttpApp,
218
- mountErrorHandler
219
- };
220
- //# sourceMappingURL=chunk-KLWL7XSC.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/router/validate.ts","../src/router/mount.ts","../src/http-app.ts"],"sourcesContent":["import type { Request, RequestHandler } from 'express';\nimport type { RequestSchema, RouteSchema, ValidationIssue, Validator } from '../types.js';\n\nconst LOCATIONS = ['params', 'query', 'body'] as const;\ntype Location = (typeof LOCATIONS)[number];\n\ninterface StandardResult {\n value?: unknown;\n issues?: ReadonlyArray<{\n message: string;\n path?: ReadonlyArray<PropertyKey | { key: PropertyKey }>;\n }>;\n}\n\nfunction isRequestSchema(value: unknown): value is RequestSchema {\n return (\n value != null &&\n typeof value === 'object' &&\n LOCATIONS.some((loc) => loc in (value as Record<string, unknown>))\n );\n}\n\n/** Picks the schema for `method`: a method-keyed entry wins over a file-wide one. */\nexport function schemaFor(\n schema: RouteSchema | undefined,\n method: string,\n): RequestSchema | undefined {\n if (!schema) return undefined;\n const byMethod = (schema as Record<string, unknown>)[method];\n if (isRequestSchema(byMethod)) return byMethod;\n return isRequestSchema(schema) ? schema : undefined;\n}\n\ntype IssuePath = ReadonlyArray<PropertyKey | { key: PropertyKey }> | undefined;\n\nfunction pathToString(path: IssuePath): string {\n if (!path) return '';\n return path\n .map((p) => (typeof p === 'object' && p !== null && 'key' in p ? p.key : p))\n .map(String)\n .join('.');\n}\n\n// Standard Schema (zod >=3.24, valibot, arktype, ...) first; plain zod-style\n// safeParse as a fallback so older zod 3 releases work too.\nasync function run(validator: Validator, input: unknown): Promise<StandardResult> {\n const std = (validator as { '~standard'?: { validate: (v: unknown) => unknown } })['~standard'];\n if (std && typeof std.validate === 'function') {\n return (await std.validate(input)) as StandardResult;\n }\n const v = validator as {\n safeParseAsync?: (x: unknown) => Promise<unknown>;\n safeParse?: (x: unknown) => unknown;\n };\n const parse = v.safeParseAsync ?? v.safeParse;\n if (typeof parse !== 'function') {\n throw new Error('[EFC] Route schema entries must be Standard Schema validators (e.g. zod)');\n }\n const r = (await parse.call(validator, input)) as {\n success: boolean;\n data?: unknown;\n error?: { issues: Array<{ message: string; path: PropertyKey[] }> };\n };\n return r.success ? { value: r.data } : { issues: r.error?.issues ?? [{ message: 'Invalid' }] };\n}\n\n/**\n * Validates params/query/body against the route's schema. On success the parsed\n * output replaces the raw input (so coercions and defaults apply); on failure\n * responds 400 with every issue across all locations.\n */\nexport function validateRequest(schema: RequestSchema): RequestHandler {\n return (req, res, next) => {\n void (async () => {\n const issues: ValidationIssue[] = [];\n const parsed: Partial<Record<Location, unknown>> = {};\n\n for (const location of LOCATIONS) {\n const validator = schema[location];\n if (!validator) continue;\n const result = await run(validator, req[location]);\n if (result.issues) {\n for (const issue of result.issues) {\n issues.push({ location, path: pathToString(issue.path), message: issue.message });\n }\n } else {\n parsed[location] = result.value;\n }\n }\n\n if (issues.length > 0) {\n res.status(400).json({ error: 'Validation failed', statusCode: 400, issues });\n return;\n }\n\n for (const location of LOCATIONS) {\n if (location in parsed) {\n // req.query is a getter in some Express setups — define rather than assign.\n Object.defineProperty(req as Request, location, {\n value: parsed[location],\n writable: true,\n configurable: true,\n enumerable: true,\n });\n }\n }\n next();\n })().catch(next);\n };\n}\n","import type { IRouter, RequestHandler } from 'express';\nimport type { MountedRoute, RouteMeta, RouteEntry, RouteSchema } from '../types.js';\nimport { schemaFor, validateRequest } from './validate.js';\n\nconst HTTP_METHODS = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS'] as const;\ntype HttpMethod = (typeof HTTP_METHODS)[number];\n\nfunction asyncWrap(handler: RequestHandler): RequestHandler {\n return (req, res, next) => {\n Promise.resolve(handler(req, res, next)).catch(next);\n };\n}\n\n/**\n * For RegExp-mounted (catch-all) routes, Express exposes captures as params[0..n].\n * Rename them to the segment names from the file path; catch-alls become string\n * arrays (`[...slug]` → `['a', 'b']`), absent optional segments become undefined.\n */\nfunction namedParams(route: RouteEntry): RequestHandler {\n const catchAlls = new Set([...route.urlPath.matchAll(/:([A-Za-z0-9_$]+)\\*/g)].map((m) => m[1]!));\n return (req, _res, next) => {\n // Express has already decoded req.params. Read the raw captures so splitting\n // happens before decoding (an encoded slash belongs to a single segment).\n const captures = route.pattern!.exec(req.path);\n const named: Record<string, unknown> = {};\n route.params.forEach((name, i) => {\n const value = captures?.[i + 1];\n if (value === undefined || value === '') {\n named[name] = catchAlls.has(name) ? [] : undefined;\n } else if (catchAlls.has(name)) {\n named[name] = value.split('/').filter(Boolean).map(decodeURIComponent);\n } else {\n named[name] = decodeURIComponent(value);\n }\n });\n req.params = named as typeof req.params;\n next();\n };\n}\n\nexport async function mountRoutes(app: IRouter, routes: RouteEntry[]): Promise<MountedRoute[]> {\n const mounted: MountedRoute[] = [];\n\n for (const route of routes) {\n const mod = (await import(route.filePath)) as Record<string, unknown>;\n const routeMiddlewares: RequestHandler[] = Array.isArray(mod['middlewares'])\n ? (mod['middlewares'] as RequestHandler[])\n : [];\n\n const raw = mod['meta'];\n const meta: RouteMeta | undefined =\n raw != null && typeof raw === 'object' && !Array.isArray(raw)\n ? (raw as RouteMeta)\n : undefined;\n\n const schema =\n mod['schema'] != null && typeof mod['schema'] === 'object'\n ? (mod['schema'] as RouteSchema)\n : undefined;\n\n const routePath = route.pattern ?? route.urlPath;\n const paramMapper = route.pattern ? [namedParams(route)] : [];\n\n const implemented: HttpMethod[] = [];\n const unimplemented: HttpMethod[] = [];\n\n for (const method of HTTP_METHODS) {\n if (typeof mod[method] === 'function') {\n implemented.push(method);\n const methodSchema = schemaFor(schema, method);\n const validation = methodSchema ? [validateRequest(methodSchema)] : [];\n app[method.toLowerCase() as Lowercase<HttpMethod>](\n routePath,\n ...paramMapper,\n ...routeMiddlewares,\n ...validation,\n asyncWrap(mod[method] as RequestHandler),\n );\n } else {\n unimplemented.push(method);\n }\n }\n\n if (implemented.length > 0 && unimplemented.length > 0) {\n const allowHeader = implemented.join(', ');\n app.all(routePath, (req, res, next) => {\n if ((unimplemented as string[]).includes(req.method)) {\n res.set('Allow', allowHeader).status(405).json({ error: 'Method Not Allowed' });\n } else {\n next();\n }\n });\n }\n\n mounted.push({ ...route, methods: implemented, ...(meta !== undefined && { meta }) });\n }\n\n return mounted;\n}\n\nexport { asyncWrap };\n","import express from 'express';\nimport cors from 'cors';\nimport cookieParser from 'cookie-parser';\nimport type { EFCConfig } from './types.js';\nimport { runWithContext } from './context.js';\nimport { requestLogger, getLogger } from './logger.js';\nimport { isHttpError } from './errors.js';\n\n/** Shared production/test HTTP middleware stack; service boot remains in ignite(). */\nexport function createHttpApp(config: EFCConfig): express.Express {\n const globalMiddlewares = config.globalMiddlewares ?? [];\n const app = express();\n if (config.trustProxy !== undefined) app.set('trust proxy', config.trustProxy);\n // defineTable returns `bigint` for bigint columns and bigserial ids, which JSON.stringify\n // rejects; send them as strings (exact — a JS number would lose precision past 2^53).\n app.set('json replacer', (_key: string, value: unknown) =>\n typeof value === 'bigint' ? value.toString() : value,\n );\n\n // Wraps every request in its own AsyncLocalStorage context, first thing, so\n // requireAuth (below) and any downstream code — including a `$currentUser`\n // default resolved inside a mongoose `.create()` call — share the same store.\n app.use((_req, _res, next) => {\n runWithContext({}, next);\n });\n app.use(requestLogger());\n\n if (config.requestTimeout) {\n const ms = config.requestTimeout;\n app.use((_req, res, next) => {\n const timer = setTimeout(() => {\n if (!res.headersSent) res.status(408).json({ error: 'Request Timeout', statusCode: 408 });\n }, ms);\n const clear = () => clearTimeout(timer);\n res.once('finish', clear);\n res.once('close', clear);\n next();\n });\n }\n\n const corsOption = config.cors ?? true;\n if (corsOption !== false) {\n const origin =\n typeof corsOption === 'object' && corsOption.origin !== undefined ? corsOption.origin : true;\n const corsOpts = typeof corsOption === 'object' ? { ...corsOption, origin } : { origin };\n app.use(cors(corsOpts));\n }\n\n app.use(express.json());\n app.use(express.urlencoded({ extended: true }));\n app.use(cookieParser());\n\n for (const mw of globalMiddlewares) {\n app.use(mw);\n }\n\n return app;\n}\n\nexport function mountErrorHandler(\n app: express.Express,\n onError?: express.ErrorRequestHandler,\n): void {\n if (onError) {\n app.use(onError);\n } else {\n app.use(\n (err: unknown, _req: express.Request, res: express.Response, _next: express.NextFunction) => {\n // e.g. a handler that kept going after requestTimeout already answered 408.\n if (res.headersSent) {\n getLogger().warn({ err }, 'Error after the response was sent');\n return;\n }\n // isHttpError() covers the common case, but errors can also arrive as plain\n // objects with a numeric statusCode (e.g. thrown across a module boundary, or\n // duck-typed by user code) — fall back to that shape before giving up to 500.\n // Only 4xx: a library's 5xx message can describe internals (hosts, SQL, paths).\n const status = (err as { statusCode?: unknown } | null)?.statusCode;\n const duckTyped =\n err instanceof Error && typeof status === 'number' && status >= 400 && status < 500\n ? (err as Error & { statusCode: number })\n : null;\n\n if (isHttpError(err)) {\n // ModelValidationError carries per-field issues; surface them like route validation does.\n const issues = (err as { issues?: unknown }).issues;\n res.status(err.statusCode).json({\n error: err.message,\n statusCode: err.statusCode,\n ...(issues !== undefined && { issues }),\n });\n } else if (duckTyped) {\n res\n .status(duckTyped.statusCode)\n .json({ error: duckTyped.message, statusCode: duckTyped.statusCode });\n } else {\n getLogger().error({ err }, 'Unhandled error');\n res.status(500).json({ error: 'Internal Server Error', statusCode: 500 });\n }\n },\n );\n }\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAM,YAAY,CAAC,UAAU,SAAS,MAAM;AAW5C,SAAS,gBAAgB,OAAwC;AAC/D,SACE,SAAS,QACT,OAAO,UAAU,YACjB,UAAU,KAAK,CAAC,QAAQ,OAAQ,KAAiC;AAErE;AAGO,SAAS,UACd,QACA,QAC2B;A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F;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1,15 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
- var _chunk7BC3AN7Rcjs = require('./chunk-7BC3AN7R.cjs');
6
- require('./chunk-RPL2IFWK.cjs');
7
- require('./chunk-H2PVWCWC.cjs');
8
- require('./chunk-JP36TLL4.cjs');
9
- require('./chunk-CGY7JU4Y.cjs');
10
-
11
-
12
-
13
-
14
- exports.closePgBoss = _chunk7BC3AN7Rcjs.closePgBoss; exports.initPgBoss = _chunk7BC3AN7Rcjs.initPgBoss; exports.pgBossAdmin = _chunk7BC3AN7Rcjs.pgBossAdmin;
15
- //# sourceMappingURL=pgboss-backend-UXQ3O2WT.cjs.map