aboutsummaryrefslogtreecommitdiffstats
path: root/database/factories/UserFactory.ts
blob: caa2ea96694e973db1459dde71b79ef4ee51c2ba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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()