fix the shit
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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",
|
||||||
|
|||||||
@@ -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`,
|
||||||
|
);
|
||||||
@@ -40,22 +40,44 @@ function RegisterForm() {
|
|||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
const { error } = await authClient.signUp.email({
|
try {
|
||||||
|
const res = await fetch("/api/auth/register", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({
|
||||||
|
firstName: trimmedFirstName,
|
||||||
|
lastName: trimmedLastName,
|
||||||
email: trimmedEmail,
|
email: trimmedEmail,
|
||||||
password,
|
password,
|
||||||
name: `${trimmedFirstName} ${trimmedLastName}`,
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { error: signInError } = await authClient.signIn.email({
|
||||||
|
email: trimmedEmail,
|
||||||
|
password,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (signInError) {
|
||||||
|
toast.success("Account created! Please sign in.");
|
||||||
|
router.push("/auth/signin");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.success("Account created successfully!");
|
toast.success("Account created successfully!");
|
||||||
router.push("/dashboard");
|
router.push("/dashboard");
|
||||||
router.refresh();
|
router.refresh();
|
||||||
|
} catch {
|
||||||
|
toast.error("Registration failed. Please try again.");
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -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: {
|
||||||
|
|||||||
Reference in New Issue
Block a user