chore: format
This commit is contained in:
@@ -1,70 +1,70 @@
|
||||
import { hashPassword } from "@src/utils/auth"
|
||||
import { faker } from "@faker-js/faker"
|
||||
import { prisma } from "@src/utils/prisma"
|
||||
import { hashPassword } from "@src/utils/auth";
|
||||
import { faker } from "@faker-js/faker";
|
||||
import { prisma } from "@src/utils/prisma";
|
||||
|
||||
export async function createUser() {
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
name: faker.person.fullName(),
|
||||
email: faker.internet.email(),
|
||||
password: await hashPassword("password123"),
|
||||
UserOrganizations: {
|
||||
create: {
|
||||
Organization: {
|
||||
create: {
|
||||
name: faker.company.name(),
|
||||
description: faker.lorem.sentence(),
|
||||
GeneralSettings: {
|
||||
create: {},
|
||||
},
|
||||
EmailDeliverySettings: {
|
||||
create: {
|
||||
rateLimit: 100,
|
||||
},
|
||||
},
|
||||
SmtpSettings: {
|
||||
create: {
|
||||
host: "smtp.test.com",
|
||||
port: 587,
|
||||
username: "test",
|
||||
password: "test",
|
||||
encryption: "STARTTLS",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
include: {
|
||||
UserOrganizations: {
|
||||
select: {
|
||||
organizationId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
name: faker.person.fullName(),
|
||||
email: faker.internet.email(),
|
||||
password: await hashPassword("password123"),
|
||||
UserOrganizations: {
|
||||
create: {
|
||||
Organization: {
|
||||
create: {
|
||||
name: faker.company.name(),
|
||||
description: faker.lorem.sentence(),
|
||||
GeneralSettings: {
|
||||
create: {},
|
||||
},
|
||||
EmailDeliverySettings: {
|
||||
create: {
|
||||
rateLimit: 100,
|
||||
},
|
||||
},
|
||||
SmtpSettings: {
|
||||
create: {
|
||||
host: "smtp.test.com",
|
||||
port: 587,
|
||||
username: "test",
|
||||
password: "test",
|
||||
encryption: "STARTTLS",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
include: {
|
||||
UserOrganizations: {
|
||||
select: {
|
||||
organizationId: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const orgId = user.UserOrganizations[0]?.organizationId || ""
|
||||
if (!orgId) {
|
||||
throw new Error("Organization not found")
|
||||
}
|
||||
const orgId = user.UserOrganizations[0]?.organizationId || "";
|
||||
if (!orgId) {
|
||||
throw new Error("Organization not found");
|
||||
}
|
||||
|
||||
// New API Key
|
||||
const apiKey = await prisma.apiKey.create({
|
||||
data: {
|
||||
key: faker.string.uuid(),
|
||||
name: "Test API Key",
|
||||
Organization: {
|
||||
connect: {
|
||||
id: orgId,
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
key: true,
|
||||
},
|
||||
})
|
||||
// New API Key
|
||||
const apiKey = await prisma.apiKey.create({
|
||||
data: {
|
||||
key: faker.string.uuid(),
|
||||
name: "Test API Key",
|
||||
Organization: {
|
||||
connect: {
|
||||
id: orgId,
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
key: true,
|
||||
},
|
||||
});
|
||||
|
||||
return { user, apiKey, orgId }
|
||||
return { user, apiKey, orgId };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user