Skip to content

Commit 6a63e00

Browse files
committed
feature: prettier 적용, 와 우리 많이 놓쳤다 ㅋㅋㅋㅋ
1 parent b25705c commit 6a63e00

25 files changed

+94
-116
lines changed

src/controllers/noti.controller.ts

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
11
import { NextFunction, Request, RequestHandler, Response } from 'express';
22
import logger from '@/configs/logger.config';
3-
import { NotiService } from "@/services/noti.service";
4-
import { NotiPostsResponseDto } from "@/types/dto/responses/notiResponse.type";
3+
import { NotiService } from '@/services/noti.service';
4+
import { NotiPostsResponseDto } from '@/types/dto/responses/notiResponse.type';
55

66
export class NotiController {
7-
constructor(private notiService: NotiService) { }
7+
constructor(private notiService: NotiService) {}
88

9-
getAllNotiPosts: RequestHandler = async (
10-
req: Request,
11-
res: Response<NotiPostsResponseDto>,
12-
next: NextFunction,
13-
) => {
9+
getAllNotiPosts: RequestHandler = async (req: Request, res: Response<NotiPostsResponseDto>, next: NextFunction) => {
1410
try {
1511
const result = await this.notiService.getAllNotiPosts();
16-
const response = new NotiPostsResponseDto(
17-
true,
18-
'전체 noti post 조회에 성공하였습니다.',
19-
{ posts: result },
20-
null,
21-
);
12+
const response = new NotiPostsResponseDto(true, '전체 noti post 조회에 성공하였습니다.', { posts: result }, null);
2213
res.status(200).json(response);
2314
} catch (error) {
2415
logger.error('전체 조회 실패:', error);
2516
next(error);
2617
}
2718
};
28-
}
19+
}

src/controllers/post.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '@/types';
1212

1313
export class PostController {
14-
constructor(private postService: PostService) { }
14+
constructor(private postService: PostService) {}
1515

1616
getAllPosts: RequestHandler = async (
1717
req: Request<object, object, object, GetAllPostsQuery>,

src/controllers/totalStats.controller.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { BadRequestError } from '@/exception';
44
import { GetTotalStatsQuery, TotalStatsResponseDto } from '@/types';
55
import { TotalStatsService } from '@/services/totalStats.service';
66

7-
87
export class TotalStatsController {
9-
constructor(private totalStatsService: TotalStatsService) { }
8+
constructor(private totalStatsService: TotalStatsService) {}
109

1110
getTotalStats: RequestHandler = async (
1211
req: Request<object, object, object, GetTotalStatsQuery>,
@@ -23,17 +22,12 @@ export class TotalStatsController {
2322
const stats = await this.totalStatsService.getTotalStats(id, period, type);
2423
const message = this.totalStatsService.getSuccessMessage(type);
2524

26-
const response = new TotalStatsResponseDto(
27-
true,
28-
message,
29-
stats,
30-
null,
31-
);
25+
const response = new TotalStatsResponseDto(true, message, stats, null);
3226

3327
res.status(200).json(response);
3428
} catch (error) {
3529
logger.error('전체 통계 조회 실패:', error);
3630
next(error);
3731
}
3832
};
39-
}
33+
}

src/controllers/user.controller.ts

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { fetchVelogApi } from '@/modules/velog/velog.api';
99
type Token10 = string & { __lengthBrand: 10 };
1010

1111
export class UserController {
12-
constructor(private userService: UserService) { }
12+
constructor(private userService: UserService) {}
1313

1414
private cookieOption(): CookieOptions {
1515
const isProd = process.env.NODE_ENV === 'production';
@@ -21,7 +21,7 @@ export class UserController {
2121

2222
if (isProd) {
2323
baseOptions.sameSite = 'lax';
24-
baseOptions.domain = "velog-dashboard.kro.kr";
24+
baseOptions.domain = 'velog-dashboard.kro.kr';
2525
} else {
2626
baseOptions.domain = 'localhost';
2727
}
@@ -31,7 +31,6 @@ export class UserController {
3131

3232
login: RequestHandler = async (req: Request, res: Response<LoginResponseDto>, next: NextFunction): Promise<void> => {
3333
try {
34-
3534
// 1. 외부 API (velog) 호출로 실존 하는 토큰 & 사용자 인지 검증
3635
const { accessToken, refreshToken } = req.body;
3736
const velogUser = await fetchVelogApi(accessToken, refreshToken);
@@ -60,7 +59,11 @@ export class UserController {
6059
}
6160
};
6261

63-
sampleLogin: RequestHandler = async (req: Request, res: Response<LoginResponseDto>, next: NextFunction): Promise<void> => {
62+
sampleLogin: RequestHandler = async (
63+
req: Request,
64+
res: Response<LoginResponseDto>,
65+
next: NextFunction,
66+
): Promise<void> => {
6467
try {
6568
const sampleUser = await this.userService.findSampleUser();
6669

@@ -77,8 +80,8 @@ export class UserController {
7780
'로그인에 성공하였습니다.',
7881
{
7982
id: sampleUser.user.id,
80-
username: "테스트 유저",
81-
profile: { "thumbnail": "https://velog.io/favicon.ico" }
83+
username: '테스트 유저',
84+
profile: { thumbnail: 'https://velog.io/favicon.ico' },
8285
},
8386
null,
8487
);
@@ -88,7 +91,7 @@ export class UserController {
8891
logger.error('로그인 실패 : ', error);
8992
next(error);
9093
}
91-
}
94+
};
9295

9396
logout: RequestHandler = async (req: Request, res: Response<EmptyResponseDto>) => {
9497
res.clearCookie('access_token', this.cookieOption());
@@ -114,25 +117,19 @@ export class UserController {
114117
res.status(200).json(response);
115118
};
116119

117-
createToken: RequestHandler = async (
118-
req: Request,
119-
res: Response<QRLoginTokenResponseDto>,
120-
next: NextFunction,
121-
) => {
120+
createToken: RequestHandler = async (req: Request, res: Response<QRLoginTokenResponseDto>, next: NextFunction) => {
122121
try {
123122
const user = req.user;
124-
const ip = typeof req.headers['x-forwarded-for'] === 'string' ? req.headers['x-forwarded-for'].split(',')[0].trim() : req.ip ?? '';
123+
const ip =
124+
typeof req.headers['x-forwarded-for'] === 'string'
125+
? req.headers['x-forwarded-for'].split(',')[0].trim()
126+
: (req.ip ?? '');
125127
const userAgent = req.headers['user-agent'] || '';
126128

127129
const token = await this.userService.createUserQRToken(user.id, ip, userAgent);
128130
const typedToken = token as Token10;
129131

130-
const response = new QRLoginTokenResponseDto(
131-
true,
132-
'QR 토큰 생성 완료',
133-
{ token: typedToken },
134-
null
135-
);
132+
const response = new QRLoginTokenResponseDto(true, 'QR 토큰 생성 완료', { token: typedToken }, null);
136133
res.status(200).json(response);
137134
} catch (error) {
138135
logger.error(`QR 토큰 생성 실패: [userId: ${req.user?.id || 'anonymous'}]`, error);

src/exception/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
export { CustomError } from './custom.exception';
22
export { DBError } from './db.exception';
3-
export { TokenError, TokenExpiredError, InvalidTokenError, QRTokenExpiredError, QRTokenInvalidError } from './token.exception';
3+
export {
4+
TokenError,
5+
TokenExpiredError,
6+
InvalidTokenError,
7+
QRTokenExpiredError,
8+
QRTokenInvalidError,
9+
} from './token.exception';
410
export { UnauthorizedError } from './unauthorized.exception';
511
export { BadRequestError } from './badRequest.exception';
612
export { NotFoundError } from './notFound.exception';

src/middlewares/auth.middleware.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ const extractTokens = (req: Request): { accessToken: string; refreshToken: strin
3232
* const payload = extractPayload(token);
3333
* // 반환값: { sub: "1234567890" }
3434
*/
35-
const extractPayload = (token: string): VelogJWTPayload => JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString());
35+
const extractPayload = (token: string): VelogJWTPayload =>
36+
JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString());
3637

3738
/**
3839
* Bearer 토큰을 검증한뒤 user정보를 Request 객체에 담는 인가 함수
@@ -51,7 +52,8 @@ const verifyBearerTokens = () => {
5152
throw new InvalidTokenError('유효하지 않은 토큰 페이로드 입니다.');
5253
}
5354

54-
const user = (await pool.query('SELECT * FROM "users_user" WHERE velog_uuid = $1', [payload.user_id])).rows[0] as User;
55+
const user = (await pool.query('SELECT * FROM "users_user" WHERE velog_uuid = $1', [payload.user_id]))
56+
.rows[0] as User;
5557
if (!user) throw new DBError('사용자를 찾을 수 없습니다.');
5658

5759
req.user = user;

src/repositories/__test__/leaderboard.repo.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Pool } from 'pg';
22
import { DBError } from '@/exception';
33
import { LeaderboardRepository } from '@/repositories/leaderboard.repository';
44
import { UserLeaderboardSortType, PostLeaderboardSortType } from '@/types';
5-
import { mockPool, createMockQueryResult } from './fixture';
5+
import { mockPool, createMockQueryResult } from './fixtures';
66

77
jest.mock('pg');
88

src/repositories/__test__/post.repo.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Pool } from 'pg';
22
import { PostRepository } from '@/repositories/post.repository';
33
import { DBError } from '@/exception';
4-
import { mockPool, createMockQueryResult } from './fixture';
4+
import { mockPool, createMockQueryResult } from './fixtures';
55

66
jest.mock('pg');
77

src/repositories/__test__/qr.repo.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { UserRepository } from '@/repositories/user.repository';
22
import { DBError } from '@/exception';
33
import { Pool } from 'pg';
44
import { QRLoginToken } from "@/types/models/QRLoginToken.type";
5-
import { mockPool } from './fixture';
5+
import { mockPool } from './fixtures';
66

77
jest.mock('pg');
88

0 commit comments

Comments
 (0)