mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 13:00:13 +02:00
32 lines
675 B
TypeScript
32 lines
675 B
TypeScript
/* eslint-disable promise/catch-or-return */
|
|
import { PrismaClient } from '@prisma/client';
|
|
import bcrypt from 'bcryptjs';
|
|
import { randomString } from '../utils';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const hashedPassword = await bcrypt.hash('admin', 12);
|
|
|
|
await prisma.user.upsert({
|
|
create: {
|
|
deviceId: `admin_${randomString(10)}`,
|
|
enabled: true,
|
|
isAdmin: true,
|
|
password: hashedPassword,
|
|
username: 'admin',
|
|
},
|
|
update: {},
|
|
where: { username: 'admin' },
|
|
});
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
// process.exit(1);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|