- Install @biomejs/biome as devDependency at root - Configure biome.json with 2-space indent, double quotes, Tailwind CSS support - Add lint/lint:fix/format/format:fix scripts to root and app package.json - Fix noNonNullAssertion: env vars extracted to variables with suppression, <div role=button> replaced with <button> - Fix noUnusedVariables: remove unused destructured vars - Fix useIterableCallbackReturn: arrow functions with block body - Fix noExplicitAny: recharts Tooltip formatters - Fix noLabelWithoutControl: add htmlFor+id or use <span> for non-input labels - Fix noStaticElementInteractions/useKeyWithClickEvents: role+keyboard events for overlays - Fix noArrayIndexKey: use error string as key - Fix CSS parse: enable tailwindDirectives parser - Normalize formatting across 80 files with biome check --write
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import "dotenv/config";
|
|
import { PrismaPg } from "@prisma/adapter-pg";
|
|
import { betterAuth } from "better-auth";
|
|
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
import { PrismaClient } from "../src/generated/prisma/client";
|
|
|
|
const adapter = new PrismaPg({
|
|
// biome-ignore lint/style/noNonNullAssertion: required env var
|
|
connectionString: process.env.DATABASE_URL!,
|
|
});
|
|
const prisma = new PrismaClient({ adapter });
|
|
|
|
async function main() {
|
|
const existingUser = await prisma.user.findUnique({
|
|
where: { email: "jselesan@gmail.com" },
|
|
});
|
|
|
|
if (existingUser) {
|
|
console.log("Admin user already exists, skipping seed.");
|
|
return;
|
|
}
|
|
|
|
const auth = betterAuth({
|
|
database: prismaAdapter(prisma, {
|
|
provider: "postgresql",
|
|
}),
|
|
emailAndPassword: {
|
|
enabled: true,
|
|
disableSignUp: false,
|
|
minPasswordLength: 4,
|
|
},
|
|
// biome-ignore lint/style/noNonNullAssertion: required env var
|
|
secret: process.env.BETTER_AUTH_SECRET!,
|
|
baseURL: process.env.BETTER_AUTH_URL ?? "http://localhost:3000",
|
|
});
|
|
|
|
const password = process.env.ADMIN_PASSWORD;
|
|
|
|
if (!password) {
|
|
console.error("ADMIN_PASSWORD environment variable is not set.");
|
|
process.exit(1);
|
|
}
|
|
|
|
await auth.api.signUpEmail({
|
|
body: {
|
|
email: "jselesan@gmail.com",
|
|
password,
|
|
name: "Admin",
|
|
},
|
|
});
|
|
|
|
console.log("Admin user created successfully.");
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|