Skip to content

Commit aadfeae

Browse files
committed
refactor: 코드 전체적인 리팩토링
1 parent 3c2bf5d commit aadfeae

File tree

16 files changed

+93
-58
lines changed

16 files changed

+93
-58
lines changed

apps/backend/src/auth/auth.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class AuthService {
3131
async findUserById(id: number): Promise<User | null> {
3232
return await this.userRepository.findOneBy({ id });
3333
}
34+
3435
async updateUser(id: number, dto: UpdateUserDto) {
3536
// 유저를 찾는다.
3637
const findUser = await this.userRepository.findOneBy({ id });

apps/backend/src/auth/strategies/kakao.strategy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class KakaoStrategy extends PassportStrategy(Strategy, 'kakao') {
2222
provider: 'kakao',
2323
email: profile._json.kakao_account.email,
2424
};
25+
2526
let user = await this.authService.findUser(createUserDto);
2627
if (!user) {
2728
user = await this.authService.signUp(createUserDto);

apps/backend/src/auth/strategies/naver.strategy.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export class NaverStrategy extends PassportStrategy(Strategy, 'naver') {
2222
provider: 'naver',
2323
email: profile._json.email,
2424
};
25+
2526
let user = await this.authService.findUser(createUserDto);
2627
if (!user) {
2728
user = await this.authService.signUp(createUserDto);

apps/backend/src/auth/token/token.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class TokenService {
2626
generateInviteToken(workspaceId: number, role: string): string {
2727
// 초대용 JWT 토큰 생성
2828
const payload = { workspaceId, role };
29+
2930
return this.jwtService.sign(payload, {
3031
expiresIn: DAY, // 초대 유효 기간: 1일
3132
secret: process.env.JWT_SECRET,
@@ -38,8 +39,6 @@ export class TokenService {
3839
});
3940
}
4041

41-
// 후에 DB 로직 (지금은 refreshToken이 DB로 관리 X)
42-
// 추가될 때를 위해 일단 비동기 선언
4342
async refreshAccessToken(refreshToken: string): Promise<string> {
4443
// refreshToken을 검증한다
4544
const decoded = this.jwtService.verify(refreshToken, {
@@ -76,6 +75,7 @@ export class TokenService {
7675
secure: true,
7776
sameSite: 'strict',
7877
});
78+
7979
response.clearCookie('refreshToken', {
8080
httpOnly: true,
8181
secure: true,

apps/backend/src/edge/edge.controller.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class EdgeController {
3131
@HttpCode(HttpStatus.CREATED)
3232
async createEdge(@Body() body: CreateEdgeDto) {
3333
await this.edgeService.createEdge(body);
34+
3435
return {
3536
message: EdgeResponseMessage.EDGE_CREATED,
3637
};
@@ -44,6 +45,7 @@ export class EdgeController {
4445
@Param('id', ParseIntPipe) id: number,
4546
): Promise<{ message: string }> {
4647
await this.edgeService.deleteEdge(id);
48+
4749
return {
4850
message: EdgeResponseMessage.EDGE_DELETED,
4951
};
@@ -59,6 +61,7 @@ export class EdgeController {
5961
@Param('workspaceId') workspaceId: string, // Snowflake ID
6062
): Promise<FindEdgesResponseDto> {
6163
const edges = await this.edgeService.findEdgesByWorkspace(workspaceId);
64+
6265
return {
6366
message: EdgeResponseMessage.EDGES_RETURNED,
6467
edges,

apps/backend/src/node/node.controller.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export class NodeController {
4545
@HttpCode(HttpStatus.OK)
4646
async getNodeById(@Param('id', ParseIntPipe) id: number) {
4747
const node = await this.nodeService.findNodeById(id);
48+
4849
return {
4950
message: NodeResponseMessage.NODE_RETURNED,
5051
node: node,
@@ -59,6 +60,7 @@ export class NodeController {
5960
@HttpCode(HttpStatus.CREATED)
6061
async createNode(@Body() body: CreateNodeDto) {
6162
await this.nodeService.createNode(body);
63+
6264
return {
6365
message: NodeResponseMessage.NODE_CREATED,
6466
};
@@ -76,6 +78,7 @@ export class NodeController {
7678
@Param('id', ParseIntPipe) id: number,
7779
): Promise<{ message: string }> {
7880
await this.nodeService.deleteNode(id);
81+
7982
return {
8083
message: NodeResponseMessage.NODE_DELETED,
8184
};
@@ -92,6 +95,7 @@ export class NodeController {
9295
@Body() body: UpdateNodeDto,
9396
): Promise<{ message: string }> {
9497
await this.nodeService.updateNode(id, body);
98+
9599
return {
96100
message: NodeResponseMessage.NODE_UPDATED,
97101
};
@@ -105,6 +109,7 @@ export class NodeController {
105109
@HttpCode(HttpStatus.OK)
106110
async getCoordinates(@Param('id', ParseIntPipe) id: number) {
107111
const coordinate = await this.nodeService.getCoordinates(id);
112+
108113
return {
109114
message: NodeResponseMessage.NODE_GET_COORDINAE,
110115
coordinate: coordinate,
@@ -118,6 +123,7 @@ export class NodeController {
118123
@Body() body: MoveNodeDto,
119124
) {
120125
await this.nodeService.moveNode(id, body);
126+
121127
return {
122128
message: NodeResponseMessage.NODE_MOVED,
123129
};
@@ -133,6 +139,7 @@ export class NodeController {
133139
@Param('workspaceId') workspaceId: string, // Snowflake ID
134140
): Promise<FindNodesResponseDto> {
135141
const nodes = await this.nodeService.findNodesByWorkspace(workspaceId);
142+
136143
return {
137144
message: NodeResponseMessage.NODES_RETURNED,
138145
nodes,

apps/backend/src/node/node.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class NodeService {
3434
async createLinkedNode(x: number, y: number, pageId: number): Promise<Node> {
3535
// 페이지를 조회한다.
3636
const existingPage = await this.pageRepository.findOneBy({ id: pageId });
37+
3738
// 노드를 생성한다.
3839
const node = this.nodeRepository.create({ x, y });
3940

@@ -71,6 +72,7 @@ export class NodeService {
7172
if (!node) {
7273
throw new NodeNotFoundException();
7374
}
75+
7476
// 노드와 연결된 페이지를 조회한다.
7577
const linkedPage = await this.pageRepository.findOneBy({
7678
id: node.page.id,

apps/backend/src/page/page.controller.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export class PageController {
4545
@Body() body: CreatePageDto,
4646
): Promise<CreatePageResponseDto> {
4747
const newPage = await this.pageService.createPage(body);
48+
4849
return {
4950
message: PageResponseMessage.PAGE_CREATED,
5051
pageId: newPage.id,
@@ -63,6 +64,7 @@ export class PageController {
6364
@Param('id', ParseIntPipe) id: number,
6465
): Promise<MessageResponseDto> {
6566
await this.pageService.deletePage(id);
67+
6668
return {
6769
message: PageResponseMessage.PAGE_DELETED,
6870
};
@@ -79,6 +81,7 @@ export class PageController {
7981
@Body() body: UpdatePageDto,
8082
): Promise<MessageResponseDto> {
8183
await this.pageService.updatePage(id, body);
84+
8285
return {
8386
message: PageResponseMessage.PAGE_UPDATED,
8487
};
@@ -94,6 +97,7 @@ export class PageController {
9497
@Param('workspaceId') workspaceId: string, // Snowflake ID
9598
): Promise<FindPagesResponseDto> {
9699
const pages = await this.pageService.findPagesByWorkspace(workspaceId);
100+
97101
return {
98102
message: PageResponseMessage.PAGES_RETURNED,
99103
pages,

apps/backend/src/page/page.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { WorkspaceNotFoundException } from '../exception/workspace.exception';
1111
import Redlock from 'redlock';
1212

1313
const RED_LOCK_TOKEN = 'RED_LOCK';
14+
1415
@Injectable()
1516
export class PageService {
1617
constructor(

apps/backend/src/redis/redis.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ type RedisPage = {
99
title?: string;
1010
content?: string;
1111
};
12+
1213
@Injectable()
1314
export class RedisService {
14-
// private readonly redisClient: Redis;
15-
1615
constructor(
1716
@Inject(REDIS_CLIENT_TOKEN) private readonly redisClient: Redis,
1817
@Inject(RED_LOCK_TOKEN) private readonly redisLock: Redlock,

0 commit comments

Comments
 (0)