Skip to content

Commit 878d2a4

Browse files
committed
fix: 모델 변경에 맞춰서 수정
1 parent 81b5cc4 commit 878d2a4

10 files changed

+30
-30
lines changed

nestjs-BE/server/src/auth/auth.controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class AuthController {
4545
const userData = { email: kakaoUserAccount.email };
4646
const user = await this.usersService.getOrCreateUser(userData);
4747
const profileData = {
48-
user_id: user.uuid,
48+
userUuid: user.uuid,
4949
image: this.configService.get<string>('BASE_IMAGE_URL'),
5050
nickname: '익명의 사용자',
5151
};

nestjs-BE/server/src/auth/auth.service.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('AuthService', () => {
5858
jest.spyOn(jwtService, 'verify').mockReturnValue({});
5959
jest.spyOn(jwtService, 'signAsync').mockResolvedValue('access token');
6060
jest.spyOn(refreshTokensService, 'findRefreshToken').mockResolvedValue({
61-
user_id: 'user uuid',
61+
userUuid: 'user uuid',
6262
} as RefreshToken);
6363

6464
const token = service.renewAccessToken('refresh token');

nestjs-BE/server/src/auth/refresh-tokens.service.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ describe('RefreshTokensService', () => {
5454
const testToken = {
5555
id: 0,
5656
token: 'Token',
57-
expiry_date: service.getExpiryDate(),
58-
user_id: 'UserId',
57+
expiryDate: service.getExpiryDate(),
58+
userUuid: 'UserId',
5959
};
6060
jest.spyOn(prisma.refreshToken, 'findUnique').mockResolvedValue(testToken);
6161

@@ -76,8 +76,8 @@ describe('RefreshTokensService', () => {
7676
const testToken = {
7777
id: 0,
7878
token: 'Token',
79-
expiry_date: service.getExpiryDate(),
80-
user_id: 'userId',
79+
expiryDate: service.getExpiryDate(),
80+
userUuid: 'userId',
8181
};
8282
jest.spyOn(prisma.refreshToken, 'create').mockResolvedValue(testToken);
8383

@@ -105,8 +105,8 @@ describe('RefreshTokensService', () => {
105105
const testToken = {
106106
id: 0,
107107
token: 'Token',
108-
expiry_date: service.getExpiryDate(),
109-
user_id: 'userId',
108+
expiryDate: service.getExpiryDate(),
109+
userUuid: 'userId',
110110
};
111111
jest.spyOn(prisma.refreshToken, 'delete').mockResolvedValue(testToken);
112112

nestjs-BE/server/src/auth/refresh-tokens.service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export class RefreshTokensService {
1818
return this.prisma.refreshToken.create({
1919
data: {
2020
token: this.createToken(),
21-
expiry_date: this.getExpiryDate(),
22-
user_id: userUuid,
21+
expiryDate: this.getExpiryDate(),
22+
userUuid,
2323
},
2424
});
2525
}

nestjs-BE/server/src/invite-codes/invite-codes.controller.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class InviteCodesController {
4444
return {
4545
statusCode: 201,
4646
message: 'Created',
47-
data: { invite_code: inviteCode.invite_code },
47+
data: { invite_code: inviteCode.inviteCode },
4848
};
4949
}
5050

@@ -66,11 +66,11 @@ export class InviteCodesController {
6666
const inviteCodeData =
6767
await this.inviteCodesService.findInviteCode(inviteCode);
6868
if (!inviteCodeData) throw new NotFoundException();
69-
if (this.inviteCodesService.checkExpiry(inviteCodeData.expiry_date)) {
69+
if (this.inviteCodesService.checkExpiry(inviteCodeData.expiryDate)) {
7070
this.inviteCodesService.deleteInviteCode(inviteCode);
7171
throw new HttpException('Invite code has expired.', HttpStatus.GONE);
7272
}
73-
const space = await this.spacesService.findSpace(inviteCodeData.space_uuid);
73+
const space = await this.spacesService.findSpace(inviteCodeData.spaceUuid);
7474
return { statusCode: 200, message: 'Success', data: space };
7575
}
7676
}

nestjs-BE/server/src/invite-codes/invite-codes.service.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ import generateUuid from '../utils/uuid';
1111
export class InviteCodesService {
1212
constructor(protected prisma: PrismaService) {}
1313

14-
async findInviteCode(inviteCode: string): Promise<InviteCode> {
14+
async findInviteCode(inviteCode: string): Promise<InviteCode | null> {
1515
return this.prisma.inviteCode.findUnique({
16-
where: { invite_code: inviteCode },
16+
where: { inviteCode: inviteCode },
1717
});
1818
}
1919

2020
async createInviteCode(spaceUuid: string): Promise<InviteCode> {
2121
return this.prisma.inviteCode.create({
2222
data: {
2323
uuid: generateUuid(),
24-
invite_code: await this.generateUniqueInviteCode(INVITE_CODE_LENGTH),
25-
space_uuid: spaceUuid,
26-
expiry_date: this.calculateExpiryDate(),
24+
inviteCode: await this.generateUniqueInviteCode(INVITE_CODE_LENGTH),
25+
spaceUuid: spaceUuid,
26+
expiryDate: this.calculateExpiryDate(),
2727
},
2828
});
2929
}
3030

31-
async deleteInviteCode(inviteCode: string): Promise<InviteCode> {
31+
async deleteInviteCode(inviteCode: string): Promise<InviteCode | null> {
3232
try {
3333
return await this.prisma.inviteCode.delete({
3434
where: {
35-
invite_code: inviteCode,
35+
inviteCode: inviteCode,
3636
},
3737
});
3838
} catch (err) {
@@ -70,7 +70,7 @@ export class InviteCodesService {
7070

7171
private async generateUniqueInviteCode(length: number): Promise<string> {
7272
let inviteCode: string;
73-
let inviteCodeData: InviteCode;
73+
let inviteCodeData: InviteCode | null;
7474

7575
do {
7676
inviteCode = this.generateShortInviteCode(length);

nestjs-BE/server/src/profiles/dto/create-profile.dto.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { MaxLength } from 'class-validator';
33
import { MAX_NAME_LENGTH } from '../../config/magic-number';
44

55
export class CreateProfileDto {
6-
user_id: string;
6+
userUuid: string;
77

88
@ApiProperty({
99
example: 'profile-image.png',

nestjs-BE/server/src/profiles/profiles.controller.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('ProfilesController', () => {
3131
const requestMock = { user: { uuid: 'user test uuid' } } as RequestWithUser;
3232
const testProfile = {
3333
uuid: 'profile test uuid',
34-
user_id: requestMock.user.uuid,
34+
userUuid: requestMock.user.uuid,
3535
image: 'www.test.com/image',
3636
nickname: 'test nickname',
3737
};
@@ -67,7 +67,7 @@ describe('ProfilesController', () => {
6767
const testImageUrl = 'www.test.com/image';
6868
const testProfile = {
6969
uuid: 'profile test uuid',
70-
user_id: requestMock.user.uuid,
70+
userUuid: requestMock.user.uuid,
7171
image: 'www.test.com/image',
7272
nickname: 'test nickname',
7373
};

nestjs-BE/server/src/profiles/profiles.service.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('ProfilesService', () => {
3434
const userId = generateUuid();
3535
const testProfile = {
3636
uuid: generateUuid(),
37-
user_id: userId,
37+
userUuid: userId,
3838
image: 'www.test.com/image',
3939
nickname: 'test nickname',
4040
};
@@ -62,7 +62,7 @@ describe('ProfilesService', () => {
6262
const testProfiles = profileUuids.map((uuid, index) => {
6363
return {
6464
uuid,
65-
user_id: generateUuid(),
65+
userUuid: generateUuid(),
6666
image: 'www.test.com/image',
6767
nickname: `nickname${index}`,
6868
};
@@ -85,7 +85,7 @@ describe('ProfilesService', () => {
8585

8686
it('getOrCreateProfile', async () => {
8787
const data = {
88-
user_id: generateUuid(),
88+
userUuid: generateUuid(),
8989
image: 'www.test.com/image',
9090
nickname: 'test nickname',
9191
};
@@ -103,7 +103,7 @@ describe('ProfilesService', () => {
103103
nickname: 'test nickname',
104104
};
105105
const uuid = generateUuid();
106-
const testProfile = { uuid: generateUuid(), user_id: uuid, ...data };
106+
const testProfile = { uuid: generateUuid(), userUuid: uuid, ...data };
107107
jest.spyOn(prisma.profile, 'update').mockResolvedValue(testProfile);
108108

109109
const profile = profilesService.updateProfile(uuid, data);

nestjs-BE/server/src/profiles/profiles.service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ export class ProfilesService {
2525

2626
async getOrCreateProfile(data: CreateProfileDto): Promise<Profile> {
2727
return this.prisma.profile.upsert({
28-
where: { userUuid: data.user_id },
28+
where: { userUuid: data.userUuid },
2929
update: {},
3030
create: {
3131
uuid: generateUuid(),
32-
userUuid: data.user_id,
32+
userUuid: data.userUuid,
3333
image: data.image,
3434
nickname: data.nickname,
3535
},

0 commit comments

Comments
 (0)