aboutsummaryrefslogtreecommitdiffstats
path: root/database/factories/UserFactory.ts
blob: ee6553edd5737309edbf78b468eca3f9ba3de0ba (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 '@ioc:Adonis/Lucid/Factory';
import WorkspaceFactory from './WorkspaceFactory';
import ServiceFactory from './ServiceFactory';
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();