feat: Set up initial monorepo structure for admin and mobile applications with core configurations and database integration.
This commit is contained in:
34
innungsapp/apps/admin/seed-auth.ts
Normal file
34
innungsapp/apps/admin/seed-auth.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { auth } from './lib/auth'
|
||||
import { PrismaClient } from '@prisma/client'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
async function seed() {
|
||||
console.log('Cleaning up existing superadmin if exists...')
|
||||
// Delete the existing user to avoid constraints
|
||||
await prisma.user.deleteMany({
|
||||
where: { email: 'superadmin@innungsapp.de' },
|
||||
})
|
||||
|
||||
console.log('Seeding superadmin via better-auth API...')
|
||||
|
||||
try {
|
||||
const user = await auth.api.signUpEmail({
|
||||
body: {
|
||||
email: 'superadmin@innungsapp.de',
|
||||
password: 'demo1234',
|
||||
name: 'Super Admin',
|
||||
}
|
||||
})
|
||||
|
||||
// Check if better-auth actually uses the Prisma DB directly here
|
||||
// It should, as auth is configured with the prisma instance
|
||||
console.log('Superadmin created successfully! ID:', user.user.id)
|
||||
} catch (err: any) {
|
||||
console.error('Error creating superadmin:', err.message || err)
|
||||
}
|
||||
}
|
||||
|
||||
seed()
|
||||
.catch(console.error)
|
||||
.finally(() => prisma.$disconnect())
|
||||
Reference in New Issue
Block a user