Skip to content

Commit 0334814

Browse files
committed
feature: 전체 조회수/좋아요/게시글 디테일 API 기본 비즈니스 로직 완성
1 parent 059a4c0 commit 0334814

File tree

9 files changed

+616
-34
lines changed

9 files changed

+616
-34
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) {}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import logger from '@/configs/logger.config';
2+
import { NextFunction, Request, RequestHandler, Response } from 'express';
3+
import { TotalStatsService } from '@/services/totalStats.service';
4+
import { GetTotalStatsQuery, TotalStatsResponseDto } from '@/types';
5+
import { BadRequestError } from '@/exception';
6+
7+
8+
export class TotalStatsController {
9+
constructor(private totalStatsService: TotalStatsService) { }
10+
11+
getTotalStats: RequestHandler = async (
12+
req: Request<object, object, object, GetTotalStatsQuery>,
13+
res: Response<TotalStatsResponseDto>,
14+
next: NextFunction,
15+
) => {
16+
try {
17+
const { id } = req.user;
18+
const { period, type } = req.query;
19+
20+
// 미들웨어에서 GetTotalStatsQueryDto 에 의해 걸리는데 런타임과 IDE 에서 구분을 못함, 이를 위해 추가
21+
if (!type) throw new BadRequestError('type 파라미터가 필요합니다.');
22+
23+
const stats = await this.totalStatsService.getTotalStats(id, period, type);
24+
const message = this.totalStatsService.getSuccessMessage(type);
25+
26+
const response = new TotalStatsResponseDto(
27+
true,
28+
message,
29+
stats,
30+
null,
31+
);
32+
33+
res.status(200).json(response);
34+
} catch (error) {
35+
logger.error('전체 통계 조회 실패:', error);
36+
next(error);
37+
}
38+
};
39+
}

0 commit comments

Comments
 (0)