express-file-cluster 0.9.2 → 0.9.6

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 (136) hide show
  1. package/dist/auth/index.cjs +4 -5
  2. package/dist/auth/index.cjs.map +1 -1
  3. package/dist/auth/index.d.cts +7 -2
  4. package/dist/auth/index.d.ts +7 -2
  5. package/dist/auth/index.js +3 -4
  6. package/dist/{chunk-ATL4GYFU.js → chunk-2SETEVMO.js} +10 -8
  7. package/dist/{chunk-ATL4GYFU.js.map → chunk-2SETEVMO.js.map} +1 -1
  8. package/dist/{chunk-UBQYQPBU.js → chunk-45BWAR6P.js} +2 -2
  9. package/dist/{chunk-TYR2GZZE.cjs → chunk-6KHBJOLB.cjs} +13 -8
  10. package/dist/chunk-6KHBJOLB.cjs.map +1 -0
  11. package/dist/chunk-73XJUT2S.js +366 -0
  12. package/dist/chunk-73XJUT2S.js.map +1 -0
  13. package/dist/{chunk-UTM4PEVG.js → chunk-7ZESZG3J.js} +8 -3
  14. package/dist/chunk-7ZESZG3J.js.map +1 -0
  15. package/dist/{chunk-R34R7QPD.cjs → chunk-DCJOWFVD.cjs} +3 -3
  16. package/dist/{chunk-R34R7QPD.cjs.map → chunk-DCJOWFVD.cjs.map} +1 -1
  17. package/dist/chunk-DUADUR6R.cjs +366 -0
  18. package/dist/chunk-DUADUR6R.cjs.map +1 -0
  19. package/dist/{chunk-T4OHFU5T.cjs → chunk-FMA76PRH.cjs} +8 -8
  20. package/dist/{chunk-T4OHFU5T.cjs.map → chunk-FMA76PRH.cjs.map} +1 -1
  21. package/dist/{chunk-RS4MXCPW.js → chunk-NI2BNGGV.js} +2 -2
  22. package/dist/{chunk-RRQ2RK5M.js → chunk-OFA7OGN5.js} +26 -6
  23. package/dist/chunk-OFA7OGN5.js.map +1 -0
  24. package/dist/{chunk-ANUSWEAP.cjs → chunk-RGT4ZVHL.cjs} +17 -15
  25. package/dist/chunk-RGT4ZVHL.cjs.map +1 -0
  26. package/dist/{chunk-X2US4RAM.cjs → chunk-TYCYYLLM.cjs} +11 -13
  27. package/dist/chunk-TYCYYLLM.cjs.map +1 -0
  28. package/dist/{chunk-QKQZF573.js → chunk-ULWNHN6P.js} +4 -6
  29. package/dist/{chunk-QKQZF573.js.map → chunk-ULWNHN6P.js.map} +1 -1
  30. package/dist/{chunk-RTF7PHS2.cjs → chunk-VWSUQKCJ.cjs} +116 -96
  31. package/dist/chunk-VWSUQKCJ.cjs.map +1 -0
  32. package/dist/cli/db-runner.cjs +20 -22
  33. package/dist/cli/db-runner.cjs.map +1 -1
  34. package/dist/cli/db-runner.js +4 -6
  35. package/dist/cli/db-runner.js.map +1 -1
  36. package/dist/cli/index.cjs +95 -58
  37. package/dist/cli/index.cjs.map +1 -1
  38. package/dist/cli/index.js +126 -89
  39. package/dist/cli/index.js.map +1 -1
  40. package/dist/docs/api-reference/auth.md +10 -8
  41. package/dist/docs/api-reference/ignite.md +13 -3
  42. package/dist/docs/cli/add.md +1 -1
  43. package/dist/docs/cli/start.md +1 -1
  44. package/dist/docs/contributing/index.md +1 -1
  45. package/dist/docs/getting-started/index.md +1 -1
  46. package/dist/docs/guides/authentication.md +34 -24
  47. package/dist/docs/guides/database.md +12 -0
  48. package/dist/docs/guides/deployment.md +1 -1
  49. package/dist/docs/guides/environment-variables.md +1 -1
  50. package/dist/docs/guides/oauth.md +15 -1
  51. package/dist/docs/index.md +2 -1
  52. package/dist/docs/skills/SKILL.md +2 -2
  53. package/dist/docs/skills/api-surface.md +5 -4
  54. package/dist/docs/skills/auth-internals.md +3 -3
  55. package/dist/docs/versioning.md +42 -0
  56. package/dist/index.cjs +73 -49
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.d.cts +2 -2
  59. package/dist/index.d.ts +2 -2
  60. package/dist/index.js +36 -12
  61. package/dist/index.js.map +1 -1
  62. package/dist/pgboss-backend-DSO3QTNK.cjs +14 -0
  63. package/dist/{pgboss-backend-TCHI7CHM.cjs.map → pgboss-backend-DSO3QTNK.cjs.map} +1 -1
  64. package/dist/{pgboss-backend-QKBXVJ6B.js → pgboss-backend-I6DFUNRM.js} +3 -3
  65. package/dist/registry/index.json +22 -3
  66. package/dist/registry/js-mongo/account-security.json +1 -1
  67. package/dist/registry/js-mongo/admin-users.json +1 -1
  68. package/dist/registry/js-mongo/auth.json +1 -1
  69. package/dist/registry/js-mongo/auth@apple.json +1 -1
  70. package/dist/registry/js-mongo/auth@google.json +1 -1
  71. package/dist/registry/js-mongo/email-verification.json +1 -1
  72. package/dist/registry/js-mongo/forgot-password.json +1 -1
  73. package/dist/registry/js-mongo/user-profile.json +1 -1
  74. package/dist/registry/js-pg-model/account-security.json +1 -1
  75. package/dist/registry/js-pg-model/admin-users.json +1 -1
  76. package/dist/registry/js-pg-model/auth.json +1 -1
  77. package/dist/registry/js-pg-model/auth@apple.json +1 -1
  78. package/dist/registry/js-pg-model/auth@google.json +1 -1
  79. package/dist/registry/js-pg-model/email-verification.json +1 -1
  80. package/dist/registry/js-pg-model/forgot-password.json +1 -1
  81. package/dist/registry/js-pg-model/user-profile.json +1 -1
  82. package/dist/registry/js-pg-table/account-security.json +1 -1
  83. package/dist/registry/js-pg-table/admin-users.json +1 -1
  84. package/dist/registry/js-pg-table/auth.json +1 -1
  85. package/dist/registry/js-pg-table/auth@apple.json +1 -1
  86. package/dist/registry/js-pg-table/auth@google.json +1 -1
  87. package/dist/registry/js-pg-table/email-verification.json +1 -1
  88. package/dist/registry/js-pg-table/forgot-password.json +1 -1
  89. package/dist/registry/js-pg-table/user-profile.json +1 -1
  90. package/dist/registry/ts-mongo/account-security.json +1 -1
  91. package/dist/registry/ts-mongo/admin-users.json +1 -1
  92. package/dist/registry/ts-mongo/auth.json +1 -1
  93. package/dist/registry/ts-mongo/auth@apple.json +1 -1
  94. package/dist/registry/ts-mongo/auth@google.json +1 -1
  95. package/dist/registry/ts-mongo/email-verification.json +1 -1
  96. package/dist/registry/ts-mongo/forgot-password.json +1 -1
  97. package/dist/registry/ts-mongo/user-profile.json +1 -1
  98. package/dist/registry/ts-pg-model/account-security.json +1 -1
  99. package/dist/registry/ts-pg-model/admin-users.json +1 -1
  100. package/dist/registry/ts-pg-model/auth.json +1 -1
  101. package/dist/registry/ts-pg-model/auth@apple.json +1 -1
  102. package/dist/registry/ts-pg-model/auth@google.json +1 -1
  103. package/dist/registry/ts-pg-model/email-verification.json +1 -1
  104. package/dist/registry/ts-pg-model/forgot-password.json +1 -1
  105. package/dist/registry/ts-pg-model/user-profile.json +1 -1
  106. package/dist/registry/ts-pg-table/account-security.json +1 -1
  107. package/dist/registry/ts-pg-table/admin-users.json +1 -1
  108. package/dist/registry/ts-pg-table/auth.json +1 -1
  109. package/dist/registry/ts-pg-table/auth@apple.json +1 -1
  110. package/dist/registry/ts-pg-table/auth@google.json +1 -1
  111. package/dist/registry/ts-pg-table/email-verification.json +1 -1
  112. package/dist/registry/ts-pg-table/forgot-password.json +1 -1
  113. package/dist/registry/ts-pg-table/user-profile.json +1 -1
  114. package/dist/tasks/index.d.cts +1 -1
  115. package/dist/tasks/index.d.ts +1 -1
  116. package/dist/{types-BY-ObnZH.d.cts → types-DAsBKVM-.d.cts} +7 -1
  117. package/dist/{types-BY-ObnZH.d.ts → types-DAsBKVM-.d.ts} +7 -1
  118. package/package.json +1 -1
  119. package/dist/chunk-277BSYVH.js +0 -127
  120. package/dist/chunk-277BSYVH.js.map +0 -1
  121. package/dist/chunk-ANUSWEAP.cjs.map +0 -1
  122. package/dist/chunk-HXV543HZ.js +0 -177
  123. package/dist/chunk-HXV543HZ.js.map +0 -1
  124. package/dist/chunk-RRQ2RK5M.js.map +0 -1
  125. package/dist/chunk-RTF7PHS2.cjs.map +0 -1
  126. package/dist/chunk-TYR2GZZE.cjs.map +0 -1
  127. package/dist/chunk-UTM4PEVG.js.map +0 -1
  128. package/dist/chunk-VQSWSYK6.cjs +0 -177
  129. package/dist/chunk-VQSWSYK6.cjs.map +0 -1
  130. package/dist/chunk-X2US4RAM.cjs.map +0 -1
  131. package/dist/chunk-YL37D6KM.cjs +0 -127
  132. package/dist/chunk-YL37D6KM.cjs.map +0 -1
  133. package/dist/pgboss-backend-TCHI7CHM.cjs +0 -14
  134. /package/dist/{chunk-UBQYQPBU.js.map → chunk-45BWAR6P.js.map} +0 -0
  135. /package/dist/{chunk-RS4MXCPW.js.map → chunk-NI2BNGGV.js.map} +0 -0
  136. /package/dist/{pgboss-backend-QKBXVJ6B.js.map → pgboss-backend-I6DFUNRM.js.map} +0 -0
package/dist/cli/index.js CHANGED
@@ -1,20 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  scanDir
4
- } from "../chunk-RS4MXCPW.js";
4
+ } from "../chunk-NI2BNGGV.js";
5
5
  import {
6
6
  parseRedisUrl
7
- } from "../chunk-UBQYQPBU.js";
7
+ } from "../chunk-45BWAR6P.js";
8
8
  import {
9
9
  writeModels
10
10
  } from "../chunk-BBSZLGZW.js";
11
11
  import {
12
12
  tableNameFor
13
- } from "../chunk-QKQZF573.js";
14
- import "../chunk-HXV543HZ.js";
13
+ } from "../chunk-ULWNHN6P.js";
15
14
  import "../chunk-LJNSJFOL.js";
16
15
  import "../chunk-HBYSKULC.js";
17
- import "../chunk-277BSYVH.js";
16
+ import "../chunk-73XJUT2S.js";
18
17
 
19
18
  // src/cli/index.ts
20
19
  import fs10 from "fs";
@@ -26,9 +25,33 @@ import { Command as Command10 } from "commander";
26
25
  // src/cli/commands/start.ts
27
26
  import { Command } from "commander";
28
27
  import { spawn } from "child_process";
29
- import path from "path";
30
- import fs from "fs";
28
+ import path2 from "path";
29
+ import fs2 from "fs";
31
30
  import pc from "picocolors";
31
+
32
+ // src/cli/env.ts
33
+ import fs from "fs";
34
+ import path from "path";
35
+ function readEnvFile(cwd = process.cwd()) {
36
+ const envPath = path.join(cwd, ".env");
37
+ if (!fs.existsSync(envPath)) return {};
38
+ const vars = {};
39
+ for (const line of fs.readFileSync(envPath, "utf8").split("\n")) {
40
+ const trimmed = line.trim();
41
+ if (!trimmed || trimmed.startsWith("#")) continue;
42
+ const eq = trimmed.indexOf("=");
43
+ if (eq === -1) continue;
44
+ const key = trimmed.slice(0, eq).trim();
45
+ const raw = trimmed.slice(eq + 1).trim();
46
+ vars[key] = raw.replace(/^(['"])(.*)\1$/, "$2");
47
+ }
48
+ return vars;
49
+ }
50
+ function envVar(key, cwd = process.cwd()) {
51
+ return process.env[key] || readEnvFile(cwd)[key] || void 0;
52
+ }
53
+
54
+ // src/cli/commands/start.ts
32
55
  function startCommand() {
33
56
  const cmd = new Command("start");
34
57
  cmd.argument("<mode>", "dev | prod").description("Start the EFC server").action((mode) => {
@@ -44,9 +67,9 @@ function startCommand() {
44
67
  return cmd;
45
68
  }
46
69
  function writeDevEnvPreload(cwd) {
47
- const cacheDir = path.join(cwd, "node_modules", ".cache", "efc");
48
- fs.mkdirSync(cacheDir, { recursive: true });
49
- const preloadPath = path.join(cacheDir, "dev-env-preload.mjs");
70
+ const cacheDir = path2.join(cwd, "node_modules", ".cache", "efc");
71
+ fs2.mkdirSync(cacheDir, { recursive: true });
72
+ const preloadPath = path2.join(cacheDir, "dev-env-preload.mjs");
50
73
  const source = `// Auto-generated by \`efc start dev\` \u2014 re-reads .env fresh on every restart
51
74
  // so tsx watch restarts always pick up the latest .env, instead of reusing a stale snapshot.
52
75
  import fs from 'node:fs';
@@ -75,7 +98,7 @@ if (fs.existsSync(envFile)) {
75
98
  }
76
99
  process.env[MARKER] = injectedNow.join(',');
77
100
  `;
78
- fs.writeFileSync(preloadPath, source);
101
+ fs2.writeFileSync(preloadPath, source);
79
102
  return preloadPath;
80
103
  }
81
104
  function startDev() {
@@ -95,9 +118,9 @@ function startDev() {
95
118
  function findTsx() {
96
119
  let dir = cwd;
97
120
  while (true) {
98
- const candidate = path.join(dir, "node_modules", ".bin", "tsx");
99
- if (fs.existsSync(candidate)) return candidate;
100
- const parent = path.dirname(dir);
121
+ const candidate = path2.join(dir, "node_modules", ".bin", "tsx");
122
+ if (fs2.existsSync(candidate)) return candidate;
123
+ const parent = path2.dirname(dir);
101
124
  if (parent === dir) return void 0;
102
125
  dir = parent;
103
126
  }
@@ -120,7 +143,7 @@ function startDev() {
120
143
  NODE_ENV: "development",
121
144
  NODE_OPTIONS: [process.env["NODE_OPTIONS"], `--import ${preloadPath}`].filter(Boolean).join(" ")
122
145
  };
123
- const child = tsx ? spawn(tsx, ["watch", "--include", "src", entry], { stdio: "inherit", env }) : spawn(process.execPath, ["--watch", "--watch-path", path.join(cwd, "src"), entry], {
146
+ const child = tsx ? spawn(tsx, ["watch", "--include", "src", entry], { stdio: "inherit", env }) : spawn(process.execPath, ["--watch", "--watch-path", path2.join(cwd, "src"), entry], {
124
147
  stdio: "inherit",
125
148
  env
126
149
  });
@@ -135,9 +158,9 @@ function forwardSignals(child) {
135
158
  function startProd() {
136
159
  const cwd = process.cwd();
137
160
  const distEntry = [
138
- path.join(cwd, "dist", "src", "index.js"),
139
- path.join(cwd, "dist", "index.js")
140
- ].find((f) => fs.existsSync(f));
161
+ path2.join(cwd, "dist", "src", "index.js"),
162
+ path2.join(cwd, "dist", "index.js")
163
+ ].find((f) => fs2.existsSync(f));
141
164
  if (!distEntry) {
142
165
  console.error(pc.red("[EFC] dist/src/index.js not found. Run `efc build prod` first."));
143
166
  process.exit(1);
@@ -145,26 +168,26 @@ function startProd() {
145
168
  console.log(pc.cyan("[EFC] Starting production server\u2026"));
146
169
  const child = spawn("node", [distEntry], {
147
170
  stdio: "inherit",
148
- env: { ...process.env, NODE_ENV: "production" }
171
+ env: { ...readEnvFile(cwd), ...process.env, NODE_ENV: "production" }
149
172
  });
150
173
  forwardSignals(child);
151
174
  }
152
175
  function resolveEntry() {
153
176
  const cwd = process.cwd();
154
177
  const candidates = [
155
- path.join(cwd, "src", "index.ts"),
156
- path.join(cwd, "index.ts"),
157
- path.join(cwd, "src", "index.js"),
158
- path.join(cwd, "index.js")
178
+ path2.join(cwd, "src", "index.ts"),
179
+ path2.join(cwd, "index.ts"),
180
+ path2.join(cwd, "src", "index.js"),
181
+ path2.join(cwd, "index.js")
159
182
  ];
160
- return candidates.find((f) => fs.existsSync(f)) ?? null;
183
+ return candidates.find((f) => fs2.existsSync(f)) ?? null;
161
184
  }
162
185
 
163
186
  // src/cli/commands/build.ts
164
187
  import { Command as Command2 } from "commander";
165
188
  import { spawn as spawn2 } from "child_process";
166
- import path2 from "path";
167
- import fs2 from "fs";
189
+ import path3 from "path";
190
+ import fs3 from "fs";
168
191
  import pc2 from "picocolors";
169
192
  function buildCommand() {
170
193
  const cmd = new Command2("build");
@@ -180,19 +203,19 @@ function buildCommand() {
180
203
  function findBin(name) {
181
204
  let dir = process.cwd();
182
205
  while (true) {
183
- const candidate = path2.join(dir, "node_modules", ".bin", name);
184
- if (fs2.existsSync(candidate)) return candidate;
185
- const parent = path2.dirname(dir);
206
+ const candidate = path3.join(dir, "node_modules", ".bin", name);
207
+ if (fs3.existsSync(candidate)) return candidate;
208
+ const parent = path3.dirname(dir);
186
209
  if (parent === dir) return name;
187
210
  dir = parent;
188
211
  }
189
212
  }
190
213
  function writeAppTsupConfig(cwd) {
191
- const pkgPath = path2.join(cwd, "package.json");
192
- const isEsm = fs2.existsSync(pkgPath) && JSON.parse(fs2.readFileSync(pkgPath, "utf8")).type === "module";
214
+ const pkgPath = path3.join(cwd, "package.json");
215
+ const isEsm = fs3.existsSync(pkgPath) && JSON.parse(fs3.readFileSync(pkgPath, "utf8")).type === "module";
193
216
  const entry = [
194
217
  "src/**/*.{ts,mts,js,mjs}",
195
- ...["efc.config.ts", "efc.config.js"].filter((f) => fs2.existsSync(path2.join(cwd, f))),
218
+ ...["efc.config.ts", "efc.config.js"].filter((f) => fs3.existsSync(path3.join(cwd, f))),
196
219
  "!src/**/*.d.ts",
197
220
  "!src/**/*.test.*",
198
221
  "!src/**/__tests__/**"
@@ -212,21 +235,21 @@ function writeAppTsupConfig(cwd) {
212
235
  },
213
236
  };
214
237
  `;
215
- const configPath = path2.join(cwd, "node_modules", ".cache", "efc", "tsup.config.mjs");
216
- fs2.mkdirSync(path2.dirname(configPath), { recursive: true });
217
- fs2.writeFileSync(configPath, config);
238
+ const configPath = path3.join(cwd, "node_modules", ".cache", "efc", "tsup.config.mjs");
239
+ fs3.mkdirSync(path3.dirname(configPath), { recursive: true });
240
+ fs3.writeFileSync(configPath, config);
218
241
  return configPath;
219
242
  }
220
243
  function hasTsupConfig() {
221
244
  const cwd = process.cwd();
222
245
  return ["tsup.config.ts", "tsup.config.js", "tsup.config.mjs", "tsup.config.cjs"].some(
223
- (f) => fs2.existsSync(path2.join(cwd, f))
246
+ (f) => fs3.existsSync(path3.join(cwd, f))
224
247
  );
225
248
  }
226
249
  function findTsConfig() {
227
250
  const cwd = process.cwd();
228
- const tsconfig = path2.join(cwd, "tsconfig.json");
229
- return fs2.existsSync(tsconfig) ? tsconfig : null;
251
+ const tsconfig = path3.join(cwd, "tsconfig.json");
252
+ return fs3.existsSync(tsconfig) ? tsconfig : null;
230
253
  }
231
254
  function buildProd() {
232
255
  console.log(pc2.cyan("[EFC] Building for production\u2026"));
@@ -245,14 +268,14 @@ function buildProd() {
245
268
  });
246
269
  }
247
270
  function copyJsProject(cwd) {
248
- const dist = path2.join(cwd, "dist");
249
- fs2.rmSync(dist, { recursive: true, force: true });
250
- fs2.cpSync(path2.join(cwd, "src"), path2.join(dist, "src"), {
271
+ const dist = path3.join(cwd, "dist");
272
+ fs3.rmSync(dist, { recursive: true, force: true });
273
+ fs3.cpSync(path3.join(cwd, "src"), path3.join(dist, "src"), {
251
274
  recursive: true,
252
275
  filter: (src) => !/(\.test\.[cm]?js$|[\\/]__tests__([\\/]|$))/.test(src)
253
276
  });
254
277
  for (const f of ["efc.config.js", "efc.config.mjs"]) {
255
- if (fs2.existsSync(path2.join(cwd, f))) fs2.copyFileSync(path2.join(cwd, f), path2.join(dist, f));
278
+ if (fs3.existsSync(path3.join(cwd, f))) fs3.copyFileSync(path3.join(cwd, f), path3.join(dist, f));
256
279
  }
257
280
  console.log(pc2.green("[EFC] Build complete \u2192 dist/ (JavaScript copied as-is)"));
258
281
  }
@@ -262,8 +285,8 @@ function transpile() {
262
285
  if (hasTsupConfig()) {
263
286
  tsupArgs = [];
264
287
  } else {
265
- const hasTs = fs2.existsSync(path2.join(cwd, "src", "index.ts"));
266
- if (!hasTs && !fs2.existsSync(path2.join(cwd, "src", "index.js"))) {
288
+ const hasTs = fs3.existsSync(path3.join(cwd, "src", "index.ts"));
289
+ if (!hasTs && !fs3.existsSync(path3.join(cwd, "src", "index.js"))) {
267
290
  console.error(pc2.red("[EFC] Could not find entry point. Expected src/index.ts"));
268
291
  process.exit(1);
269
292
  return;
@@ -308,8 +331,8 @@ function runTests(extraArgs) {
308
331
 
309
332
  // src/cli/commands/generate.ts
310
333
  import { Command as Command4 } from "commander";
311
- import fs3 from "fs";
312
- import path3 from "path";
334
+ import fs4 from "fs";
335
+ import path4 from "path";
313
336
  import pc4 from "picocolors";
314
337
  function generateCommand() {
315
338
  const cmd = new Command4("generate").alias("g").description("Scaffold EFC modules");
@@ -321,18 +344,18 @@ function generateCommand() {
321
344
  return cmd;
322
345
  }
323
346
  function writeFile(filePath, content) {
324
- const dir = path3.dirname(filePath);
325
- fs3.mkdirSync(dir, { recursive: true });
326
- if (fs3.existsSync(filePath)) {
347
+ const dir = path4.dirname(filePath);
348
+ fs4.mkdirSync(dir, { recursive: true });
349
+ if (fs4.existsSync(filePath)) {
327
350
  console.error(pc4.red(`File already exists: ${filePath}`));
328
351
  process.exit(1);
329
352
  }
330
- fs3.writeFileSync(filePath, content, "utf8");
331
- console.log(pc4.green(` created ${path3.relative(process.cwd(), filePath)}`));
353
+ fs4.writeFileSync(filePath, content, "utf8");
354
+ console.log(pc4.green(` created ${path4.relative(process.cwd(), filePath)}`));
332
355
  }
333
356
  function generateRoute(routePath) {
334
357
  const cwd = process.cwd();
335
- const filePath = path3.join(cwd, "src", "api", `${routePath}.ts`);
358
+ const filePath = path4.join(cwd, "src", "api", `${routePath}.ts`);
336
359
  const content = `import type { Request, Response } from 'express';
337
360
  import type { RouteMeta } from 'express-file-cluster';
338
361
 
@@ -383,7 +406,7 @@ export const POST = async (req: Request, res: Response) => {
383
406
  }
384
407
  function generateTask(name) {
385
408
  const cwd = process.cwd();
386
- const filePath = path3.join(cwd, "src", "tasks", `${name}.ts`);
409
+ const filePath = path4.join(cwd, "src", "tasks", `${name}.ts`);
387
410
  const content = `import { defineTask } from 'express-file-cluster/tasks';
388
411
 
389
412
  interface ${name}Payload {
@@ -400,7 +423,7 @@ export default defineTask<${name}Payload>(async (payload) => {
400
423
  }
401
424
  function generateMiddleware(name) {
402
425
  const cwd = process.cwd();
403
- const filePath = path3.join(cwd, "src", "middlewares", `${name}.ts`);
426
+ const filePath = path4.join(cwd, "src", "middlewares", `${name}.ts`);
404
427
  const content = `import type { Request, Response, NextFunction } from 'express';
405
428
 
406
429
  export function ${name}(req: Request, res: Response, next: NextFunction): void {
@@ -411,12 +434,12 @@ export function ${name}(req: Request, res: Response, next: NextFunction): void {
411
434
  writeFile(filePath, content);
412
435
  console.log(pc4.cyan(`[EFC] Middleware scaffolded`));
413
436
  }
414
- var isTypeScript = () => fs3.existsSync(path3.join(process.cwd(), "tsconfig.json"));
437
+ var isTypeScript = () => fs4.existsSync(path4.join(process.cwd(), "tsconfig.json"));
415
438
  var snake = (name) => name.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/[^A-Za-z0-9]+/g, "_").replace(/^_|_$/g, "").toLowerCase();
416
439
  function generateMigration(name) {
417
440
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:T]/g, "").slice(0, 14);
418
441
  const ts = isTypeScript();
419
- const filePath = path3.join(
442
+ const filePath = path4.join(
420
443
  process.cwd(),
421
444
  "src",
422
445
  "migrations",
@@ -444,7 +467,7 @@ export async function down(${ctx})${ret} {
444
467
  }
445
468
  function generateSeed(name) {
446
469
  const ts = isTypeScript();
447
- const filePath = path3.join(process.cwd(), "src", "seeds", `${snake(name)}.${ts ? "ts" : "js"}`);
470
+ const filePath = path4.join(process.cwd(), "src", "seeds", `${snake(name)}.${ts ? "ts" : "js"}`);
448
471
  const typeImport = ts ? "import type { MigrationContext } from 'express-file-cluster';\n" : "";
449
472
  const ctx = ts ? "{ engine }: MigrationContext" : "{ engine }";
450
473
  writeFile(
@@ -466,28 +489,6 @@ import path5 from "path";
466
489
  import fs5 from "fs";
467
490
  import pc6 from "picocolors";
468
491
 
469
- // src/cli/env.ts
470
- import fs4 from "fs";
471
- import path4 from "path";
472
- function readEnvFile(cwd = process.cwd()) {
473
- const envPath = path4.join(cwd, ".env");
474
- if (!fs4.existsSync(envPath)) return {};
475
- const vars = {};
476
- for (const line of fs4.readFileSync(envPath, "utf8").split("\n")) {
477
- const trimmed = line.trim();
478
- if (!trimmed || trimmed.startsWith("#")) continue;
479
- const eq = trimmed.indexOf("=");
480
- if (eq === -1) continue;
481
- const key = trimmed.slice(0, eq).trim();
482
- const raw = trimmed.slice(eq + 1).trim();
483
- vars[key] = raw.replace(/^(['"])(.*)\1$/, "$2");
484
- }
485
- return vars;
486
- }
487
- function envVar(key, cwd = process.cwd()) {
488
- return process.env[key] || readEnvFile(cwd)[key] || void 0;
489
- }
490
-
491
492
  // src/cli/commands/task-admin.ts
492
493
  import { Command as Command5 } from "commander";
493
494
  import pc5 from "picocolors";
@@ -551,7 +552,7 @@ async function connect(opts) {
551
552
  if (backend === "bullmq") return bullmqAdmin(redisUrl ?? "redis://localhost:6379", opts.queue);
552
553
  if (backend === "pg-boss") {
553
554
  if (!databaseUrl) throw new Error("[EFC] pg-boss needs DATABASE_URL (or --database-url)");
554
- const { pgBossAdmin } = await import("../pgboss-backend-QKBXVJ6B.js");
555
+ const { pgBossAdmin } = await import("../pgboss-backend-I6DFUNRM.js");
555
556
  return pgBossAdmin(databaseUrl, opts.queue);
556
557
  }
557
558
  throw new Error(`[EFC] Unknown task backend: ${backend}`);
@@ -1041,7 +1042,7 @@ function planAdd(cwd, registry, names, opts = {}, cfg = readEfcJson(cwd) ?? dete
1041
1042
  const dup = plan.prompts.some(
1042
1043
  (q) => q.name === p.name && JSON.stringify(q.when) === JSON.stringify(p.when)
1043
1044
  );
1044
- if (!dup && sets(p)) plan.prompts.push(p);
1045
+ if (!dup && (p.config !== void 0 || sets(p))) plan.prompts.push(p);
1045
1046
  }
1046
1047
  }
1047
1048
  return plan;
@@ -1087,11 +1088,36 @@ function envFromAnswers(prompts, answers) {
1087
1088
  }
1088
1089
  return env;
1089
1090
  }
1091
+ function configFromAnswers(prompts, answers) {
1092
+ const config = {};
1093
+ for (const p of prompts) {
1094
+ if (p.config !== void 0 && p.name in answers && promptApplies(p, answers)) {
1095
+ config[p.config] = answers[p.name];
1096
+ }
1097
+ }
1098
+ return config;
1099
+ }
1100
+ function setConfigValues(cwd, values) {
1101
+ const entries = Object.entries(values);
1102
+ if (entries.length === 0) return [];
1103
+ const file = ["efc.config.ts", "efc.config.js", "efc.config.mjs"].map((f) => path7.join(cwd, f)).find((f) => fs7.existsSync(f));
1104
+ if (!file) return entries.map(([k, v]) => `efc.config: set \`${k}: '${v}'\``);
1105
+ let text = fs7.readFileSync(file, "utf8");
1106
+ const manual = [];
1107
+ for (const [key, value] of entries) {
1108
+ const re = new RegExp(`^(\\s*)${key}:\\s*(['"])[^'"\\n]*\\2`, "gm");
1109
+ const found = text.match(re)?.length ?? 0;
1110
+ if (found === 1) text = text.replace(re, `$1${key}: '${value}'`);
1111
+ else manual.push(`${path7.basename(file)}: set \`${key}: '${value}'\``);
1112
+ }
1113
+ fs7.writeFileSync(file, text);
1114
+ return manual;
1115
+ }
1090
1116
  function envLine(key, value) {
1091
1117
  if (!/[\s#"'`]/.test(value)) return `${key}=${value}`;
1092
1118
  return value.includes("'") ? `${key}="${value.replace(/"/g, '\\"')}"` : `${key}='${value}'`;
1093
1119
  }
1094
- function applyAdd(cwd, plan, registry, env = {}) {
1120
+ function applyAdd(cwd, plan, registry, env = {}, config = {}) {
1095
1121
  const result = {
1096
1122
  written: [],
1097
1123
  skipped: [],
@@ -1148,6 +1174,7 @@ function applyAdd(cwd, plan, registry, env = {}) {
1148
1174
  plan.env.filter((v) => !readEnvKeys(exampleFile).includes(v.key)).map((v) => `${v.key}=${v.example}`)
1149
1175
  );
1150
1176
  }
1177
+ result.manual.push(...setConfigValues(cwd, config));
1151
1178
  if (cfg.modelApi === "defineTable" && cfg.database === "postgresql" && newModels.length) {
1152
1179
  result.manual.push(...registerModels(cwd, cfg.language, newModels));
1153
1180
  }
@@ -1331,7 +1358,8 @@ import { ${pascal} } from '../../../model/${pascal}.js';
1331
1358
 
1332
1359
  export const POST = async ${typedArgs} => {
1333
1360
  const { name, email, password } = req.body;
1334
- if (!name || !email || !password) {
1361
+ // Strings only: an object such as {"$ne": null} would be read as a filter operator and match any account.
1362
+ if (typeof name !== 'string' || typeof email !== 'string' || typeof password !== 'string' || !name || !email || !password) {
1335
1363
  return res.status(400).json({ error: 'name, email and password are required' });
1336
1364
  }
1337
1365
  const existing = await ${db.findOne(pascal, "{ email }")};
@@ -1353,15 +1381,19 @@ import { ${pascal} } from '../../../model/${pascal}.js';
1353
1381
 
1354
1382
  export const POST = async ${typedArgs} => {
1355
1383
  const { email, password } = req.body;
1356
- if (!email || !password) return res.status(400).json({ error: 'email and password are required' });
1384
+ // Strings only: an object such as {"$ne": null} would be read as a filter operator and match any account.
1385
+ if (typeof email !== 'string' || typeof password !== 'string' || !email || !password) {
1386
+ return res.status(400).json({ error: 'email and password are required' });
1387
+ }
1357
1388
 
1358
1389
  const record = await ${db.findOne(pascal, "{ email }")};
1359
1390
  if (!record) return res.status(401).json({ error: 'Invalid credentials' });
1360
1391
  const match = await verifyPassword(password, record.password);
1361
1392
  if (!match) return res.status(401).json({ error: 'Invalid credentials' });
1362
1393
  if (!record.isActive) return res.status(403).json({ error: 'Account suspended' });
1363
- await issueToken(res, { id: record.id, role: record.role, email: record.email });
1364
- res.json({ message: 'Logged in as ${slug}' });
1394
+ const token = await issueToken(res, { id: record.id, role: record.role, email: record.email });
1395
+ // bearer: the client stores the token itself; http-only: it's a cookie.
1396
+ res.json({ message: 'Logged in as ${slug}', ...(token ? { token } : {}) });
1365
1397
  };
1366
1398
  `;
1367
1399
  }
@@ -1732,6 +1764,7 @@ function addCommand() {
1732
1764
  if (!opts.yes && !tty) fail("Not a terminal \u2014 pass --yes to add without confirming.");
1733
1765
  const ask = opts.prompt && tty && plan.prompts.length > 0;
1734
1766
  let env = {};
1767
+ let config = {};
1735
1768
  if (!opts.yes || ask) {
1736
1769
  const term = openTerminal();
1737
1770
  try {
@@ -1740,15 +1773,19 @@ function addCommand() {
1740
1773
  return;
1741
1774
  }
1742
1775
  if (ask) {
1743
- console.log(pc8.bold("\n Configuration") + pc8.dim(" (saved to .env)\n"));
1744
- env = envFromAnswers(plan.prompts, await askPrompts(term, plan.prompts, cwd));
1776
+ const where = plan.prompts.some((p) => p.config !== void 0) ? ".env / efc.config" : ".env";
1777
+ console.log(pc8.bold("\n Configuration") + pc8.dim(` (saved to ${where})
1778
+ `));
1779
+ const answers = await askPrompts(term, plan.prompts, cwd);
1780
+ env = envFromAnswers(plan.prompts, answers);
1781
+ config = configFromAnswers(plan.prompts, answers);
1745
1782
  console.log();
1746
1783
  }
1747
1784
  } finally {
1748
1785
  term.close();
1749
1786
  }
1750
1787
  }
1751
- const result = applyAdd(cwd, plan, registry, env);
1788
+ const result = applyAdd(cwd, plan, registry, env, config);
1752
1789
  console.log(
1753
1790
  pc8.green(` \u2713 ${result.written.length} file(s) written`) + (result.conflicts.length ? pc8.yellow(`, ${result.conflicts.length} left alone`) : "")
1754
1791
  );