Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | 11x 3x 1x 1x 2x 2x 2x 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x | import { PrismaClient } from '@prisma/client';
import { JwtService } from '@nestjs/jwt';
import { ConfigService } from '@nestjs/config';
async function createDefaultUser(prisma: PrismaClient) {
await prisma.user.create({
data: {
email: 'default@mail.com',
password: 'Password1',
id: 'defaultId',
avatarId: 'defaultAvatarId',
name: 'defaultName',
description: 'defaultDescription',
},
});
}
async function createDefaultBand(prisma: PrismaClient, founderId: string) {
await prisma.band.create({
data: {
id: '3c9887c3-ebbd-4773-a6fd-36fc7641426e',
founderId: founderId,
name: 'defaultBandName',
description: 'defaultBandDescription',
avatarId: 'defaultBandAvatarId',
},
});
}
async function generateTokenDefaultUser(
jwtService: JwtService,
configService: ConfigService,
) {
const payload = {
userId: 'defaultId',
};
return jwtService.sign(payload, {
expiresIn: '10h',
secret: configService.get<string>('JWT_SECRET'),
});
}
async function createDefaultInstrument(prisma: PrismaClient) {
await prisma.instrument.create({
data: {
id: 'defaultInstrument',
name: 'defaultInstrument',
},
});
const getInstrument = await prisma.instrument.findFirst({
where: {
name: 'defaultInstrument',
},
});
return getInstrument?.id;
}
async function relateSkillToUser(prisma: PrismaClient) {
await prisma.userInstrument.create({
data: {
userId: 'defaultId',
instrumentId: 'defaultInstrument',
skillLevel: 3,
},
});
}
async function createExtraDefaultUserAndInstrument(prisma: PrismaClient) {
await prisma.user.create({
data: {
email: 'default2@mail.com',
password: 'Password2',
id: 'defaultId2',
avatarId: 'defaultAvatarId',
name: 'defaultName2',
description: 'defaultDescription',
},
});
await prisma.instrument.create({
data: {
id: 'defaultInstrument2',
name: 'defaultInstrument2',
},
});
}
async function createCompleteDefaultBand(
prisma: PrismaClient,
founderId: string,
instrumentId: string,
) {
return prisma.band.create({
data: {
id: '3c9887c3-ebbd-4773-a6fd-36fc7641426e',
founderId: founderId,
name: 'defaultBandName',
description: 'defaultBandDescription',
avatarId: 'defaultBandAvatarId',
users: {
create: [
{ userId: founderId, instrumentId: instrumentId },
{ userId: 'defaultId2', instrumentId: 'defaultInstrument2' },
],
},
slots: {
create: [{ instrumentId: instrumentId, status: 'VACANT' }],
},
},
});
}
export {
createDefaultUser,
createDefaultBand,
generateTokenDefaultUser,
createDefaultInstrument,
relateSkillToUser,
createExtraDefaultUserAndInstrument,
createCompleteDefaultBand,
};
|