Skip to content

Commit 60a4446

Browse files
committed
modify: 검증 완료
1 parent 8650263 commit 60a4446

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

src/controllers/post.controller.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ export class PostController {
9090
) => {
9191
try {
9292
const postId = req.params.postId;
93-
9493
const post = await this.postService.getPostByPostUUID(postId);
9594

9695
const response = new PostResponseDto(true, 'uuid로 post 조회에 성공하였습니다.', { post }, null);

src/middlewares/auth.middleware.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { NextFunction, Request, Response } from 'express';
22
import { isUUID } from 'class-validator';
33
import logger from '@/configs/logger.config';
44
import pool from '@/configs/db.config';
5-
import { InvalidTokenError } from '@/exception';
5+
import { DBError, InvalidTokenError } from '@/exception';
66
import { VelogJWTPayload, User } from '@/types';
77

88
/**
@@ -52,9 +52,10 @@ const verifyBearerTokens = () => {
5252
}
5353

5454
const user = (await pool.query('SELECT * FROM "users_user" WHERE velog_uuid = $1', [payload.user_id])).rows[0] as User;
55+
if (!user) throw new DBError('사용자를 찾을 수 없습니다.');
56+
5557
req.user = user;
5658
req.tokens = { accessToken, refreshToken };
57-
5859
next();
5960
} catch (error) {
6061
logger.error('인증 처리중 오류가 발생하였습니다. : ', error);

src/modules/__test__/velog.api.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ describe('Velog API', () => {
4141
mockedAxios.post.mockResolvedValueOnce(mockResponse);
4242

4343
const result = await fetchVelogApi(mockAccessToken, mockRefreshToken);
44+
const query = VELOG_QUERIES.LOGIN;
4445

4546
// 결과 검증
4647
expect(result).toEqual({
@@ -56,7 +57,7 @@ describe('Velog API', () => {
5657
expect(mockedAxios.post).toHaveBeenCalledTimes(1);
5758
expect(mockedAxios.post).toHaveBeenCalledWith(
5859
VELOG_API_URL,
59-
{ VELOG_QUERIES, variables: {} },
60+
{ query, variables: {} },
6061
{
6162
headers: {
6263
authority: 'v3.velog.io',

src/modules/velog/velog.api.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import axios from 'axios';
33
import logger from '@/configs/logger.config';
44
import { InvalidTokenError } from '@/exception';
55
import { VELOG_API_URL, VELOG_QUERIES } from '@/modules/velog/velog.constans';
6-
import { VelogUserCurrentResponse } from './velog.type';
6+
import { VelogUserCurrentResponse } from '@/types';
77

88
/**
99
* Velog API를 통해 사용자 정보를 조회합니다.
@@ -14,9 +14,10 @@ import { VelogUserCurrentResponse } from './velog.type';
1414
*/
1515
export const fetchVelogApi = async (accessToken: string, refreshToken: string): Promise<VelogUserCurrentResponse> => {
1616
try {
17+
const query = VELOG_QUERIES.LOGIN;
1718
const response = await axios.post(
1819
VELOG_API_URL,
19-
{ VELOG_QUERIES, variables: {} },
20+
{ query, variables: {} },
2021
{
2122
headers: {
2223
authority: 'v3.velog.io',

src/types/express.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { User } from '@/velog.type';
1+
import { User } from '@/types';
22

33
declare global {
44
namespace Express {

0 commit comments

Comments
 (0)