MCPcopy Create free account
hub / github.com/LeChatErrant/API-template / seedAdminUser

Function seedAdminUser

src/utils/seedAdminUser.ts:8–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import { hashPassword } from './hash';
7
8export default async function seedAdminUser() {
9 logger.info('Seeding root user...');
10
11 const alreadyExists = !!await db.user.findFirst({
12 where: {
13 role: Role.ADMIN,
14 },
15 });
16
17 if (alreadyExists) {
18 logger.info('Root user already exists. Skipping database seeding');
19 return;
20 }
21
22 const hashedPassword = await hashPassword(config.defaultAdminPassword);
23 await db.user.create({
24 data: {
25 role: Role.ADMIN,
26 username: 'root',
27 email: config.defaultAdminEmail,
28 password: hashedPassword,
29 },
30 });
31}

Callers 2

mainFunction · 0.85
user.spec.tsFile · 0.85

Calls 1

hashPasswordFunction · 0.90

Tested by

no test coverage detected