Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #64

Merged
merged 5 commits into from
Jul 15, 2024
Merged

Dev #64

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/common/modules/express/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ module.exports = expressLoader = (app) => {
origin: (origin, callback) => {
if (
// whitelist에 있는 origin 허용
(origin && conf.corsWhiteList.indexOf(origin) !== -1) ||
// postman 허용
(!origin &&
conf.corsUserAgent.split(',').some((agent) => req.headers['user-agent'].includes(agent)))
origin === undefined ||
conf.corsWhiteList.indexOf(origin) !== -1
// NOTE : EB Health Check도 origin undefind라 거부 당해서 임시 주석처리
// // whitelist에 있는 origin 허용
// (origin && conf.corsWhiteList.indexOf(origin) !== -1) ||
// // postman 허용
// (!origin &&
// conf.corsUserAgent.split(',').some((agent) => req.headers['user-agent'].includes(agent)))
) {
return callback(null, true);
}
Expand Down
3 changes: 2 additions & 1 deletion src/common/utils/rateLimit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ exports.postApiLimiter = rateLimit({

exports.commonLimiter = rateLimit({
windowMs: 60 * 1000, // 1분 간격
// TODO : 100으로 줄이기
max: 1000, // windowMs동안 최대 호출 횟수
handler(req, res) {
// 제한 초과 시 콜백 함수
res.status(this.statusCode).json({
code: this.statusCode, // statusCode 기본값은 429
message: '1분에 50번만 요청 할 수 있습니다.',
message: '1분에 100번만 요청 할 수 있습니다.',
});
},
});
11 changes: 11 additions & 0 deletions src/routes/user/user.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,17 @@ exports.updateRequestState = async (req, res) => {

exports.deleteUser = async (req, res) => {
try {
const refreshToken = req.cookies.refreshToken;
if (refreshToken) {
try {
const email = req.user.email;
await redisClient.del(email);
} catch (err) {
console.error('Redis error:', err);
}
}
res.clearCookie('refreshToken', config.cookieInRefreshTokenDeleteOptions);

const { _id } = req.user;
await wordService.deleteWordContributor(_id);
await userService.deleteUser(_id);
Expand Down
1 change: 0 additions & 1 deletion src/routes/user/user.route.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ userRouter.delete('/:searchTerm', isLoggedIn, delRecentSearch); // 최근 검색
//등록 요청
userRouter.post('/requests/:nickname/new', isLoggedIn, postWords);

module.exports = userRouter;
// 요청 조회
userRouter.get('/requests', isLoggedIn, UserRequests); // 요청 목록 조회
userRouter.get('/requests/all', isLoggedIn, UserRequestsAll); // 모든 요청 목록 조회
Expand Down