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.
- package/dist/auth/index.cjs +7 -6
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +3 -1
- package/dist/auth/index.d.ts +3 -1
- package/dist/auth/index.js +5 -5
- package/dist/{chunk-73XJUT2S.js → chunk-2IDRC7RK.js} +163 -5
- package/dist/chunk-2IDRC7RK.js.map +1 -0
- package/dist/{chunk-QDEDOHP7.js → chunk-336IU55W.js} +9 -42
- package/dist/chunk-336IU55W.js.map +1 -0
- package/dist/{chunk-R52CUEGT.js → chunk-3SWI46YK.js} +2 -2
- package/dist/{chunk-7KO4DJRJ.cjs → chunk-6WTMRZS7.cjs} +14 -14
- package/dist/{chunk-7KO4DJRJ.cjs.map → chunk-6WTMRZS7.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-CGY7JU4Y.cjs +8 -0
- package/dist/chunk-CGY7JU4Y.cjs.map +1 -0
- package/dist/chunk-DGYPIIJE.cjs +845 -0
- package/dist/chunk-DGYPIIJE.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-YK4ZM3CA.cjs → chunk-DTMDJGRW.cjs} +15 -15
- package/dist/{chunk-YK4ZM3CA.cjs.map → chunk-DTMDJGRW.cjs.map} +1 -1
- package/dist/{chunk-R4XO4SVM.js → chunk-EJDZZ4KX.js} +4 -4
- package/dist/{chunk-NKLOE4AK.cjs → chunk-GWMW6XY7.cjs} +20 -53
- package/dist/chunk-GWMW6XY7.cjs.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-KFVFP2Q7.cjs → chunk-IEF6AEK3.cjs} +70 -55
- package/dist/chunk-IEF6AEK3.cjs.map +1 -0
- package/dist/{chunk-PGJQK36V.js → chunk-JBOMTZT5.js} +7 -5
- package/dist/{chunk-PGJQK36V.js.map → chunk-JBOMTZT5.js.map} +1 -1
- package/dist/chunk-LECHRAU3.js +845 -0
- package/dist/chunk-LECHRAU3.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-NI2BNGGV.js → chunk-O2E7H2XA.js} +2 -2
- package/dist/{chunk-ATVD2HGC.js → chunk-OM2XJJWX.js} +4 -4
- package/dist/{chunk-DUADUR6R.cjs → chunk-QSIP7YLW.cjs} +172 -14
- package/dist/chunk-QSIP7YLW.cjs.map +1 -0
- package/dist/{chunk-7KC2H76D.js → chunk-R6GPQZLI.js} +62 -47
- package/dist/chunk-R6GPQZLI.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-HBCY7ILD.cjs → chunk-SOU3PBJC.cjs} +97 -95
- package/dist/chunk-SOU3PBJC.cjs.map +1 -0
- package/dist/{chunk-DCJOWFVD.cjs → chunk-WHBSVYUY.cjs} +3 -3
- package/dist/{chunk-DCJOWFVD.cjs.map → chunk-WHBSVYUY.cjs.map} +1 -1
- package/dist/chunk-XPY5TQDK.js +42 -0
- package/dist/chunk-XPY5TQDK.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 +8 -1
- package/dist/docs/api-reference/openapi.md +36 -0
- package/dist/docs/api-reference/testing.md +28 -0
- package/dist/docs/api-reference/websockets.md +23 -0
- package/dist/docs/cli/add.md +2 -2
- package/dist/docs/core-concepts/clustering.md +2 -0
- package/dist/docs/core-concepts/file-based-routing.md +4 -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/feature-matrix.md +9 -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/openapi.md +57 -0
- package/dist/docs/guides/testing.md +31 -0
- package/dist/docs/guides/validation.md +2 -0
- package/dist/docs/guides/websockets.md +60 -0
- package/dist/docs/index.md +4 -1
- package/dist/docs/skills/SKILL.md +8 -2
- package/dist/docs/skills/api-surface.md +30 -4
- package/dist/docs/skills/auth-internals.md +14 -1
- package/dist/docs/skills/pre-flight.md +8 -0
- package/dist/docs/skills/routing-rules.md +5 -1
- package/dist/docs/skills/what-not-to-invent.md +11 -1
- package/dist/docs/versioning.md +1 -1
- package/dist/index.cjs +100 -267
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -3
- package/dist/index.d.ts +28 -3
- package/dist/index.js +52 -221
- package/dist/index.js.map +1 -1
- package/dist/openapi-cjs.cjs +5 -0
- package/dist/pgboss-backend-PQW6I3VF.js +14 -0
- package/dist/pgboss-backend-QVXISTLP.cjs +15 -0
- package/dist/pgboss-backend-QVXISTLP.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 +3 -1
- package/dist/tasks/index.d.ts +3 -1
- package/dist/tasks/index.js +1 -1
- package/dist/testing-cjs.cjs +5 -0
- package/dist/testing.cjs +65 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +30 -0
- package/dist/testing.d.ts +30 -0
- package/dist/testing.js +64 -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-D3QmZgeX.d.cts} +88 -2
- package/dist/{types-Bnxvj3l0.d.cts → types-D3QmZgeX.d.ts} +88 -2
- package/package.json +11 -4
- 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-RAB44UGX.js.map → chunk-B6MB6HEG.js.map} +0 -0
- /package/dist/{chunk-R4XO4SVM.js.map → chunk-EJDZZ4KX.js.map} +0 -0
- /package/dist/{chunk-NI2BNGGV.js.map → chunk-O2E7H2XA.js.map} +0 -0
- /package/dist/{chunk-ATVD2HGC.js.map → chunk-OM2XJJWX.js.map} +0 -0
- /package/dist/{pgboss-backend-FW42SBSM.js.map → pgboss-backend-PQW6I3VF.js.map} +0 -0
package/dist/tasks/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/tasks/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,oXAAC","file":"/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/tasks/index.cjs"}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/tasks/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,oXAAC","file":"/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/tasks/index.cjs"}
|
package/dist/tasks/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { T as TaskOptions, a as TaskDefinition } from '../types-
|
|
1
|
+
import { T as TaskOptions, a as TaskDefinition } from '../types-D3QmZgeX.cjs';
|
|
2
2
|
import 'express';
|
|
3
|
+
import 'node:http';
|
|
4
|
+
import 'ws';
|
|
3
5
|
|
|
4
6
|
declare const taskRegistry: Map<string, TaskDefinition<unknown>>;
|
|
5
7
|
type HandlerFn<T> = (payload: T) => Promise<void>;
|
package/dist/tasks/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { T as TaskOptions, a as TaskDefinition } from '../types-
|
|
1
|
+
import { T as TaskOptions, a as TaskDefinition } from '../types-D3QmZgeX.js';
|
|
2
2
|
import 'express';
|
|
3
|
+
import 'node:http';
|
|
4
|
+
import 'ws';
|
|
3
5
|
|
|
4
6
|
declare const taskRegistry: Map<string, TaskDefinition<unknown>>;
|
|
5
7
|
type HandlerFn<T> = (payload: T) => Promise<void>;
|
package/dist/tasks/index.js
CHANGED
package/dist/testing.cjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkDGYPIIJEcjs = require('./chunk-DGYPIIJE.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkIEF6AEK3cjs = require('./chunk-IEF6AEK3.cjs');
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _chunkWHBSVYUYcjs = require('./chunk-WHBSVYUY.cjs');
|
|
13
|
+
require('./chunk-DTMDJGRW.cjs');
|
|
14
|
+
require('./chunk-AGOYTFRO.cjs');
|
|
15
|
+
require('./chunk-RPL2IFWK.cjs');
|
|
16
|
+
require('./chunk-H2PVWCWC.cjs');
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
var _chunkQSIP7YLWcjs = require('./chunk-QSIP7YLW.cjs');
|
|
20
|
+
require('./chunk-CGY7JU4Y.cjs');
|
|
21
|
+
|
|
22
|
+
// src/testing.ts
|
|
23
|
+
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
24
|
+
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
25
|
+
var _express = require('express'); var _express2 = _interopRequireDefault(_express);
|
|
26
|
+
async function createTestApp(options) {
|
|
27
|
+
if (typeof options.apiDir !== "string" || !options.apiDir.trim()) {
|
|
28
|
+
throw new Error("[EFC] createTestApp requires a nonempty apiDir");
|
|
29
|
+
}
|
|
30
|
+
const apiDir = _path2.default.resolve(options.apiDir);
|
|
31
|
+
if (!_fs2.default.existsSync(apiDir) || !_fs2.default.statSync(apiDir).isDirectory()) {
|
|
32
|
+
throw new Error(`[EFC] createTestApp apiDir is not a directory: ${apiDir}`);
|
|
33
|
+
}
|
|
34
|
+
_chunkQSIP7YLWcjs.configureLogger.call(void 0, false);
|
|
35
|
+
if (options.auth) {
|
|
36
|
+
_chunkIEF6AEK3cjs.configureAuth.call(void 0, {
|
|
37
|
+
secret: options.auth.secret,
|
|
38
|
+
strategy: _nullishCoalesce(options.auth.strategy, () => ( "http-only")),
|
|
39
|
+
expiresIn: _nullishCoalesce(options.auth.expiresIn, () => ( "1h")),
|
|
40
|
+
...options.auth.cookieDomain !== void 0 && { cookieDomain: options.auth.cookieDomain }
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const app = _chunkDGYPIIJEcjs.createHttpApp.call(void 0, {
|
|
44
|
+
cors: false,
|
|
45
|
+
...options.globalMiddlewares !== void 0 && {
|
|
46
|
+
globalMiddlewares: options.globalMiddlewares
|
|
47
|
+
},
|
|
48
|
+
...options.requestTimeout !== void 0 && { requestTimeout: options.requestTimeout },
|
|
49
|
+
...options.trustProxy !== void 0 && { trustProxy: options.trustProxy }
|
|
50
|
+
});
|
|
51
|
+
const router = _express2.default.Router();
|
|
52
|
+
const mounted = await _chunkDGYPIIJEcjs.mountRoutes.call(void 0, router, _chunkWHBSVYUYcjs.scanDir.call(void 0, apiDir));
|
|
53
|
+
if (options.openapi)
|
|
54
|
+
await _chunkDGYPIIJEcjs.mountOpenAPI.call(void 0, app, mounted, {
|
|
55
|
+
...options.openapi === true ? {} : options.openapi,
|
|
56
|
+
basePath: _nullishCoalesce(options.basePath, () => ( "/v1/api"))
|
|
57
|
+
});
|
|
58
|
+
app.use(_nullishCoalesce(options.basePath, () => ( "/v1/api")), router);
|
|
59
|
+
_chunkDGYPIIJEcjs.mountErrorHandler.call(void 0, app, options.onError);
|
|
60
|
+
return app;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
exports.createTestApp = createTestApp;
|
|
65
|
+
//# sourceMappingURL=testing.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/testing.cjs","../src/testing.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACrBA,wEAAiB;AACjB,gEAAe;AACf,oFAAoB;AAgCpB,MAAA,SAAsB,aAAA,CAAc,OAAA,EAAmD;AACrF,EAAA,GAAA,CAAI,OAAO,OAAA,CAAQ,OAAA,IAAW,SAAA,GAAY,CAAC,OAAA,CAAQ,MAAA,CAAO,IAAA,CAAK,CAAA,EAAG;AAChE,IAAA,MAAM,IAAI,KAAA,CAAM,gDAAgD,CAAA;AAAA,EAClE;AACA,EAAA,MAAM,OAAA,EAAS,cAAA,CAAK,OAAA,CAAQ,OAAA,CAAQ,MAAM,CAAA;AAC1C,EAAA,GAAA,CAAI,CAAC,YAAA,CAAG,UAAA,CAAW,MAAM,EAAA,GAAK,CAAC,YAAA,CAAG,QAAA,CAAS,MAAM,CAAA,CAAE,WAAA,CAAY,CAAA,EAAG;AAChE,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,+CAAA,EAAkD,MAAM,CAAA,CAAA;AAC1E,EAAA;AACqB,EAAA;AACH,EAAA;AACF,IAAA;AACS,MAAA;AACc,MAAA;AACE,MAAA;AACkC,MAAA;AACxE,IAAA;AACH,EAAA;AAC0B,EAAA;AAClB,IAAA;AACyC,IAAA;AAClB,MAAA;AAC7B,IAAA;AACsE,IAAA;AACG,IAAA;AAC1E,EAAA;AAC6B,EAAA;AAC2B,EAAA;AAC7C,EAAA;AACuB,IAAA;AACa,MAAA;AACd,MAAA;AAC/B,IAAA;AAC0C,EAAA;AACP,EAAA;AAC/B,EAAA;AACT;ADR6E;AACA;AACA","file":"/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/testing.cjs","sourcesContent":[null,"import path from 'node:path';\nimport fs from 'node:fs';\nimport express from 'express';\nimport type { AuthStrategy, EFCConfig } from './types.js';\nimport { configureAuth } from './auth/index.js';\nimport { configureLogger } from './logger.js';\nimport { createHttpApp, mountErrorHandler } from './http-app.js';\nimport { scanDir } from './router/scan.js';\nimport { mountRoutes } from './router/mount.js';\nimport { mountOpenAPI } from './openapi.js';\n\nexport interface TestAppOptions {\n openapi?: EFCConfig['openapi'];\n /** Explicit fixtures/app API directory. Does not change cwd or ignite() conventions. */\n apiDir: string;\n basePath?: string;\n globalMiddlewares?: express.RequestHandler[];\n requestTimeout?: number;\n trustProxy?: EFCConfig['trustProxy'];\n onError?: express.ErrorRequestHandler;\n /** Auth is process-wide, as in ignite(); use one configuration per test process. */\n auth?: {\n secret: string;\n strategy?: AuthStrategy;\n expiresIn?: string;\n cookieDomain?: string;\n };\n}\n\n/**\n * Mounts real file-based routes on an Express app for supertest (or another HTTP\n * harness). Does not listen, fork workers, start services, or install signal handlers.\n * Models and task queues need separately configured integration fixtures.\n */\nexport async function createTestApp(options: TestAppOptions): Promise<express.Express> {\n if (typeof options.apiDir !== 'string' || !options.apiDir.trim()) {\n throw new Error('[EFC] createTestApp requires a nonempty apiDir');\n }\n const apiDir = path.resolve(options.apiDir);\n if (!fs.existsSync(apiDir) || !fs.statSync(apiDir).isDirectory()) {\n throw new Error(`[EFC] createTestApp apiDir is not a directory: ${apiDir}`);\n }\n configureLogger(false);\n if (options.auth) {\n configureAuth({\n secret: options.auth.secret,\n strategy: options.auth.strategy ?? 'http-only',\n expiresIn: options.auth.expiresIn ?? '1h',\n ...(options.auth.cookieDomain !== undefined && { cookieDomain: options.auth.cookieDomain }),\n });\n }\n const app = createHttpApp({\n cors: false,\n ...(options.globalMiddlewares !== undefined && {\n globalMiddlewares: options.globalMiddlewares,\n }),\n ...(options.requestTimeout !== undefined && { requestTimeout: options.requestTimeout }),\n ...(options.trustProxy !== undefined && { trustProxy: options.trustProxy }),\n });\n const router = express.Router();\n const mounted = await mountRoutes(router, scanDir(apiDir));\n if (options.openapi)\n await mountOpenAPI(app, mounted, {\n ...(options.openapi === true ? {} : options.openapi),\n basePath: options.basePath ?? '/v1/api',\n });\n app.use(options.basePath ?? '/v1/api', router);\n mountErrorHandler(app, options.onError);\n return app;\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { E as EFCConfig, A as AuthStrategy } from './types-D3QmZgeX.cjs';
|
|
3
|
+
import 'node:http';
|
|
4
|
+
import 'ws';
|
|
5
|
+
|
|
6
|
+
interface TestAppOptions {
|
|
7
|
+
openapi?: EFCConfig['openapi'];
|
|
8
|
+
/** Explicit fixtures/app API directory. Does not change cwd or ignite() conventions. */
|
|
9
|
+
apiDir: string;
|
|
10
|
+
basePath?: string;
|
|
11
|
+
globalMiddlewares?: express.RequestHandler[];
|
|
12
|
+
requestTimeout?: number;
|
|
13
|
+
trustProxy?: EFCConfig['trustProxy'];
|
|
14
|
+
onError?: express.ErrorRequestHandler;
|
|
15
|
+
/** Auth is process-wide, as in ignite(); use one configuration per test process. */
|
|
16
|
+
auth?: {
|
|
17
|
+
secret: string;
|
|
18
|
+
strategy?: AuthStrategy;
|
|
19
|
+
expiresIn?: string;
|
|
20
|
+
cookieDomain?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Mounts real file-based routes on an Express app for supertest (or another HTTP
|
|
25
|
+
* harness). Does not listen, fork workers, start services, or install signal handlers.
|
|
26
|
+
* Models and task queues need separately configured integration fixtures.
|
|
27
|
+
*/
|
|
28
|
+
declare function createTestApp(options: TestAppOptions): Promise<express.Express>;
|
|
29
|
+
|
|
30
|
+
export { type TestAppOptions, createTestApp };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import { E as EFCConfig, A as AuthStrategy } from './types-D3QmZgeX.js';
|
|
3
|
+
import 'node:http';
|
|
4
|
+
import 'ws';
|
|
5
|
+
|
|
6
|
+
interface TestAppOptions {
|
|
7
|
+
openapi?: EFCConfig['openapi'];
|
|
8
|
+
/** Explicit fixtures/app API directory. Does not change cwd or ignite() conventions. */
|
|
9
|
+
apiDir: string;
|
|
10
|
+
basePath?: string;
|
|
11
|
+
globalMiddlewares?: express.RequestHandler[];
|
|
12
|
+
requestTimeout?: number;
|
|
13
|
+
trustProxy?: EFCConfig['trustProxy'];
|
|
14
|
+
onError?: express.ErrorRequestHandler;
|
|
15
|
+
/** Auth is process-wide, as in ignite(); use one configuration per test process. */
|
|
16
|
+
auth?: {
|
|
17
|
+
secret: string;
|
|
18
|
+
strategy?: AuthStrategy;
|
|
19
|
+
expiresIn?: string;
|
|
20
|
+
cookieDomain?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Mounts real file-based routes on an Express app for supertest (or another HTTP
|
|
25
|
+
* harness). Does not listen, fork workers, start services, or install signal handlers.
|
|
26
|
+
* Models and task queues need separately configured integration fixtures.
|
|
27
|
+
*/
|
|
28
|
+
declare function createTestApp(options: TestAppOptions): Promise<express.Express>;
|
|
29
|
+
|
|
30
|
+
export { type TestAppOptions, createTestApp };
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createHttpApp,
|
|
3
|
+
mountErrorHandler,
|
|
4
|
+
mountOpenAPI,
|
|
5
|
+
mountRoutes
|
|
6
|
+
} from "./chunk-LECHRAU3.js";
|
|
7
|
+
import {
|
|
8
|
+
configureAuth
|
|
9
|
+
} from "./chunk-R6GPQZLI.js";
|
|
10
|
+
import {
|
|
11
|
+
scanDir
|
|
12
|
+
} from "./chunk-O2E7H2XA.js";
|
|
13
|
+
import "./chunk-OM2XJJWX.js";
|
|
14
|
+
import "./chunk-XPY5TQDK.js";
|
|
15
|
+
import "./chunk-3SWI46YK.js";
|
|
16
|
+
import "./chunk-B6MB6HEG.js";
|
|
17
|
+
import {
|
|
18
|
+
configureLogger
|
|
19
|
+
} from "./chunk-2IDRC7RK.js";
|
|
20
|
+
|
|
21
|
+
// src/testing.ts
|
|
22
|
+
import path from "path";
|
|
23
|
+
import fs from "fs";
|
|
24
|
+
import express from "express";
|
|
25
|
+
async function createTestApp(options) {
|
|
26
|
+
if (typeof options.apiDir !== "string" || !options.apiDir.trim()) {
|
|
27
|
+
throw new Error("[EFC] createTestApp requires a nonempty apiDir");
|
|
28
|
+
}
|
|
29
|
+
const apiDir = path.resolve(options.apiDir);
|
|
30
|
+
if (!fs.existsSync(apiDir) || !fs.statSync(apiDir).isDirectory()) {
|
|
31
|
+
throw new Error(`[EFC] createTestApp apiDir is not a directory: ${apiDir}`);
|
|
32
|
+
}
|
|
33
|
+
configureLogger(false);
|
|
34
|
+
if (options.auth) {
|
|
35
|
+
configureAuth({
|
|
36
|
+
secret: options.auth.secret,
|
|
37
|
+
strategy: options.auth.strategy ?? "http-only",
|
|
38
|
+
expiresIn: options.auth.expiresIn ?? "1h",
|
|
39
|
+
...options.auth.cookieDomain !== void 0 && { cookieDomain: options.auth.cookieDomain }
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const app = createHttpApp({
|
|
43
|
+
cors: false,
|
|
44
|
+
...options.globalMiddlewares !== void 0 && {
|
|
45
|
+
globalMiddlewares: options.globalMiddlewares
|
|
46
|
+
},
|
|
47
|
+
...options.requestTimeout !== void 0 && { requestTimeout: options.requestTimeout },
|
|
48
|
+
...options.trustProxy !== void 0 && { trustProxy: options.trustProxy }
|
|
49
|
+
});
|
|
50
|
+
const router = express.Router();
|
|
51
|
+
const mounted = await mountRoutes(router, scanDir(apiDir));
|
|
52
|
+
if (options.openapi)
|
|
53
|
+
await mountOpenAPI(app, mounted, {
|
|
54
|
+
...options.openapi === true ? {} : options.openapi,
|
|
55
|
+
basePath: options.basePath ?? "/v1/api"
|
|
56
|
+
});
|
|
57
|
+
app.use(options.basePath ?? "/v1/api", router);
|
|
58
|
+
mountErrorHandler(app, options.onError);
|
|
59
|
+
return app;
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
createTestApp
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import path from 'node:path';\nimport fs from 'node:fs';\nimport express from 'express';\nimport type { AuthStrategy, EFCConfig } from './types.js';\nimport { configureAuth } from './auth/index.js';\nimport { configureLogger } from './logger.js';\nimport { createHttpApp, mountErrorHandler } from './http-app.js';\nimport { scanDir } from './router/scan.js';\nimport { mountRoutes } from './router/mount.js';\nimport { mountOpenAPI } from './openapi.js';\n\nexport interface TestAppOptions {\n openapi?: EFCConfig['openapi'];\n /** Explicit fixtures/app API directory. Does not change cwd or ignite() conventions. */\n apiDir: string;\n basePath?: string;\n globalMiddlewares?: express.RequestHandler[];\n requestTimeout?: number;\n trustProxy?: EFCConfig['trustProxy'];\n onError?: express.ErrorRequestHandler;\n /** Auth is process-wide, as in ignite(); use one configuration per test process. */\n auth?: {\n secret: string;\n strategy?: AuthStrategy;\n expiresIn?: string;\n cookieDomain?: string;\n };\n}\n\n/**\n * Mounts real file-based routes on an Express app for supertest (or another HTTP\n * harness). Does not listen, fork workers, start services, or install signal handlers.\n * Models and task queues need separately configured integration fixtures.\n */\nexport async function createTestApp(options: TestAppOptions): Promise<express.Express> {\n if (typeof options.apiDir !== 'string' || !options.apiDir.trim()) {\n throw new Error('[EFC] createTestApp requires a nonempty apiDir');\n }\n const apiDir = path.resolve(options.apiDir);\n if (!fs.existsSync(apiDir) || !fs.statSync(apiDir).isDirectory()) {\n throw new Error(`[EFC] createTestApp apiDir is not a directory: ${apiDir}`);\n }\n configureLogger(false);\n if (options.auth) {\n configureAuth({\n secret: options.auth.secret,\n strategy: options.auth.strategy ?? 'http-only',\n expiresIn: options.auth.expiresIn ?? '1h',\n ...(options.auth.cookieDomain !== undefined && { cookieDomain: options.auth.cookieDomain }),\n });\n }\n const app = createHttpApp({\n cors: false,\n ...(options.globalMiddlewares !== undefined && {\n globalMiddlewares: options.globalMiddlewares,\n }),\n ...(options.requestTimeout !== undefined && { requestTimeout: options.requestTimeout }),\n ...(options.trustProxy !== undefined && { trustProxy: options.trustProxy }),\n });\n const router = express.Router();\n const mounted = await mountRoutes(router, scanDir(apiDir));\n if (options.openapi)\n await mountOpenAPI(app, mounted, {\n ...(options.openapi === true ? {} : options.openapi),\n basePath: options.basePath ?? '/v1/api',\n });\n app.use(options.basePath ?? '/v1/api', router);\n mountErrorHandler(app, options.onError);\n return app;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAO,aAAa;AAgCpB,eAAsB,cAAc,SAAmD;AACrF,MAAI,OAAO,QAAQ,WAAW,YAAY,CAAC,QAAQ,OAAO,KAAK,GAAG;AAChE,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AACA,QAAM,SAAS,KAAK,QAAQ,QAAQ,MAAM;AAC1C,MAAI,CAAC,GAAG,WAAW,MAAM,KAAK,CAAC,GAAG,SAAS,MAAM,EAAE,YAAY,GAAG;AAChE,UAAM,IAAI,MAAM,kDAAkD,MAAM,EAAE;AAAA,EAC5E;AACA,kBAAgB,KAAK;AACrB,MAAI,QAAQ,MAAM;AAChB,kBAAc;AAAA,MACZ,QAAQ,QAAQ,KAAK;AAAA,MACrB,UAAU,QAAQ,KAAK,YAAY;AAAA,MACnC,WAAW,QAAQ,KAAK,aAAa;AAAA,MACrC,GAAI,QAAQ,KAAK,iBAAiB,UAAa,EAAE,cAAc,QAAQ,KAAK,aAAa;AAAA,IAC3F,CAAC;AAAA,EACH;AACA,QAAM,MAAM,cAAc;AAAA,IACxB,MAAM;AAAA,IACN,GAAI,QAAQ,sBAAsB,UAAa;AAAA,MAC7C,mBAAmB,QAAQ;AAAA,IAC7B;AAAA,IACA,GAAI,QAAQ,mBAAmB,UAAa,EAAE,gBAAgB,QAAQ,eAAe;AAAA,IACrF,GAAI,QAAQ,eAAe,UAAa,EAAE,YAAY,QAAQ,WAAW;AAAA,EAC3E,CAAC;AACD,QAAM,SAAS,QAAQ,OAAO;AAC9B,QAAM,UAAU,MAAM,YAAY,QAAQ,QAAQ,MAAM,CAAC;AACzD,MAAI,QAAQ;AACV,UAAM,aAAa,KAAK,SAAS;AAAA,MAC/B,GAAI,QAAQ,YAAY,OAAO,CAAC,IAAI,QAAQ;AAAA,MAC5C,UAAU,QAAQ,YAAY;AAAA,IAChC,CAAC;AACH,MAAI,IAAI,QAAQ,YAAY,WAAW,MAAM;AAC7C,oBAAkB,KAAK,QAAQ,OAAO;AACtC,SAAO;AACT;","names":[]}
|
package/dist/thread-runner.cjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var _chunkRPL2IFWKcjs = require('./chunk-RPL2IFWK.cjs');
|
|
4
|
+
require('./chunk-H2PVWCWC.cjs');
|
|
5
|
+
require('./chunk-CGY7JU4Y.cjs');
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
exports.runInThread =
|
|
8
|
+
exports.runInThread = _chunkRPL2IFWKcjs.runInThread;
|
|
8
9
|
//# sourceMappingURL=thread-runner.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/thread-runner.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,oDAAC","file":"/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/thread-runner.cjs"}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/thread-runner.cjs"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACF,oDAAC","file":"/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/thread-runner.cjs"}
|
package/dist/thread-runner.js
CHANGED
|
@@ -1,4 +1,60 @@
|
|
|
1
|
-
import { RequestHandler, ErrorRequestHandler } from 'express';
|
|
1
|
+
import { Request, Express, RequestHandler, ErrorRequestHandler } from 'express';
|
|
2
|
+
import http from 'node:http';
|
|
3
|
+
import { WebSocket, WebSocketServer } from 'ws';
|
|
4
|
+
|
|
5
|
+
type JSONSchema = boolean | Record<string, unknown>;
|
|
6
|
+
interface OpenAPIOptions {
|
|
7
|
+
/** Absolute static URL for the document. Default /openapi.json. */
|
|
8
|
+
path?: string;
|
|
9
|
+
info?: {
|
|
10
|
+
title: string;
|
|
11
|
+
version: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
};
|
|
14
|
+
servers?: Array<{
|
|
15
|
+
url: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
}>;
|
|
18
|
+
components?: Record<string, unknown>;
|
|
19
|
+
/** Adapter for validators without Standard JSON Schema support. */
|
|
20
|
+
schemaToJSONSchema?: (validator: Validator) => JSONSchema | Promise<JSONSchema>;
|
|
21
|
+
}
|
|
22
|
+
interface OpenAPIDocument {
|
|
23
|
+
openapi: '3.1.0';
|
|
24
|
+
info: {
|
|
25
|
+
title: string;
|
|
26
|
+
version: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
};
|
|
29
|
+
paths: Record<string, Record<string, unknown>>;
|
|
30
|
+
components: Record<string, unknown> & {
|
|
31
|
+
schemas: Record<string, JSONSchema>;
|
|
32
|
+
};
|
|
33
|
+
servers?: Array<{
|
|
34
|
+
url: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
/** Generate a document from the same mounted route exports used by the HTTP router. */
|
|
39
|
+
declare function generateOpenAPI(input: MountedRoute[] | string, options?: OpenAPIOptions & {
|
|
40
|
+
basePath?: string;
|
|
41
|
+
}): Promise<OpenAPIDocument>;
|
|
42
|
+
|
|
43
|
+
type WebSocketHandler = (socket: WebSocket, request: Request) => void | Promise<void>;
|
|
44
|
+
interface WebSocketOptions {
|
|
45
|
+
/** Default 1 MiB. Compression is disabled. */
|
|
46
|
+
maxPayload?: number;
|
|
47
|
+
/** Browser origins; default is same-origin. Clients without Origin are allowed. */
|
|
48
|
+
origins?: string[];
|
|
49
|
+
/** Default 30 seconds; 0 disables heartbeat. */
|
|
50
|
+
heartbeatIntervalMs?: number;
|
|
51
|
+
/** Default 10 seconds to finish upgrade middleware. */
|
|
52
|
+
handshakeTimeoutMs?: number;
|
|
53
|
+
}
|
|
54
|
+
/** Attach upgrade handling to an EFC HTTP app/server (also useful with createTestApp). */
|
|
55
|
+
declare function attachWebSockets(server: http.Server, app: Express, options?: WebSocketOptions): WebSocketServer;
|
|
56
|
+
/** Close upgraded sockets with 1001, then terminate peers that do not acknowledge. */
|
|
57
|
+
declare function closeWebSockets(server: http.Server, timeoutMs?: number): Promise<void>;
|
|
2
58
|
|
|
3
59
|
type DatabaseEngine = 'mongodb' | 'postgresql';
|
|
4
60
|
/**
|
|
@@ -67,6 +123,10 @@ interface LoggingConfig {
|
|
|
67
123
|
queries?: boolean | QueryLogConfig;
|
|
68
124
|
}
|
|
69
125
|
interface QueryLogConfig {
|
|
126
|
+
/** Opt-in per-process query counters/latencies; default off, at most 1000 model/op entries. */
|
|
127
|
+
metrics?: boolean | {
|
|
128
|
+
maxEntries?: number;
|
|
129
|
+
};
|
|
70
130
|
/** Log every operation (info), not just slow ones. Default: false (true with `queries: true`). */
|
|
71
131
|
all?: boolean;
|
|
72
132
|
/** Operations taking at least this long are logged as warnings. Default: 500. */
|
|
@@ -86,6 +146,10 @@ interface CorsConfig {
|
|
|
86
146
|
}
|
|
87
147
|
/** Connection pool settings, per worker process (`databasePool` in `ignite()`). */
|
|
88
148
|
interface DatabasePoolConfig {
|
|
149
|
+
/** PostgreSQL model statements: default true (100 names per connection); false or { max: 0 } for incompatible poolers. */
|
|
150
|
+
preparedStatements?: boolean | {
|
|
151
|
+
max?: number;
|
|
152
|
+
};
|
|
89
153
|
/** Most open connections. Default: 10 (pg) / 100 (MongoDB). */
|
|
90
154
|
max?: number;
|
|
91
155
|
/** Close a connection idle this long, in ms. Default: 10000 (pg) / never (MongoDB). */
|
|
@@ -94,6 +158,10 @@ interface DatabasePoolConfig {
|
|
|
94
158
|
connectionTimeoutMs?: number;
|
|
95
159
|
}
|
|
96
160
|
interface EFCConfig {
|
|
161
|
+
/** Opt-in OpenAPI 3.1 document; default URL /openapi.json. */
|
|
162
|
+
openapi?: boolean | OpenAPIOptions;
|
|
163
|
+
/** WS exports enable WebSockets by default; false disables upgrades. */
|
|
164
|
+
websocket?: false | WebSocketOptions;
|
|
97
165
|
port?: number;
|
|
98
166
|
/**
|
|
99
167
|
* Express's `trust proxy`: set it when the app runs behind a proxy or load balancer
|
|
@@ -147,6 +215,13 @@ interface RouteEntry {
|
|
|
147
215
|
pattern?: RegExp;
|
|
148
216
|
}
|
|
149
217
|
interface RouteMethodMeta {
|
|
218
|
+
summary?: string;
|
|
219
|
+
tags?: string[];
|
|
220
|
+
operationId?: string;
|
|
221
|
+
/** Explicit OpenAPI operation fields. hidden omits this operation from docs. */
|
|
222
|
+
openapi?: Record<string, unknown> & {
|
|
223
|
+
hidden?: boolean;
|
|
224
|
+
};
|
|
150
225
|
description?: string;
|
|
151
226
|
request?: {
|
|
152
227
|
headers?: Record<string, string>;
|
|
@@ -171,6 +246,11 @@ type RouteMeta = Partial<Record<string, RouteMethodMeta>>;
|
|
|
171
246
|
type Validator = {
|
|
172
247
|
readonly '~standard': {
|
|
173
248
|
validate: (value: unknown) => unknown;
|
|
249
|
+
jsonSchema?: {
|
|
250
|
+
input: (options: {
|
|
251
|
+
target: 'draft-2020-12';
|
|
252
|
+
}) => unknown;
|
|
253
|
+
};
|
|
174
254
|
};
|
|
175
255
|
} | {
|
|
176
256
|
safeParse: (value: unknown) => unknown;
|
|
@@ -192,6 +272,12 @@ interface ValidationIssue {
|
|
|
192
272
|
path: string;
|
|
193
273
|
message: string;
|
|
194
274
|
}
|
|
275
|
+
interface MountedRoute extends RouteEntry {
|
|
276
|
+
methods: string[];
|
|
277
|
+
schema?: RouteSchema;
|
|
278
|
+
websocket?: boolean;
|
|
279
|
+
meta?: RouteMeta;
|
|
280
|
+
}
|
|
195
281
|
interface TaskOptions {
|
|
196
282
|
thread?: boolean;
|
|
197
283
|
retries?: number;
|
|
@@ -643,4 +729,4 @@ interface MigrationContext {
|
|
|
643
729
|
engine: DatabaseEngine;
|
|
644
730
|
}
|
|
645
731
|
|
|
646
|
-
export type
|
|
732
|
+
export { closeWebSockets as $, type AuthStrategy as A, type RouteSchema as B, type CollectionSchema as C, type DatabaseEngine as D, type EFCConfig as E, type FieldDefinition as F, type GeoPoint as G, type ScalarKeys as H, type InferSchema as I, type JSONSchema as J, type SchemaField as K, type LoggingConfig as L, type ModelSchema as M, type TableFieldDefinition as N, type OpenAPIDocument as O, type TableRelation as P, type QueryLogConfig as Q, type RouteEntry as R, type Simplify as S, type TaskOptions as T, type TableSchemaField as U, type Update as V, type ValidationIssue as W, type Validator as X, type WebSocketHandler as Y, type WebSocketOptions as Z, attachWebSockets as _, type TaskDefinition as a, generateOpenAPI as a0, type InferCreateInput as b, type ModelOptions as c, type InferredModel as d, type TableSchema as e, type TableOptions as f, type SortDirection as g, type InferRecord as h, type CacheConfig as i, type CollectionFieldDefinition as j, type CorsConfig as k, type DatabasePoolConfig as l, type DefaultOperator as m, type Filter as n, type FilterOperators as o, type FindOptions as p, type IndexDefinition as q, type InferCreate as r, type MigrationContext as s, type ModelCRUD as t, type ModelQueryOptions as u, type ModelRecord as v, type OpenAPIOptions as w, type RequestSchema as x, type RouteMeta as y, type RouteMethodMeta as z };
|
|
@@ -1,4 +1,60 @@
|
|
|
1
|
-
import { RequestHandler, ErrorRequestHandler } from 'express';
|
|
1
|
+
import { Request, Express, RequestHandler, ErrorRequestHandler } from 'express';
|
|
2
|
+
import http from 'node:http';
|
|
3
|
+
import { WebSocket, WebSocketServer } from 'ws';
|
|
4
|
+
|
|
5
|
+
type JSONSchema = boolean | Record<string, unknown>;
|
|
6
|
+
interface OpenAPIOptions {
|
|
7
|
+
/** Absolute static URL for the document. Default /openapi.json. */
|
|
8
|
+
path?: string;
|
|
9
|
+
info?: {
|
|
10
|
+
title: string;
|
|
11
|
+
version: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
};
|
|
14
|
+
servers?: Array<{
|
|
15
|
+
url: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
}>;
|
|
18
|
+
components?: Record<string, unknown>;
|
|
19
|
+
/** Adapter for validators without Standard JSON Schema support. */
|
|
20
|
+
schemaToJSONSchema?: (validator: Validator) => JSONSchema | Promise<JSONSchema>;
|
|
21
|
+
}
|
|
22
|
+
interface OpenAPIDocument {
|
|
23
|
+
openapi: '3.1.0';
|
|
24
|
+
info: {
|
|
25
|
+
title: string;
|
|
26
|
+
version: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
};
|
|
29
|
+
paths: Record<string, Record<string, unknown>>;
|
|
30
|
+
components: Record<string, unknown> & {
|
|
31
|
+
schemas: Record<string, JSONSchema>;
|
|
32
|
+
};
|
|
33
|
+
servers?: Array<{
|
|
34
|
+
url: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
/** Generate a document from the same mounted route exports used by the HTTP router. */
|
|
39
|
+
declare function generateOpenAPI(input: MountedRoute[] | string, options?: OpenAPIOptions & {
|
|
40
|
+
basePath?: string;
|
|
41
|
+
}): Promise<OpenAPIDocument>;
|
|
42
|
+
|
|
43
|
+
type WebSocketHandler = (socket: WebSocket, request: Request) => void | Promise<void>;
|
|
44
|
+
interface WebSocketOptions {
|
|
45
|
+
/** Default 1 MiB. Compression is disabled. */
|
|
46
|
+
maxPayload?: number;
|
|
47
|
+
/** Browser origins; default is same-origin. Clients without Origin are allowed. */
|
|
48
|
+
origins?: string[];
|
|
49
|
+
/** Default 30 seconds; 0 disables heartbeat. */
|
|
50
|
+
heartbeatIntervalMs?: number;
|
|
51
|
+
/** Default 10 seconds to finish upgrade middleware. */
|
|
52
|
+
handshakeTimeoutMs?: number;
|
|
53
|
+
}
|
|
54
|
+
/** Attach upgrade handling to an EFC HTTP app/server (also useful with createTestApp). */
|
|
55
|
+
declare function attachWebSockets(server: http.Server, app: Express, options?: WebSocketOptions): WebSocketServer;
|
|
56
|
+
/** Close upgraded sockets with 1001, then terminate peers that do not acknowledge. */
|
|
57
|
+
declare function closeWebSockets(server: http.Server, timeoutMs?: number): Promise<void>;
|
|
2
58
|
|
|
3
59
|
type DatabaseEngine = 'mongodb' | 'postgresql';
|
|
4
60
|
/**
|
|
@@ -67,6 +123,10 @@ interface LoggingConfig {
|
|
|
67
123
|
queries?: boolean | QueryLogConfig;
|
|
68
124
|
}
|
|
69
125
|
interface QueryLogConfig {
|
|
126
|
+
/** Opt-in per-process query counters/latencies; default off, at most 1000 model/op entries. */
|
|
127
|
+
metrics?: boolean | {
|
|
128
|
+
maxEntries?: number;
|
|
129
|
+
};
|
|
70
130
|
/** Log every operation (info), not just slow ones. Default: false (true with `queries: true`). */
|
|
71
131
|
all?: boolean;
|
|
72
132
|
/** Operations taking at least this long are logged as warnings. Default: 500. */
|
|
@@ -86,6 +146,10 @@ interface CorsConfig {
|
|
|
86
146
|
}
|
|
87
147
|
/** Connection pool settings, per worker process (`databasePool` in `ignite()`). */
|
|
88
148
|
interface DatabasePoolConfig {
|
|
149
|
+
/** PostgreSQL model statements: default true (100 names per connection); false or { max: 0 } for incompatible poolers. */
|
|
150
|
+
preparedStatements?: boolean | {
|
|
151
|
+
max?: number;
|
|
152
|
+
};
|
|
89
153
|
/** Most open connections. Default: 10 (pg) / 100 (MongoDB). */
|
|
90
154
|
max?: number;
|
|
91
155
|
/** Close a connection idle this long, in ms. Default: 10000 (pg) / never (MongoDB). */
|
|
@@ -94,6 +158,10 @@ interface DatabasePoolConfig {
|
|
|
94
158
|
connectionTimeoutMs?: number;
|
|
95
159
|
}
|
|
96
160
|
interface EFCConfig {
|
|
161
|
+
/** Opt-in OpenAPI 3.1 document; default URL /openapi.json. */
|
|
162
|
+
openapi?: boolean | OpenAPIOptions;
|
|
163
|
+
/** WS exports enable WebSockets by default; false disables upgrades. */
|
|
164
|
+
websocket?: false | WebSocketOptions;
|
|
97
165
|
port?: number;
|
|
98
166
|
/**
|
|
99
167
|
* Express's `trust proxy`: set it when the app runs behind a proxy or load balancer
|
|
@@ -147,6 +215,13 @@ interface RouteEntry {
|
|
|
147
215
|
pattern?: RegExp;
|
|
148
216
|
}
|
|
149
217
|
interface RouteMethodMeta {
|
|
218
|
+
summary?: string;
|
|
219
|
+
tags?: string[];
|
|
220
|
+
operationId?: string;
|
|
221
|
+
/** Explicit OpenAPI operation fields. hidden omits this operation from docs. */
|
|
222
|
+
openapi?: Record<string, unknown> & {
|
|
223
|
+
hidden?: boolean;
|
|
224
|
+
};
|
|
150
225
|
description?: string;
|
|
151
226
|
request?: {
|
|
152
227
|
headers?: Record<string, string>;
|
|
@@ -171,6 +246,11 @@ type RouteMeta = Partial<Record<string, RouteMethodMeta>>;
|
|
|
171
246
|
type Validator = {
|
|
172
247
|
readonly '~standard': {
|
|
173
248
|
validate: (value: unknown) => unknown;
|
|
249
|
+
jsonSchema?: {
|
|
250
|
+
input: (options: {
|
|
251
|
+
target: 'draft-2020-12';
|
|
252
|
+
}) => unknown;
|
|
253
|
+
};
|
|
174
254
|
};
|
|
175
255
|
} | {
|
|
176
256
|
safeParse: (value: unknown) => unknown;
|
|
@@ -192,6 +272,12 @@ interface ValidationIssue {
|
|
|
192
272
|
path: string;
|
|
193
273
|
message: string;
|
|
194
274
|
}
|
|
275
|
+
interface MountedRoute extends RouteEntry {
|
|
276
|
+
methods: string[];
|
|
277
|
+
schema?: RouteSchema;
|
|
278
|
+
websocket?: boolean;
|
|
279
|
+
meta?: RouteMeta;
|
|
280
|
+
}
|
|
195
281
|
interface TaskOptions {
|
|
196
282
|
thread?: boolean;
|
|
197
283
|
retries?: number;
|
|
@@ -643,4 +729,4 @@ interface MigrationContext {
|
|
|
643
729
|
engine: DatabaseEngine;
|
|
644
730
|
}
|
|
645
731
|
|
|
646
|
-
export type
|
|
732
|
+
export { closeWebSockets as $, type AuthStrategy as A, type RouteSchema as B, type CollectionSchema as C, type DatabaseEngine as D, type EFCConfig as E, type FieldDefinition as F, type GeoPoint as G, type ScalarKeys as H, type InferSchema as I, type JSONSchema as J, type SchemaField as K, type LoggingConfig as L, type ModelSchema as M, type TableFieldDefinition as N, type OpenAPIDocument as O, type TableRelation as P, type QueryLogConfig as Q, type RouteEntry as R, type Simplify as S, type TaskOptions as T, type TableSchemaField as U, type Update as V, type ValidationIssue as W, type Validator as X, type WebSocketHandler as Y, type WebSocketOptions as Z, attachWebSockets as _, type TaskDefinition as a, generateOpenAPI as a0, type InferCreateInput as b, type ModelOptions as c, type InferredModel as d, type TableSchema as e, type TableOptions as f, type SortDirection as g, type InferRecord as h, type CacheConfig as i, type CollectionFieldDefinition as j, type CorsConfig as k, type DatabasePoolConfig as l, type DefaultOperator as m, type Filter as n, type FilterOperators as o, type FindOptions as p, type IndexDefinition as q, type InferCreate as r, type MigrationContext as s, type ModelCRUD as t, type ModelQueryOptions as u, type ModelRecord as v, type OpenAPIOptions as w, type RequestSchema as x, type RouteMeta as y, type RouteMethodMeta as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-file-cluster",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "Enterprise-grade, zero-boilerplate backend framework with file-based routing and multi-core clustering",
|
|
5
5
|
"homepage": "https://efc.prashantadhikari7.com.np/",
|
|
6
6
|
"repository": {
|
|
@@ -33,6 +33,11 @@
|
|
|
33
33
|
"import": "./dist/auth/index.js",
|
|
34
34
|
"require": "./dist/auth/index.cjs"
|
|
35
35
|
},
|
|
36
|
+
"./testing": {
|
|
37
|
+
"types": "./dist/testing.d.ts",
|
|
38
|
+
"import": "./dist/testing.js",
|
|
39
|
+
"require": "./dist/testing-cjs.cjs"
|
|
40
|
+
},
|
|
36
41
|
"./tasks": {
|
|
37
42
|
"types": "./dist/tasks/index.d.ts",
|
|
38
43
|
"import": "./dist/tasks/index.js",
|
|
@@ -45,13 +50,15 @@
|
|
|
45
50
|
"typecheck": "tsc --noEmit"
|
|
46
51
|
},
|
|
47
52
|
"dependencies": {
|
|
53
|
+
"@types/ws": "^8.18.2",
|
|
48
54
|
"chokidar": "^4.0.0",
|
|
49
55
|
"commander": "^12.0.0",
|
|
50
56
|
"cookie-parser": "^1.4.6",
|
|
51
57
|
"cors": "^2.8.6",
|
|
52
58
|
"jose": "^6.2.3",
|
|
53
59
|
"picocolors": "^1.1.1",
|
|
54
|
-
"pino": "^10.4.0"
|
|
60
|
+
"pino": "^10.4.0",
|
|
61
|
+
"ws": "^8.22.0"
|
|
55
62
|
},
|
|
56
63
|
"devDependencies": {
|
|
57
64
|
"@types/cookie-parser": "^1.4.7",
|
|
@@ -76,10 +83,10 @@
|
|
|
76
83
|
"bullmq": ">=5.0.0",
|
|
77
84
|
"drizzle-orm": ">=0.40.0",
|
|
78
85
|
"express": "^4.19.0",
|
|
86
|
+
"ioredis": "^5.0.0",
|
|
79
87
|
"mongoose": "^8.0.0 || ^9.0.0",
|
|
80
88
|
"pg": "^8.11.0",
|
|
81
|
-
"pg-boss": ">=12.0.0"
|
|
82
|
-
"ioredis": "^5.0.0"
|
|
89
|
+
"pg-boss": ">=12.0.0"
|
|
83
90
|
},
|
|
84
91
|
"peerDependenciesMeta": {
|
|
85
92
|
"bullmq": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/chunk-4DOHQU6I.cjs","../src/db/codegen.ts"],"names":["flat"],"mappings":"AAAA;ACEA,gEAAe;AACf,wEAAiB;AAcjB,IAAM,MAAA,EAAQ,4BAAA;AACd,IAAM,IAAA,EAAM,CAAC,CAAA,EAAA,GACX,KAAA,CAAM,IAAA,CAAK,CAAC,EAAA,EAAI,EAAA,EAAI,CAAA,CAAA,EAAI,CAAA,CAAE,OAAA,CAAQ,KAAA,EAAO,MAAM,CAAA,CAAE,OAAA,CAAQ,IAAA,EAAM,KAAK,CAAC,CAAA,CAAA,CAAA;AAEvE,SAAS,OAAA,CAAQ,CAAA,EAAY,MAAA,EAAwB;AACnD,EAAA,GAAA,CAAI,OAAO,EAAA,IAAM,QAAA,EAAU,OAAO,CAAA,CAAA,EAAI,CAAA,CAAE,OAAA,CAAQ,KAAA,EAAO,MAAM,CAAA,CAAE,OAAA,CAAQ,IAAA,EAAM,KAAK,CAAC,CAAA,CAAA,CAAA;AACnF,EAAA,GAAA,CAAI,OAAO,EAAA,IAAM,SAAA,GAAY,OAAO,EAAA,IAAM,SAAA,EAAW,OAAO,MAAA,CAAO,CAAC,CAAA;AACpE,EAAA,GAAA,CAAI,OAAO,EAAA,IAAM,QAAA,EAAU,OAAO,CAAA,EAAA;AACX,EAAA;AACD,EAAA;AACO,IAAA;AACK,IAAA;AACHA,IAAAA;AAEgB;AAAuB;AACtE,EAAA;AAC6D,EAAA;AAC5B,EAAA;AACE,EAAA;AACJ,EAAA;AACxB,EAAA;AAAuC;AAAmE;AACnH;AAEsD;AACrB,EAAA;AAA0B;AAEhD,EAAA;AAEc,EAAA;AACS,IAAA;AAEL,MAAA;AACzB,IAAA;AACF,EAAA;AACkC,EAAA;AAA4C,EAAA;AACrD,EAAA;AACH,EAAA;AAAA;AAES;AAClB,GAAA;AAAA;AAEP;AACE,IAAA;AAAA;AAAA;AAGV;AAM4C;AACX,EAAA;AACG,EAAA;AACC,EAAA;AAAU;AAC5B,EAAA;AAAA;AAEkB;AAAmC;AAAA;AAAA;AAAA;AAK5C;AAA4B;AAAA;AAAA;AAIxD;AAME;AAE8B,EAAA;AACC,EAAA;AACJ,EAAA;AACA,EAAA;AACoB,EAAA;AAChB,IAAA;AACC,IAAA;AACzB,IAAA;AACwB,MAAA;AACb,MAAA;AAChB,IAAA;AACF,EAAA;AACiC,EAAA;AACjC,EAAA;AACc,IAAA;AACZ,IAAA;AAC0B,MAAA;AACnB,MAAA;AACwB,MAAA;AAC/B,IAAA;AACF,EAAA;AAC0B,EAAA;AAC5B;AAMW;AAKyB;AAChB,EAAA;AACiB,EAAA;AACrC;AAE4C;AAEG;AACb,EAAA;AACI,EAAA;AACH,EAAA;AAC1B,EAAA;AACT;AAE6C;AACb,EAAA;AACI,EAAA;AACpB,EAAA;AAChB;ADrCqC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/express-file-cluster/express-file-cluster/packages/core/dist/chunk-4DOHQU6I.cjs","sourcesContent":[null,"// Writes model files from a plain description — shared by `efc db pull` (introspected\n// PostgreSQL → defineTable, sampled MongoDB → defineCollection) and `efc import-prisma`.\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nexport interface ModelSource {\n name: string;\n /** Field name → definition, in column order. */\n fields: [string, unknown][];\n /** defineTable options (empty keys are left out). */\n options: Record<string, unknown>;\n /** Comments put above the model — what couldn't be carried over. */\n notes: string[];\n /** Default `defineTable`. */\n api?: 'defineTable' | 'defineCollection';\n}\n\nconst IDENT = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\nconst key = (k: string) =>\n IDENT.test(k) ? k : `'${k.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`;\n\nfunction literal(v: unknown, indent: string): string {\n if (typeof v === 'string') return `'${v.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`;\n if (typeof v === 'number' || typeof v === 'boolean') return String(v);\n if (typeof v === 'bigint') return `${v}n`;\n if (v === null) return 'null';\n if (Array.isArray(v)) {\n const items = v.map((x) => literal(x, indent));\n const flat = `[${items.join(', ')}]`;\n return flat.length <= 80 && !flat.includes('\\n')\n ? flat\n : `[\\n${items.map((i) => `${indent} ${i},`).join('\\n')}\\n${indent}]`;\n }\n const entries = Object.entries(v as Record<string, unknown>).filter(([, x]) => x !== undefined);\n if (entries.length === 0) return '{}';\n const flat = `{ ${entries.map(([k, x]) => `${key(k)}: ${literal(x, indent)}`).join(', ')} }`;\n if (flat.length <= 80 && !flat.includes('\\n')) return flat;\n return `{\\n${entries.map(([k, x]) => `${indent} ${key(k)}: ${literal(x, `${indent} `)},`).join('\\n')}\\n${indent}}`;\n}\n\nexport function modelFile(model: ModelSource): string {\n const notes = model.notes.map((n) => `// ${n}\\n`).join('');\n const fields = model.fields\n .map(([name, def]) => ` ${key(name)}: ${literal(def, ' ')},`)\n .join('\\n');\n const options = Object.fromEntries(\n Object.entries(model.options).filter(\n ([, v]) =>\n v !== undefined && !(typeof v === 'object' && v !== null && Object.keys(v).length === 0),\n ),\n );\n const opts = Object.keys(options).length ? `\\n ${literal(options, ' ')},` : '';\n const api = model.api ?? 'defineTable';\n return `import { ${api} } from 'express-file-cluster';\n\n${notes}export const ${model.name} = ${api}(\n '${model.name}',\n {\n${fields}\n },${opts}\n);\n`;\n}\n\n/**\n * The barrel that registers every model and, in TypeScript, declares `Tables` for\n * `include` (defineTable only — `tables: false` for collections).\n */\nexport function modelIndex(names: string[], typescript: boolean, tables = true): string {\n const sorted = [...names].sort();\n const exports = sorted.map((n) => `export { ${n} } from './${n}.js';`).join('\\n');\n if (!typescript || !tables) return `${exports}\\n`;\n return `${exports}\n\n${sorted.map((n) => `import type { ${n} } from './${n}.js';`).join('\\n')}\n\n// Types \\`include\\` results: relations name models by string, this maps the names to models.\ndeclare module 'express-file-cluster' {\n interface Tables {\n${sorted.map((n) => ` ${n}: typeof ${n};`).join('\\n')}\n }\n}\n`;\n}\n\n/** Writes the models (and index) into `dir`; existing files are kept unless `force`. */\nexport function writeModels(\n dir: string,\n models: ModelSource[],\n opts: { typescript: boolean; force?: boolean },\n): { written: string[]; skipped: string[] } {\n const ext = opts.typescript ? 'ts' : 'js';\n fs.mkdirSync(dir, { recursive: true });\n const written: string[] = [];\n const skipped: string[] = [];\n const put = (file: string, content: string) => {\n const p = path.join(dir, file);\n if (fs.existsSync(p) && !opts.force) skipped.push(p);\n else {\n fs.writeFileSync(p, content);\n written.push(p);\n }\n };\n for (const m of models) put(`${m.name}.${ext}`, modelFile(m));\n put(\n `index.${ext}`,\n modelIndex(\n models.map((m) => m.name),\n opts.typescript,\n models.some((m) => (m.api ?? 'defineTable') === 'defineTable'),\n ),\n );\n return { written, skipped };\n}\n\n// ── Naming ───────────────────────────────────────────────────────────────────\n\nexport const pascal = (s: string) =>\n s\n .split(/[^A-Za-z0-9]+|_/)\n .filter(Boolean)\n .map((w) => w[0]!.toUpperCase() + w.slice(1))\n .join('');\n\nexport const camel = (s: string) => {\n const p = pascal(s);\n return p ? p[0]!.toLowerCase() + p.slice(1) : s;\n};\n\nexport const lcFirst = (s: string) => s[0]!.toLowerCase() + s.slice(1);\n\nexport function singular(word: string): string {\n if (/[^aeiou]ies$/i.test(word)) return word.slice(0, -3) + 'y';\n if (/(s|x|z|ch|sh)es$/i.test(word)) return word.slice(0, -2);\n if (/[^s]s$/i.test(word)) return word.slice(0, -1);\n return word;\n}\n\nexport function plural(word: string): string {\n if (/[^aeiou]y$/i.test(word)) return word.slice(0, -1) + 'ies';\n if (/(s|x|z|ch|sh)$/i.test(word)) return word + 'es';\n return word + 's';\n}\n"]}
|