-
Notifications
You must be signed in to change notification settings - Fork 1
feature/ dashboardClient controller, service, model 생성, 회원가입기능(apikey발급, apikey와 비밀번호 hash처리 ) #13
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a79e094
feature/ dashboardClient controller, service, model 생성, 회원가입기능(apikey…
nemo0824 7b7f726
feature: dashboardClient 로그인기능
nemo0824 ee18349
refactor: errorHandle 글로벌 에러핸들러 수정,
nemo0824 8af0afa
refactor: dashboardClientService(apikey를 bcrypt 에서 sha256으로 변경)
nemo0824 ccd0ef5
refactor: authenticate(SHA-256으로 hash한것으로 hahsedDomain끼리 조회 후 domain반환 )
nemo0824 fc53d20
refactor: dashboardClient service(타입단언 수정(get으로 일반객체로 불러오기, ) ), con…
nemo0824 67ab02d
refactor: dashboardClinet 에러메시지 변경
nemo0824 6ef8edb
refactor: sdkClientUser apiKeyservice(도메인 조회방법변경(raw 제거, 조회 후 일반객체로 …
nemo0824 b961fc4
refactor: dashboardClient(apikey 암호화 제거 및 필드에 암호화되지않은 apiKey로 변경)
nemo0824 0b85761
feature: dashboardClient(로그아웃 기능 추가)
nemo0824 ee4f480
refactor: dashboardController (도메인 session에서 사용), errorHanle(도메인 없을시 …
nemo0824 416f11e
refactor: hasDashboardDomain 미들웨어 생성 및 적용
nemo0824 e0b19b4
refactor: 미들웨어 ensureLogin추가(로그인 했는지 판별)
nemo0824 83c7f54
refactor: sessionType 추가 , Controller(Request타입 AuthenticatedRequest …
nemo0824 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 hidden or 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 hidden or 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 hidden or 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,10 @@ | ||
| import { NextFunction, Request, Response } from 'express'; | ||
|
|
||
| export const hasDashboardDomain = (req: Request, res: Response, next: NextFunction) => { | ||
| const domain = req.session.client?.domain; | ||
| if (!domain) { | ||
| return next(new Error('도메인 에러')); | ||
| } | ||
| res.locals.dashboardDomain = domain; | ||
| next(); | ||
| }; |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,26 +1,78 @@ | ||
| import express from 'express'; | ||
| import { dashboardController } from '../controllers/dashboardController'; | ||
|
|
||
| import { hasDashboardDomain } from '../middleware/hasDashboardDomain'; | ||
| export const dashboardRouter = express.Router(); | ||
|
|
||
| dashboardRouter.get('/dashboard/onlineUsersCount', dashboardController.getOnlineUsersCount); | ||
| dashboardRouter.get('/dashboard/browsersStats', dashboardController.getBrowserStats); | ||
| dashboardRouter.get('/dashboard/osStats', dashboardController.getOsStats); | ||
| dashboardRouter.get('/dashboard/deviceStats', dashboardController.getDeviceStats); | ||
| dashboardRouter.get('/dashboard/resolutionStats', dashboardController.getResolutionStats); | ||
| dashboardRouter.get('/dashboard/languageStats', dashboardController.getLanguageStats); | ||
| dashboardRouter.get('/dashboard/countryStats', dashboardController.getCountryStats); | ||
| dashboardRouter.get('/dashboard/visitedRate', dashboardController.getVisitedUsersRate); | ||
| dashboardRouter.get('/dashboard/referrer', dashboardController.getReferrerStats); | ||
| dashboardRouter.get('/dashboard/loadTime', dashboardController.getAveragePageLoadTime); | ||
| dashboardRouter.get('/dashboard/visitorsPageByPeriodCount', dashboardController.getPageViewCount); | ||
| dashboardRouter.get( | ||
| '/dashboard/onlineUsersCount', | ||
| hasDashboardDomain, | ||
| dashboardController.getOnlineUsersCount | ||
| ); | ||
| dashboardRouter.get( | ||
| '/dashboard/browsersStats', | ||
| hasDashboardDomain, | ||
| dashboardController.getBrowserStats | ||
| ); | ||
| dashboardRouter.get('/dashboard/osStats', hasDashboardDomain, dashboardController.getOsStats); | ||
| dashboardRouter.get( | ||
| '/dashboard/deviceStats', | ||
| hasDashboardDomain, | ||
| dashboardController.getDeviceStats | ||
| ); | ||
| dashboardRouter.get( | ||
| '/dashboard/resolutionStats', | ||
| hasDashboardDomain, | ||
| dashboardController.getResolutionStats | ||
| ); | ||
| dashboardRouter.get( | ||
| '/dashboard/languageStats', | ||
| hasDashboardDomain, | ||
| dashboardController.getLanguageStats | ||
| ); | ||
| dashboardRouter.get( | ||
| '/dashboard/countryStats', | ||
| hasDashboardDomain, | ||
| dashboardController.getCountryStats | ||
| ); | ||
| dashboardRouter.get( | ||
| '/dashboard/visitedRate', | ||
| hasDashboardDomain, | ||
| dashboardController.getVisitedUsersRate | ||
| ); | ||
| dashboardRouter.get( | ||
| '/dashboard/referrer', | ||
| hasDashboardDomain, | ||
| dashboardController.getReferrerStats | ||
| ); | ||
| dashboardRouter.get( | ||
| '/dashboard/loadTime', | ||
| hasDashboardDomain, | ||
| dashboardController.getAveragePageLoadTime | ||
| ); | ||
| dashboardRouter.get( | ||
| '/dashboard/visitorsPageByPeriodCount', | ||
| hasDashboardDomain, | ||
| dashboardController.getPageViewCount | ||
| ); | ||
| dashboardRouter.get( | ||
| '/dashboard/perPageAverageScrollDepth', | ||
| dashboardController.getPerPageAverageScrollDepth | ||
| ); | ||
| dashboardRouter.get('/dashboard/bounceRate', dashboardController.getPerPageBounceRate); | ||
| dashboardRouter.get(`/dashboard/visitorsByPeriodCount`, dashboardController.getVisitorsByPeriod); | ||
| dashboardRouter.get(`/dashboard/totalVisitorsCount`, dashboardController.getTotalVisitors); | ||
| dashboardRouter.get( | ||
| '/dashboard/bounceRate', | ||
| hasDashboardDomain, | ||
| dashboardController.getPerPageBounceRate | ||
| ); | ||
| dashboardRouter.get( | ||
| '/dashboard/visitorsByPeriodCount', | ||
| hasDashboardDomain, | ||
| dashboardController.getVisitorsByPeriod | ||
| ); | ||
| dashboardRouter.get( | ||
| '/dashboard/totalVisitorsCount', | ||
| hasDashboardDomain, | ||
| dashboardController.getTotalVisitors | ||
| ); | ||
| dashboardRouter.post('/dashboard/enrollClient', dashboardController.enrollClient); | ||
| dashboardRouter.post('/dashboard/loginClient', dashboardController.loginClient); | ||
| dashboardRouter.post('/dashboard/logoutClient', dashboardController.logoutClient); | ||
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.
근데 도메인 유무를 왜 확인해야 하나요? 무조건 있어야 하는 거 아닌가요? 스키마상으로 domain이 nullable한가요?
로그인 여부를 확인해야지 왜 도메인 유무를 확인하는지 알기가 어렵네요.
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.
스키마상으로 domain은 nullable 하지않습니다 무조건 존재합니다 저렇게 코드를 작성한 이유는 타입스크립트에서 인식할수있도록 작성했습니다.
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.
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.
이 코드리뷰에서 내부 구현은 관심사가 아니고요,
hasDashboardDomain, 그러니까 domain 유무를 왜 확인하냐는 겁니다. 도메인은 무조건 있는 건데.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.
그럼 위 댓글에서 말씀하신 '실제 세션 데이터'라는 건 어차피 실체가 없는 거 아닌가요?
Uh oh!
There was an error while loading. Please reload this page.
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.
express-session의 타입 정의를 보게되면 session: session.Session & Partial<session.SessionData>;
SessionData가 Partial<>감싸져있는데 SessionData내부에서 client를 넣어도 역시 Partial 때문에 보장이 안되고 있습니다
멘토님이 말씀하신 Request를 확장은 혹시 clinet를 넣어 확장하여 미들웨어에서 req.client = req.session.client 이렇게 우회하라는 말씀이신가요?
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.
만들고
이렇게 써보세요.
Uh oh!
There was an error while loading. Please reload this page.
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.
제시해주신 방법도 전에 시도해봤었는데 라이터 쪽 RequestHandler 타입에러가 있어서 실패했었습니다
그러면 RequsetHandler 까지 타입 확장해서 해결해야하는 문제일가요?
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.
HOF 사용하면 될 것 같은데 힘들면 라우터 쪽에
as RequestHandler사용하세요~