mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-06-01 10:04:00 +00:00
Move next js project to archive (#207)
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { hashPassword } from '../../../config/auth/passwordFns';
|
||||
import { ADMIN_PASSWORD } from '../../../config/env';
|
||||
|
||||
import DBClient from '../../DBClient';
|
||||
import GetUserSchema from '../../../services/users/auth/schema/GetUserSchema';
|
||||
import imageUrls from '../util/imageUrls';
|
||||
|
||||
const createAdminUser = async () => {
|
||||
const hash = await hashPassword(ADMIN_PASSWORD);
|
||||
const adminUser: z.infer<typeof GetUserSchema> = await DBClient.instance.user.create({
|
||||
data: {
|
||||
username: 'admin',
|
||||
email: 'admin@example.com',
|
||||
firstName: 'Admin',
|
||||
lastName: 'User',
|
||||
dateOfBirth: new Date('1990-01-01'),
|
||||
role: 'ADMIN',
|
||||
hash,
|
||||
userAvatar: {
|
||||
create: {
|
||||
path: imageUrls[Math.floor(Math.random() * imageUrls.length)],
|
||||
alt: 'Admin User',
|
||||
caption: 'Admin User',
|
||||
createdAt: new Date(),
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
email: true,
|
||||
firstName: true,
|
||||
lastName: true,
|
||||
dateOfBirth: true,
|
||||
createdAt: true,
|
||||
accountIsVerified: true,
|
||||
updatedAt: true,
|
||||
role: true,
|
||||
bio: true,
|
||||
userAvatar: true,
|
||||
},
|
||||
});
|
||||
|
||||
return adminUser;
|
||||
};
|
||||
|
||||
export default createAdminUser;
|
||||
Reference in New Issue
Block a user