Skip to content

Commit

Permalink
[back] 💾 database: add default admin user with email and password
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnPetros committed Nov 29, 2024
1 parent fd8c86c commit 7b21f8f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions apps/server/src/database/prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
SuppliersFaker,
UsersFaker,
} from '@stocker/core/fakers'
import { CryptoProvider } from '@/providers/crypto-provider'

const FAKE_COMPANY_ID = '29fcf7a0-5ee3-4cb0-b36e-ecc825f1cdaa'

Expand Down Expand Up @@ -60,7 +61,8 @@ export async function registerInboundMovement(
}

export async function seed() {
await resetDatabase()
const existingFakeCompany = await companiesRepository.findById(FAKE_COMPANY_ID)
if (existingFakeCompany) await companiesRepository.delete(FAKE_COMPANY_ID)

const fakeCompany = CompanyFaker.fake({ id: FAKE_COMPANY_ID })
const fakeSuppliers = SuppliersFaker.fakeMany(3, { companyId: fakeCompany.id })
Expand Down Expand Up @@ -94,7 +96,14 @@ export async function seed() {
role: 'employee',
companyId: fakeCompany.id,
})
fakeUsers.push(UsersFaker.fake({ role: 'admin', companyId: fakeCompany.id }))
fakeUsers.push(
UsersFaker.fake({
role: 'admin',
companyId: fakeCompany.id,
email: '[email protected]',
password: await new CryptoProvider().hash('stocker123'),
}),
)

await companiesRepository.add(fakeCompany)

Expand Down

0 comments on commit 7b21f8f

Please sign in to comment.