Skip to content

Commit

Permalink
Merge pull request #63 from Murakano/feature/jikky-issue
Browse files Browse the repository at this point in the history
Feature/jikky issue
  • Loading branch information
jjikky authored Jul 15, 2024
2 parents ab9e1a2 + 88ebadd commit b2e3cf4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
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

0 comments on commit b2e3cf4

Please sign in to comment.