Skip to content

Commit d099a2f

Browse files
authored
[25.06.03 / TASK-191]Feature - 전체 조회수/좋아요/게시글 디테일 API 대응개발 (#33)
* feature: 전체 조회수/좋아요/게시글 디테일 API 기본 비즈니스 로직 완성 * feature: repo 테스트에 필수인 모킹 객체들 fixture 로 분리, 공통 fixture 사용 * feature: total Stats repo 계층 테스트 코드 추가 * feature: fixture jsdocs 추가 * feature: prettier 적용, 와 우리 많이 놓쳤다 ㅋㅋㅋㅋ * feature: router 매핑, 전체 끝 * modify: 오탈자 수정 * modify: 게시글 통계를 증가량 대신 그날 누적 게시글 수 통계로 * modify: totla stats 의 서비스 arguments 에 모두 default 값 넣는 방향으로 * modify: 포메팅
1 parent 059a4c0 commit d099a2f

33 files changed

+964
-163
lines changed

.gitignore

Lines changed: 235 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Node.js 기본
2-
node_modules/
3-
pnpm-debug.log*
4-
51
# 환경 변수 및 인증 정보
62
.env
73
.env.local
@@ -17,22 +13,246 @@ dist/
1713
*.swp
1814
*.swo
1915

20-
# OS별 시스템 파일
21-
.DS_Store
22-
Thumbs.db
23-
2416
# 로그 파일
2517
logs/*
2618
*.log
2719
*.gz
2820
*.out
2921

30-
# 빌드 및 캐시 파일
31-
.cache/
32-
build/
33-
temp/
34-
tmp/
22+
# Created by https://www.toptal.com/developers/gitignore/api/macos,windows,visualstudiocode,node,git
23+
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,windows,visualstudiocode,node,git
24+
25+
### Git ###
26+
# Created by git for backups. To disable backups in Git:
27+
# $ git config --global mergetool.keepBackup false
28+
*.orig
29+
30+
# Created by git when using merge tools for conflicts
31+
*.BACKUP.*
32+
*.BASE.*
33+
*.LOCAL.*
34+
*.REMOTE.*
35+
*_BACKUP_*.txt
36+
*_BASE_*.txt
37+
*_LOCAL_*.txt
38+
*_REMOTE_*.txt
39+
40+
### macOS ###
41+
# General
42+
.DS_Store
43+
.AppleDouble
44+
.LSOverride
45+
46+
# Icon must end with two \r
47+
Icon
48+
49+
50+
# Thumbnails
51+
._*
52+
53+
# Files that might appear in the root of a volume
54+
.DocumentRevisions-V100
55+
.fseventsd
56+
.Spotlight-V100
57+
.TemporaryItems
58+
.Trashes
59+
.VolumeIcon.icns
60+
.com.apple.timemachine.donotpresent
61+
62+
# Directories potentially created on remote AFP share
63+
.AppleDB
64+
.AppleDesktop
65+
Network Trash Folder
66+
Temporary Items
67+
.apdisk
68+
69+
### macOS Patch ###
70+
# iCloud generated files
71+
*.icloud
72+
73+
### Node ###
74+
# Logs
75+
logs
76+
*.log
77+
npm-debug.log*
78+
yarn-debug.log*
79+
yarn-error.log*
80+
lerna-debug.log*
81+
.pnpm-debug.log*
3582

36-
# 테스트 출력
37-
coverage/
83+
# Diagnostic reports (https://nodejs.org/api/report.html)
84+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
85+
86+
# Runtime data
87+
pids
88+
*.pid
89+
*.seed
90+
*.pid.lock
91+
92+
# Directory for instrumented libs generated by jscoverage/JSCover
93+
lib-cov
94+
95+
# Coverage directory used by tools like istanbul
96+
coverage
3897
*.lcov
98+
99+
# nyc test coverage
100+
.nyc_output
101+
102+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
103+
.grunt
104+
105+
# Bower dependency directory (https://bower.io/)
106+
bower_components
107+
108+
# node-waf configuration
109+
.lock-wscript
110+
111+
# Compiled binary addons (https://nodejs.org/api/addons.html)
112+
build/Release
113+
114+
# Dependency directories
115+
node_modules/
116+
jspm_packages/
117+
118+
# Snowpack dependency directory (https://snowpack.dev/)
119+
web_modules/
120+
121+
# TypeScript cache
122+
*.tsbuildinfo
123+
124+
# Optional npm cache directory
125+
.npm
126+
127+
# Optional eslint cache
128+
.eslintcache
129+
130+
# Optional stylelint cache
131+
.stylelintcache
132+
133+
# Microbundle cache
134+
.rpt2_cache/
135+
.rts2_cache_cjs/
136+
.rts2_cache_es/
137+
.rts2_cache_umd/
138+
139+
# Optional REPL history
140+
.node_repl_history
141+
142+
# Output of 'npm pack'
143+
*.tgz
144+
145+
# Yarn Integrity file
146+
.yarn-integrity
147+
148+
# dotenv environment variable files
149+
.env
150+
.env.development.local
151+
.env.test.local
152+
.env.production.local
153+
.env.local
154+
155+
# parcel-bundler cache (https://parceljs.org/)
156+
.cache
157+
.parcel-cache
158+
159+
# Next.js build output
160+
.next
161+
out
162+
163+
# Nuxt.js build / generate output
164+
.nuxt
165+
dist
166+
167+
# Gatsby files
168+
.cache/
169+
# Comment in the public line in if your project uses Gatsby and not Next.js
170+
# https://nextjs.org/blog/next-9-1#public-directory-support
171+
# public
172+
173+
# vuepress build output
174+
.vuepress/dist
175+
176+
# vuepress v2.x temp and cache directory
177+
.temp
178+
179+
# Docusaurus cache and generated files
180+
.docusaurus
181+
182+
# Serverless directories
183+
.serverless/
184+
185+
# FuseBox cache
186+
.fusebox/
187+
188+
# DynamoDB Local files
189+
.dynamodb/
190+
191+
# TernJS port file
192+
.tern-port
193+
194+
# Stores VSCode versions used for testing VSCode extensions
195+
.vscode-test
196+
197+
# yarn v2
198+
.yarn/cache
199+
.yarn/unplugged
200+
.yarn/build-state.yml
201+
.yarn/install-state.gz
202+
.pnp.*
203+
204+
### Node Patch ###
205+
# Serverless Webpack directories
206+
.webpack/
207+
208+
# Optional stylelint cache
209+
210+
# SvelteKit build / generate output
211+
.svelte-kit
212+
213+
### VisualStudioCode ###
214+
.vscode/*
215+
!.vscode/settings.json
216+
!.vscode/tasks.json
217+
!.vscode/launch.json
218+
!.vscode/extensions.json
219+
!.vscode/*.code-snippets
220+
221+
# Local History for Visual Studio Code
222+
.history/
223+
224+
# Built Visual Studio Code Extensions
225+
*.vsix
226+
227+
### VisualStudioCode Patch ###
228+
# Ignore all local history of files
229+
.history
230+
.ionide
231+
232+
### Windows ###
233+
# Windows thumbnail cache files
234+
Thumbs.db
235+
Thumbs.db:encryptable
236+
ehthumbs.db
237+
ehthumbs_vista.db
238+
239+
# Dump file
240+
*.stackdump
241+
242+
# Folder config file
243+
[Dd]esktop.ini
244+
245+
# Recycle Bin used on file shares
246+
$RECYCLE.BIN/
247+
248+
# Windows Installer files
249+
*.cab
250+
*.msi
251+
*.msix
252+
*.msm
253+
*.msp
254+
255+
# Windows shortcuts
256+
*.lnk
257+
258+
# End of https://www.toptal.com/developers/gitignore/api/macos,windows,visualstudiocode,node,git

src/controllers/leaderboard.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
GetPostLeaderboardQuery,
77
UserLeaderboardResponseDto,
88
PostLeaderboardResponseDto,
9-
} from '@/types/index';
9+
} from '@/types';
1010

1111
export class LeaderboardController {
1212
constructor(private leaderboardService: LeaderboardService) {}

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>,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { NextFunction, Request, RequestHandler, Response } from 'express';
2+
import logger from '@/configs/logger.config';
3+
import { GetTotalStatsQuery, TotalStatsResponseDto } from '@/types';
4+
import { TotalStatsService } from '@/services/totalStats.service';
5+
6+
export class TotalStatsController {
7+
constructor(private totalStatsService: TotalStatsService) {}
8+
9+
getTotalStats: RequestHandler = async (
10+
req: Request<object, object, object, GetTotalStatsQuery>,
11+
res: Response<TotalStatsResponseDto>,
12+
next: NextFunction,
13+
) => {
14+
try {
15+
const { id } = req.user;
16+
const { period, type } = req.query;
17+
18+
const stats = await this.totalStatsService.getTotalStats(id, period, type);
19+
const message = this.totalStatsService.getSuccessMessage(type);
20+
21+
const response = new TotalStatsResponseDto(true, message, stats, null);
22+
23+
res.status(200).json(response);
24+
} catch (error) {
25+
logger.error('전체 통계 조회 실패:', error);
26+
next(error);
27+
}
28+
};
29+
}

0 commit comments

Comments
 (0)