-
Notifications
You must be signed in to change notification settings - Fork 1
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
#541 24-chuseok event ban middleware #544
Open
TaehyeonPark
wants to merge
8
commits into
dev
Choose a base branch
from
#541-24-chuseok-event-ban-middleware
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9798ecc
Add: add ban features into event code
TaehyeonPark b9efeeb
Add: resolve comments
TaehyeonPark 793157c
Add: resolve comments
TaehyeonPark cc87bc3
Merge branch 'dev' of https://github.com/sparcs-kaist/taxi-back into …
TaehyeonPark 07d6c3b
Add: req.session.loginInfo.sid added to test
TaehyeonPark 6f64cac
Add: req.session.loginInfo.sid added to test
TaehyeonPark a4ef34a
Add: resolve error in test; invalid arguments error
TaehyeonPark fd4437a
Fix: mocha error fix
TaehyeonPark File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const { eventStatusModel } = require("../modules/stores/mongo"); | ||
const logger = require("../../modules/logger"); | ||
|
||
/** | ||
* 사용자가 차단 되었는지 여부를 판단합니다. | ||
* 차단된 사용자는 이벤트에 한하여 서비스 이용에 제재를 받습니다. | ||
* @param {*} req eventStatus가 성공적일 경우 req.eventStatus = eventStatus로 들어갑니다. | ||
* @param {*} res | ||
* @param {*} next | ||
* @returns | ||
*/ | ||
const eventValidator = async (req, res, next) => { | ||
try { | ||
const eventStatus = await eventStatusModel | ||
.findOne({ userId: req.userOid }) | ||
.lean(); | ||
if (!eventStatus) { | ||
return res | ||
.status(400) | ||
.json({ error: "eventValidator: nonexistent eventStatus" }); | ||
} | ||
req.eventStatus = eventStatus; | ||
next(); | ||
} catch (err) { | ||
logger.error(err); | ||
res.error(500).json({ | ||
error: "eventValidator: internal server error", | ||
}); | ||
} | ||
}; | ||
|
||
module.exports = eventValidator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
개인적으로는 이렇게 eventStatus를 가져오는 미들웨어보다는 필요한 services에서만 가져다 쓰는게 좋을 것 같다고 생각해요. 기존 코드에 user를 가져오는 미들웨어가 없고 필요한 services에서 직접 조회해서 쓰는 것처럼요. 물론 성능 차이는 거의 없겠지만, service에 따라 eventStatus를 단순히 조회만 하는 경우가 있고, 수정해야 하는 경우도 있는데 후자의 경우에는 (미들웨어가 있으면) query가 2번 발생하게 됩니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 백엔드 분들은 어케 생각하시는지도 궁금하네요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
계속 사용하는 것으로 결정