Feat: Add role enum for user table

This commit is contained in:
Aaron William Po
2023-09-23 01:26:36 -04:00
parent bf56ca6058
commit 942f1390f7
11 changed files with 946 additions and 870 deletions

View File

@@ -0,0 +1,36 @@
import { z } from 'zod';
import { hashPassword } from '../../../config/auth/passwordFns';
import DBClient from '../../DBClient';
import GetUserSchema from '../../../services/User/schema/GetUserSchema';
const createAdminUser = async () => {
const hash = await hashPassword('Pas!3word');
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,
},
select: {
id: true,
username: true,
email: true,
firstName: true,
lastName: true,
dateOfBirth: true,
createdAt: true,
accountIsVerified: true,
updatedAt: true,
role: true,
},
});
return adminUser;
};
export default createAdminUser;