express-file-cluster 0.9.3 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.cjs +6 -7
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.cts +7 -2
- package/dist/auth/index.d.ts +7 -2
- package/dist/auth/index.js +5 -6
- package/dist/{chunk-QL6EWT4B.cjs → chunk-4DOHQU6I.cjs} +9 -7
- package/dist/chunk-4DOHQU6I.cjs.map +1 -0
- package/dist/chunk-73XJUT2S.js +366 -0
- package/dist/chunk-73XJUT2S.js.map +1 -0
- package/dist/{chunk-ATL4GYFU.js → chunk-7KC2H76D.js} +50 -8
- package/dist/chunk-7KC2H76D.js.map +1 -0
- package/dist/{chunk-TYR2GZZE.cjs → chunk-7KO4DJRJ.cjs} +19 -14
- package/dist/chunk-7KO4DJRJ.cjs.map +1 -0
- package/dist/{chunk-UBQYQPBU.js → chunk-ATVD2HGC.js} +4 -4
- package/dist/{chunk-R34R7QPD.cjs → chunk-DCJOWFVD.cjs} +3 -3
- package/dist/{chunk-R34R7QPD.cjs.map → chunk-DCJOWFVD.cjs.map} +1 -1
- package/dist/chunk-DUADUR6R.cjs +366 -0
- package/dist/chunk-DUADUR6R.cjs.map +1 -0
- package/dist/{chunk-BBSZLGZW.js → chunk-EGSSZUVO.js} +8 -6
- package/dist/chunk-EGSSZUVO.js.map +1 -0
- package/dist/{chunk-TI24L4XE.cjs → chunk-GBI77W5T.cjs} +6 -2
- package/dist/chunk-GBI77W5T.cjs.map +1 -0
- package/dist/{chunk-RTF7PHS2.cjs → chunk-HBCY7ILD.cjs} +306 -119
- package/dist/chunk-HBCY7ILD.cjs.map +1 -0
- package/dist/{chunk-ANUSWEAP.cjs → chunk-KFVFP2Q7.cjs} +59 -17
- package/dist/chunk-KFVFP2Q7.cjs.map +1 -0
- package/dist/{chunk-RS4MXCPW.js → chunk-NI2BNGGV.js} +2 -2
- package/dist/{chunk-X2US4RAM.cjs → chunk-NKLOE4AK.cjs} +11 -13
- package/dist/chunk-NKLOE4AK.cjs.map +1 -0
- package/dist/{chunk-RRQ2RK5M.js → chunk-PGJQK36V.js} +195 -8
- package/dist/chunk-PGJQK36V.js.map +1 -0
- package/dist/{chunk-QKQZF573.js → chunk-QDEDOHP7.js} +4 -6
- package/dist/chunk-QDEDOHP7.js.map +1 -0
- package/dist/{chunk-UTM4PEVG.js → chunk-R4XO4SVM.js} +10 -5
- package/dist/chunk-R4XO4SVM.js.map +1 -0
- package/dist/chunk-R52CUEGT.js +74 -0
- package/dist/chunk-R52CUEGT.js.map +1 -0
- package/dist/{chunk-HBYSKULC.js → chunk-RAB44UGX.js} +5 -1
- package/dist/chunk-RAB44UGX.js.map +1 -0
- package/dist/{chunk-7YEX4MQV.cjs → chunk-WBLUGOAG.cjs} +42 -6
- package/dist/chunk-WBLUGOAG.cjs.map +1 -0
- package/dist/{chunk-T4OHFU5T.cjs → chunk-YK4ZM3CA.cjs} +15 -15
- package/dist/{chunk-T4OHFU5T.cjs.map → chunk-YK4ZM3CA.cjs.map} +1 -1
- package/dist/cli/db-runner.cjs +2012 -120
- package/dist/cli/db-runner.cjs.map +1 -1
- package/dist/cli/db-runner.js +1989 -97
- package/dist/cli/db-runner.js.map +1 -1
- package/dist/cli/index.cjs +101 -43
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +80 -22
- package/dist/cli/index.js.map +1 -1
- package/dist/docs/api-reference/auth.md +10 -8
- package/dist/docs/api-reference/collection.md +44 -1
- package/dist/docs/api-reference/ignite.md +22 -3
- package/dist/docs/api-reference/types.md +99 -0
- package/dist/docs/cli/add.md +1 -1
- package/dist/docs/cli/db.md +2 -2
- package/dist/docs/contributing/index.md +1 -1
- package/dist/docs/core-concepts/background-tasks.md +6 -3
- package/dist/docs/getting-started/index.md +3 -2
- package/dist/docs/guides/authentication.md +34 -24
- package/dist/docs/guides/caching.md +32 -1
- package/dist/docs/guides/database.md +14 -0
- package/dist/docs/guides/feature-matrix.md +58 -0
- package/dist/docs/guides/migrations.md +23 -2
- package/dist/docs/guides/oauth.md +15 -1
- package/dist/docs/guides/which-api.md +2 -2
- package/dist/docs/index.md +4 -1
- package/dist/docs/skills/SKILL.md +2 -2
- package/dist/docs/skills/api-surface.md +10 -4
- package/dist/docs/skills/auth-internals.md +3 -3
- package/dist/docs/skills/tasks-internals.md +4 -3
- package/dist/docs/skills/what-not-to-invent.md +4 -3
- package/dist/docs/versioning.md +42 -0
- package/dist/index.cjs +144 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +204 -3
- package/dist/index.d.ts +204 -3
- package/dist/index.js +107 -14
- package/dist/index.js.map +1 -1
- package/dist/pgboss-backend-FW42SBSM.js +14 -0
- package/dist/pgboss-backend-RVHUBJTU.cjs +14 -0
- package/dist/{pgboss-backend-TCHI7CHM.cjs.map → pgboss-backend-RVHUBJTU.cjs.map} +1 -1
- package/dist/registry/index.json +34 -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/email-verification.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/_base.json +1 -0
- package/dist/registry/js-mongo-collection/account-security.json +1 -0
- package/dist/registry/js-mongo-collection/account-settings.json +1 -0
- package/dist/registry/js-mongo-collection/admin-admins.json +1 -0
- package/dist/registry/js-mongo-collection/admin-analytics.json +1 -0
- package/dist/registry/js-mongo-collection/admin-billing.json +1 -0
- package/dist/registry/js-mongo-collection/admin-content.json +1 -0
- package/dist/registry/js-mongo-collection/admin-logs.json +1 -0
- package/dist/registry/js-mongo-collection/admin-support.json +1 -0
- package/dist/registry/js-mongo-collection/admin-system.json +1 -0
- package/dist/registry/js-mongo-collection/admin-users.json +1 -0
- package/dist/registry/js-mongo-collection/admin.json +1 -0
- package/dist/registry/js-mongo-collection/auth.json +1 -0
- package/dist/registry/js-mongo-collection/auth@apple.json +1 -0
- package/dist/registry/js-mongo-collection/auth@google.json +1 -0
- package/dist/registry/js-mongo-collection/billing.json +1 -0
- package/dist/registry/js-mongo-collection/email-client.json +1 -0
- package/dist/registry/js-mongo-collection/email-verification.json +1 -0
- package/dist/registry/js-mongo-collection/files.json +1 -0
- package/dist/registry/js-mongo-collection/forgot-password.json +1 -0
- package/dist/registry/js-mongo-collection/notifications.json +1 -0
- package/dist/registry/js-mongo-collection/support.json +1 -0
- package/dist/registry/js-mongo-collection/user-profile.json +1 -0
- package/dist/registry/js-pg-model/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/email-verification.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/email-verification.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/email-verification.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/_base.json +1 -0
- package/dist/registry/ts-mongo-collection/account-security.json +1 -0
- package/dist/registry/ts-mongo-collection/account-settings.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-admins.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-analytics.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-billing.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-content.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-logs.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-support.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-system.json +1 -0
- package/dist/registry/ts-mongo-collection/admin-users.json +1 -0
- package/dist/registry/ts-mongo-collection/admin.json +1 -0
- package/dist/registry/ts-mongo-collection/auth.json +1 -0
- package/dist/registry/ts-mongo-collection/auth@apple.json +1 -0
- package/dist/registry/ts-mongo-collection/auth@google.json +1 -0
- package/dist/registry/ts-mongo-collection/billing.json +1 -0
- package/dist/registry/ts-mongo-collection/email-client.json +1 -0
- package/dist/registry/ts-mongo-collection/email-verification.json +1 -0
- package/dist/registry/ts-mongo-collection/files.json +1 -0
- package/dist/registry/ts-mongo-collection/forgot-password.json +1 -0
- package/dist/registry/ts-mongo-collection/notifications.json +1 -0
- package/dist/registry/ts-mongo-collection/support.json +1 -0
- package/dist/registry/ts-mongo-collection/user-profile.json +1 -0
- package/dist/registry/ts-pg-model/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/email-verification.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/email-verification.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 +4 -2
- package/dist/tasks/index.cjs.map +1 -1
- package/dist/tasks/index.d.cts +4 -2
- package/dist/tasks/index.d.ts +4 -2
- package/dist/tasks/index.js +3 -1
- package/dist/thread-runner.cjs +8 -0
- package/dist/thread-runner.cjs.map +1 -0
- package/dist/thread-runner.d.cts +3 -0
- package/dist/thread-runner.d.ts +3 -0
- package/dist/thread-runner.js +8 -0
- package/dist/thread-runner.js.map +1 -0
- package/dist/{types-BY-ObnZH.d.ts → types-Bnxvj3l0.d.cts} +14 -2
- package/dist/{types-BY-ObnZH.d.cts → types-Bnxvj3l0.d.ts} +14 -2
- package/package.json +1 -1
- package/dist/chunk-277BSYVH.js +0 -127
- package/dist/chunk-277BSYVH.js.map +0 -1
- package/dist/chunk-7YEX4MQV.cjs.map +0 -1
- package/dist/chunk-ANUSWEAP.cjs.map +0 -1
- package/dist/chunk-ATL4GYFU.js.map +0 -1
- package/dist/chunk-BBSZLGZW.js.map +0 -1
- package/dist/chunk-HBYSKULC.js.map +0 -1
- package/dist/chunk-HXV543HZ.js +0 -177
- package/dist/chunk-HXV543HZ.js.map +0 -1
- package/dist/chunk-LJNSJFOL.js +0 -38
- package/dist/chunk-LJNSJFOL.js.map +0 -1
- package/dist/chunk-QKQZF573.js.map +0 -1
- package/dist/chunk-QL6EWT4B.cjs.map +0 -1
- package/dist/chunk-RRQ2RK5M.js.map +0 -1
- package/dist/chunk-RTF7PHS2.cjs.map +0 -1
- package/dist/chunk-TI24L4XE.cjs.map +0 -1
- package/dist/chunk-TYR2GZZE.cjs.map +0 -1
- package/dist/chunk-UTM4PEVG.js.map +0 -1
- package/dist/chunk-VQSWSYK6.cjs +0 -177
- package/dist/chunk-VQSWSYK6.cjs.map +0 -1
- package/dist/chunk-X2US4RAM.cjs.map +0 -1
- package/dist/chunk-YL37D6KM.cjs +0 -127
- package/dist/chunk-YL37D6KM.cjs.map +0 -1
- package/dist/pgboss-backend-QKBXVJ6B.js +0 -14
- package/dist/pgboss-backend-TCHI7CHM.cjs +0 -14
- /package/dist/{chunk-UBQYQPBU.js.map → chunk-ATVD2HGC.js.map} +0 -0
- /package/dist/{chunk-RS4MXCPW.js.map → chunk-NI2BNGGV.js.map} +0 -0
- /package/dist/{pgboss-backend-QKBXVJ6B.js.map → pgboss-backend-FW42SBSM.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-
|
|
4
|
+
} from "../chunk-NI2BNGGV.js";
|
|
5
5
|
import {
|
|
6
6
|
parseRedisUrl
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-ATVD2HGC.js";
|
|
8
8
|
import {
|
|
9
9
|
writeModels
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-EGSSZUVO.js";
|
|
11
11
|
import {
|
|
12
12
|
tableNameFor
|
|
13
|
-
} from "../chunk-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-277BSYVH.js";
|
|
13
|
+
} from "../chunk-QDEDOHP7.js";
|
|
14
|
+
import "../chunk-R52CUEGT.js";
|
|
15
|
+
import "../chunk-RAB44UGX.js";
|
|
16
|
+
import "../chunk-73XJUT2S.js";
|
|
18
17
|
|
|
19
18
|
// src/cli/index.ts
|
|
20
19
|
import fs10 from "fs";
|
|
@@ -553,7 +552,7 @@ async function connect(opts) {
|
|
|
553
552
|
if (backend === "bullmq") return bullmqAdmin(redisUrl ?? "redis://localhost:6379", opts.queue);
|
|
554
553
|
if (backend === "pg-boss") {
|
|
555
554
|
if (!databaseUrl) throw new Error("[EFC] pg-boss needs DATABASE_URL (or --database-url)");
|
|
556
|
-
const { pgBossAdmin } = await import("../pgboss-backend-
|
|
555
|
+
const { pgBossAdmin } = await import("../pgboss-backend-FW42SBSM.js");
|
|
557
556
|
return pgBossAdmin(databaseUrl, opts.queue);
|
|
558
557
|
}
|
|
559
558
|
throw new Error(`[EFC] Unknown task backend: ${backend}`);
|
|
@@ -819,8 +818,14 @@ function dbCommand() {
|
|
|
819
818
|
(opts) => run2("sync", opts)
|
|
820
819
|
);
|
|
821
820
|
common(
|
|
822
|
-
cmd.command("pull").description(
|
|
823
|
-
|
|
821
|
+
cmd.command("pull").description(
|
|
822
|
+
"Write models for the database: defineTable from PostgreSQL tables, defineCollection from sampled MongoDB documents"
|
|
823
|
+
)
|
|
824
|
+
).option("--out <dir>", "where to write the models", "src/model").option("--force", "overwrite model files that already exist").option(
|
|
825
|
+
"--sample <n>",
|
|
826
|
+
"MongoDB: documents sampled per collection (default 1000)",
|
|
827
|
+
(v) => Number.parseInt(v, 10)
|
|
828
|
+
).action(
|
|
824
829
|
(opts) => run2("pull", opts)
|
|
825
830
|
);
|
|
826
831
|
common(cmd.command("status").description("List applied and pending migrations")).action(
|
|
@@ -831,7 +836,9 @@ function dbCommand() {
|
|
|
831
836
|
).action(
|
|
832
837
|
(name, opts) => run2("seed", { ...opts, ...name !== void 0 && { seed: name } })
|
|
833
838
|
);
|
|
834
|
-
common(
|
|
839
|
+
common(
|
|
840
|
+
cmd.command("studio").description("Open a local database browser (read-only; --write edits through your models)")
|
|
841
|
+
).option("-p, --port <port>", "port to listen on (127.0.0.1 only)", "4983").option("--write", "allow inserting, editing and deleting rows (through src/model, validated)").action(
|
|
835
842
|
(opts) => run2("studio", { ...opts, port: Number(opts.port) })
|
|
836
843
|
);
|
|
837
844
|
return cmd;
|
|
@@ -916,7 +923,8 @@ var Registry = class {
|
|
|
916
923
|
};
|
|
917
924
|
function variantOf(cfg) {
|
|
918
925
|
const lang = cfg.language === "typescript" ? "ts" : "js";
|
|
919
|
-
if (cfg.database === "mongodb")
|
|
926
|
+
if (cfg.database === "mongodb")
|
|
927
|
+
return cfg.modelApi === "defineCollection" ? `${lang}-mongo-collection` : `${lang}-mongo`;
|
|
920
928
|
return `${lang}-pg-${cfg.modelApi === "defineTable" ? "table" : "model"}`;
|
|
921
929
|
}
|
|
922
930
|
function readJson(file) {
|
|
@@ -951,6 +959,10 @@ function detectProject(cwd, version2) {
|
|
|
951
959
|
}
|
|
952
960
|
let modelApi = database === "postgresql" ? "defineTable" : "defineModel";
|
|
953
961
|
const modelDir = path7.join(cwd, "src", "model");
|
|
962
|
+
if (database === "mongodb" && fs7.existsSync(modelDir)) {
|
|
963
|
+
const sources = fs7.readdirSync(modelDir).filter((f) => /\.[jt]s$/.test(f)).map((f) => fs7.readFileSync(path7.join(modelDir, f), "utf8")).join("\n");
|
|
964
|
+
if (/\bdefineCollection\(/.test(sources)) modelApi = "defineCollection";
|
|
965
|
+
}
|
|
954
966
|
if (database === "postgresql" && fs7.existsSync(modelDir)) {
|
|
955
967
|
const sources = fs7.readdirSync(modelDir).filter((f) => /\.[jt]s$/.test(f)).map((f) => fs7.readFileSync(path7.join(modelDir, f), "utf8")).join("\n");
|
|
956
968
|
if (/\bdefineModel\(/.test(sources) && !/\bdefineTable\(/.test(sources))
|
|
@@ -1043,7 +1055,7 @@ function planAdd(cwd, registry, names, opts = {}, cfg = readEfcJson(cwd) ?? dete
|
|
|
1043
1055
|
const dup = plan.prompts.some(
|
|
1044
1056
|
(q) => q.name === p.name && JSON.stringify(q.when) === JSON.stringify(p.when)
|
|
1045
1057
|
);
|
|
1046
|
-
if (!dup && sets(p)) plan.prompts.push(p);
|
|
1058
|
+
if (!dup && (p.config !== void 0 || sets(p))) plan.prompts.push(p);
|
|
1047
1059
|
}
|
|
1048
1060
|
}
|
|
1049
1061
|
return plan;
|
|
@@ -1089,11 +1101,36 @@ function envFromAnswers(prompts, answers) {
|
|
|
1089
1101
|
}
|
|
1090
1102
|
return env;
|
|
1091
1103
|
}
|
|
1104
|
+
function configFromAnswers(prompts, answers) {
|
|
1105
|
+
const config = {};
|
|
1106
|
+
for (const p of prompts) {
|
|
1107
|
+
if (p.config !== void 0 && p.name in answers && promptApplies(p, answers)) {
|
|
1108
|
+
config[p.config] = answers[p.name];
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
return config;
|
|
1112
|
+
}
|
|
1113
|
+
function setConfigValues(cwd, values) {
|
|
1114
|
+
const entries = Object.entries(values);
|
|
1115
|
+
if (entries.length === 0) return [];
|
|
1116
|
+
const file = ["efc.config.ts", "efc.config.js", "efc.config.mjs"].map((f) => path7.join(cwd, f)).find((f) => fs7.existsSync(f));
|
|
1117
|
+
if (!file) return entries.map(([k, v]) => `efc.config: set \`${k}: '${v}'\``);
|
|
1118
|
+
let text = fs7.readFileSync(file, "utf8");
|
|
1119
|
+
const manual = [];
|
|
1120
|
+
for (const [key, value] of entries) {
|
|
1121
|
+
const re = new RegExp(`^(\\s*)${key}:\\s*(['"])[^'"\\n]*\\2`, "gm");
|
|
1122
|
+
const found = text.match(re)?.length ?? 0;
|
|
1123
|
+
if (found === 1) text = text.replace(re, `$1${key}: '${value}'`);
|
|
1124
|
+
else manual.push(`${path7.basename(file)}: set \`${key}: '${value}'\``);
|
|
1125
|
+
}
|
|
1126
|
+
fs7.writeFileSync(file, text);
|
|
1127
|
+
return manual;
|
|
1128
|
+
}
|
|
1092
1129
|
function envLine(key, value) {
|
|
1093
1130
|
if (!/[\s#"'`]/.test(value)) return `${key}=${value}`;
|
|
1094
1131
|
return value.includes("'") ? `${key}="${value.replace(/"/g, '\\"')}"` : `${key}='${value}'`;
|
|
1095
1132
|
}
|
|
1096
|
-
function applyAdd(cwd, plan, registry, env = {}) {
|
|
1133
|
+
function applyAdd(cwd, plan, registry, env = {}, config = {}) {
|
|
1097
1134
|
const result = {
|
|
1098
1135
|
written: [],
|
|
1099
1136
|
skipped: [],
|
|
@@ -1150,6 +1187,7 @@ function applyAdd(cwd, plan, registry, env = {}) {
|
|
|
1150
1187
|
plan.env.filter((v) => !readEnvKeys(exampleFile).includes(v.key)).map((v) => `${v.key}=${v.example}`)
|
|
1151
1188
|
);
|
|
1152
1189
|
}
|
|
1190
|
+
result.manual.push(...setConfigValues(cwd, config));
|
|
1153
1191
|
if (cfg.modelApi === "defineTable" && cfg.database === "postgresql" && newModels.length) {
|
|
1154
1192
|
result.manual.push(...registerModels(cwd, cfg.language, newModels));
|
|
1155
1193
|
}
|
|
@@ -1333,7 +1371,8 @@ import { ${pascal} } from '../../../model/${pascal}.js';
|
|
|
1333
1371
|
|
|
1334
1372
|
export const POST = async ${typedArgs} => {
|
|
1335
1373
|
const { name, email, password } = req.body;
|
|
1336
|
-
|
|
1374
|
+
// Strings only: an object such as {"$ne": null} would be read as a filter operator and match any account.
|
|
1375
|
+
if (typeof name !== 'string' || typeof email !== 'string' || typeof password !== 'string' || !name || !email || !password) {
|
|
1337
1376
|
return res.status(400).json({ error: 'name, email and password are required' });
|
|
1338
1377
|
}
|
|
1339
1378
|
const existing = await ${db.findOne(pascal, "{ email }")};
|
|
@@ -1351,19 +1390,33 @@ function entityLoginContent(pascal, slug, cfg) {
|
|
|
1351
1390
|
const typedArgs = ts ? "(req: Request, res: Response)" : "(req, res)";
|
|
1352
1391
|
const typeImport = ts ? "import type { Request, Response } from 'express';\n" : "";
|
|
1353
1392
|
return `${typeImport}import { issueToken, verifyPassword } from 'express-file-cluster/auth';
|
|
1393
|
+
import { rateLimit } from 'express-file-cluster';
|
|
1354
1394
|
import { ${pascal} } from '../../../model/${pascal}.js';
|
|
1355
1395
|
|
|
1396
|
+
// 10 attempts per 15 minutes per address and account (see TRUST_PROXY behind a proxy).
|
|
1397
|
+
export const middlewares = [
|
|
1398
|
+
rateLimit({
|
|
1399
|
+
window: '15m',
|
|
1400
|
+
max: 10,
|
|
1401
|
+
key: (req) => \`\${req.ip}:\${String(req.body?.email ?? '').toLowerCase()}\`,
|
|
1402
|
+
}),
|
|
1403
|
+
];
|
|
1404
|
+
|
|
1356
1405
|
export const POST = async ${typedArgs} => {
|
|
1357
1406
|
const { email, password } = req.body;
|
|
1358
|
-
|
|
1407
|
+
// Strings only: an object such as {"$ne": null} would be read as a filter operator and match any account.
|
|
1408
|
+
if (typeof email !== 'string' || typeof password !== 'string' || !email || !password) {
|
|
1409
|
+
return res.status(400).json({ error: 'email and password are required' });
|
|
1410
|
+
}
|
|
1359
1411
|
|
|
1360
1412
|
const record = await ${db.findOne(pascal, "{ email }")};
|
|
1361
1413
|
if (!record) return res.status(401).json({ error: 'Invalid credentials' });
|
|
1362
1414
|
const match = await verifyPassword(password, record.password);
|
|
1363
1415
|
if (!match) return res.status(401).json({ error: 'Invalid credentials' });
|
|
1364
1416
|
if (!record.isActive) return res.status(403).json({ error: 'Account suspended' });
|
|
1365
|
-
await issueToken(res, { id: record.id, role: record.role, email: record.email });
|
|
1366
|
-
|
|
1417
|
+
const token = await issueToken(res, { id: record.id, role: record.role, email: record.email });
|
|
1418
|
+
// bearer: the client stores the token itself; http-only: it's a cookie.
|
|
1419
|
+
res.json({ message: 'Logged in as ${slug}', ...(token ? { token } : {}) });
|
|
1367
1420
|
};
|
|
1368
1421
|
`;
|
|
1369
1422
|
}
|
|
@@ -1734,6 +1787,7 @@ function addCommand() {
|
|
|
1734
1787
|
if (!opts.yes && !tty) fail("Not a terminal \u2014 pass --yes to add without confirming.");
|
|
1735
1788
|
const ask = opts.prompt && tty && plan.prompts.length > 0;
|
|
1736
1789
|
let env = {};
|
|
1790
|
+
let config = {};
|
|
1737
1791
|
if (!opts.yes || ask) {
|
|
1738
1792
|
const term = openTerminal();
|
|
1739
1793
|
try {
|
|
@@ -1742,15 +1796,19 @@ function addCommand() {
|
|
|
1742
1796
|
return;
|
|
1743
1797
|
}
|
|
1744
1798
|
if (ask) {
|
|
1745
|
-
|
|
1746
|
-
|
|
1799
|
+
const where = plan.prompts.some((p) => p.config !== void 0) ? ".env / efc.config" : ".env";
|
|
1800
|
+
console.log(pc8.bold("\n Configuration") + pc8.dim(` (saved to ${where})
|
|
1801
|
+
`));
|
|
1802
|
+
const answers = await askPrompts(term, plan.prompts, cwd);
|
|
1803
|
+
env = envFromAnswers(plan.prompts, answers);
|
|
1804
|
+
config = configFromAnswers(plan.prompts, answers);
|
|
1747
1805
|
console.log();
|
|
1748
1806
|
}
|
|
1749
1807
|
} finally {
|
|
1750
1808
|
term.close();
|
|
1751
1809
|
}
|
|
1752
1810
|
}
|
|
1753
|
-
const result = applyAdd(cwd, plan, registry, env);
|
|
1811
|
+
const result = applyAdd(cwd, plan, registry, env, config);
|
|
1754
1812
|
console.log(
|
|
1755
1813
|
pc8.green(` \u2713 ${result.written.length} file(s) written`) + (result.conflicts.length ? pc8.yellow(`, ${result.conflicts.length} left alone`) : "")
|
|
1756
1814
|
);
|