-
Notifications
You must be signed in to change notification settings - Fork 41
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
[refactor]:signup_router #237
base: main
Are you sure you want to change the base?
[refactor]:signup_router #237
Conversation
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.
Hey , please do not run any code formatter on the codebase , and submit the PR . It changes lots of lines and make it very difficult to review the code . Just make changes to the required lines and format only that lines of code . By hand or select only that lines and format.
@@ -153,9 +153,11 @@ router.post('/login', apiRequestAuthLoginValidator, async (req, res) => { | |||
*/ | |||
router.post('/signup', apiRequestAuthSignupValidator, async (req, res) => { | |||
try { | |||
const parsedBody = emailPasswordObjectValidator.parse(req.body); | |||
const reqClientData: IRequestAuthSignup = res.locals.reqClientData; | |||
const parsedBody = emailPasswordObjectValidator.parse(reqClientData.body); |
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.
Why you are validating again if already validated , remove this line
@@ -153,9 +153,11 @@ router.post('/login', apiRequestAuthLoginValidator, async (req, res) => { | |||
*/ | |||
router.post('/signup', apiRequestAuthSignupValidator, async (req, res) => { | |||
try { | |||
const parsedBody = emailPasswordObjectValidator.parse(req.body); | |||
const reqClientData: IRequestAuthSignup = res.locals.reqClientData; | |||
const parsedBody = emailPasswordObjectValidator.parse(reqClientData.body); | |||
const email = parsedBody.email; |
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.
use reqClientData
@@ -153,9 +153,11 @@ router.post('/login', apiRequestAuthLoginValidator, async (req, res) => { | |||
*/ | |||
router.post('/signup', apiRequestAuthSignupValidator, async (req, res) => { | |||
try { | |||
const parsedBody = emailPasswordObjectValidator.parse(req.body); | |||
const reqClientData: IRequestAuthSignup = res.locals.reqClientData; | |||
const parsedBody = emailPasswordObjectValidator.parse(reqClientData.body); | |||
const email = parsedBody.email; | |||
const password = parsedBody.password; |
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.
use reqClientData
to get password
error:'A account already exists with this email.' | ||
} | ||
error: 'A account already exists with this email.', | ||
}; | ||
res.status(500).json(response); |
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.
Status should be 409 same as response.
error: error.issues[0]?.message | ||
} | ||
error: error.issues[0]?.message, | ||
}; | ||
return res.status(400).send(response); |
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.
Put return below
} | ||
const response: ApiResponse<null> = { | ||
success: false, | ||
status: 400, |
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.
It should be 500
const response: ApiResponse<null> = { | ||
success: false, | ||
status: 400, | ||
error: error, |
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.
Do not return error object . Only "Something unexpected happened". like that
success: false, | ||
status: 400, | ||
error: error, | ||
}; | ||
return res.status(400).send(response); |
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.
Change here too ( 500 )
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.
Fix the required changes and submit again . Thanks
i'm sorry. |
Okay. Is it related to English language or something else. 「わかりました。それは英語の言語に関連していますか、それとも別の何かですか。」 |
Not only is my English not good, but |
遅くなりすみません。 |
「確認してお知らせします。ありがとうございます。」 |
issue
# 230
content
This PR enhances the code structure by utilizing res.locals.reqClientData as the source for client data, removing direct access to req.body, req.query, andreq.params.