aboutsummaryrefslogtreecommitdiffstats
path: root/database/factories/UserFactory.ts
blob: 2e6005247846ede757c1a1c549432e061954808c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import User from '#app/Models/User';
import Factory from '@adonisjs/lucid/factories';
import WorkspaceFactory from './WorkspaceFactory.js';
import ServiceFactory from './ServiceFactory.js';
import crypto from 'node:crypto';

const hashedPassword = crypto
  .createHash('sha256')
  .update('password')
  .digest('base64');

export default Factory.define(User, async ({ faker }) => ({
  email: faker.internet.email(),
  username: faker.internet.userName(),
  password: hashedPassword,
  // eslint-disable-next-line unicorn/prefer-string-replace-all
  lastname: faker.person.lastName().replace(/'/g, ''),
}))
  .relation('workspaces', () => WorkspaceFactory)
  .relation('services', () => ServiceFactory)
  .build();