fix the shit

This commit is contained in:
2026-06-26 00:12:09 -04:00
parent af1f4a5721
commit eb9548b832
5 changed files with 2757 additions and 13 deletions
File diff suppressed because it is too large Load Diff
+1
View File
@@ -8,6 +8,7 @@
"check": "eslint . && tsc --noEmit", "check": "eslint . && tsc --noEmit",
"db:generate": "drizzle-kit generate", "db:generate": "drizzle-kit generate",
"db:migrate": "bun src/server/db/migrate.ts", "db:migrate": "bun src/server/db/migrate.ts",
"db:verify-journal": "bun scripts/verify-drizzle-journal.ts",
"db:push": "drizzle-kit push", "db:push": "drizzle-kit push",
"db:studio": "drizzle-kit studio", "db:studio": "drizzle-kit studio",
"db:clone": "./scripts/clone-local.sh", "db:clone": "./scripts/clone-local.sh",
+54
View File
@@ -0,0 +1,54 @@
/**
* Ensures every drizzle/*.sql migration file has a matching entry in meta/_journal.json.
* Run: bun scripts/verify-drizzle-journal.ts
*/
import { readdirSync, readFileSync } from "fs";
import path from "path";
const drizzleDir = path.resolve(import.meta.dir, "../drizzle");
const journalPath = path.join(drizzleDir, "meta/_journal.json");
const journal = JSON.parse(readFileSync(journalPath, "utf8")) as {
entries: Array<{ idx: number; tag: string }>;
};
const sqlTags = readdirSync(drizzleDir)
.filter((name) => /^\d+_.+\.sql$/.test(name))
.map((name) => name.replace(/\.sql$/, ""))
.sort();
const journalTags = journal.entries.map((entry) => entry.tag).sort();
const missingFromJournal = sqlTags.filter((tag) => !journalTags.includes(tag));
const missingSql = journalTags.filter((tag) => !sqlTags.includes(tag));
const idxSequence = journal.entries.map((entry) => entry.idx);
const expectedIdx = journal.entries.map((_, i) => i);
const badIdx = idxSequence.some((idx, i) => idx !== expectedIdx[i]);
let failed = false;
if (missingFromJournal.length > 0) {
console.error("[verify-drizzle-journal] SQL files missing from journal:");
for (const tag of missingFromJournal) console.error(` - ${tag}`);
failed = true;
}
if (missingSql.length > 0) {
console.error("[verify-drizzle-journal] Journal entries without SQL files:");
for (const tag of missingSql) console.error(` - ${tag}`);
failed = true;
}
if (badIdx) {
console.error("[verify-drizzle-journal] Journal idx values are not sequential from 0");
failed = true;
}
if (failed) {
process.exit(1);
}
console.log(
`[verify-drizzle-journal] OK — ${sqlTags.length} migrations match journal entries`,
);
+35 -13
View File
@@ -40,22 +40,44 @@ function RegisterForm() {
setLoading(true); setLoading(true);
const { error } = await authClient.signUp.email({ try {
email: trimmedEmail, const res = await fetch("/api/auth/register", {
password, method: "POST",
name: `${trimmedFirstName} ${trimmedLastName}`, headers: { "Content-Type": "application/json" },
}); body: JSON.stringify({
firstName: trimmedFirstName,
lastName: trimmedLastName,
email: trimmedEmail,
password,
}),
});
setLoading(false); const data = (await res.json()) as { error?: string };
if (error) { if (!res.ok) {
toast.error(error.message ?? "Registration failed"); toast.error(data.error ?? "Registration failed");
return; return;
}
const { error: signInError } = await authClient.signIn.email({
email: trimmedEmail,
password,
});
if (signInError) {
toast.success("Account created! Please sign in.");
router.push("/auth/signin");
return;
}
toast.success("Account created successfully!");
router.push("/dashboard");
router.refresh();
} catch {
toast.error("Registration failed. Please try again.");
} finally {
setLoading(false);
} }
toast.success("Account created successfully!");
router.push("/dashboard");
router.refresh();
} }
return ( return (
+3
View File
@@ -23,6 +23,9 @@ const authentikOrigin =
export const auth = betterAuth({ export const auth = betterAuth({
baseURL: process.env.BETTER_AUTH_URL, baseURL: process.env.BETTER_AUTH_URL,
secret: process.env.AUTH_SECRET, secret: process.env.AUTH_SECRET,
experimental: {
joins: true,
},
database: drizzleAdapter(db, { database: drizzleAdapter(db, {
provider: "pg", provider: "pg",
schema: { schema: {