-
Notifications
You must be signed in to change notification settings - Fork 8
fix: rename publilishEvent to publishEvent across codebase #6
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,8 +120,8 @@ const getMe = asyncHandler(async (req: Request, res: Response) => { | |
| } | ||
| let user = await User.findById(req.user.id).select( | ||
| "name userName email avatar provider createdAt" | ||
| );; | ||
| ); | ||
|
|
||
| if (!user) { | ||
| return res.status(404).json( | ||
| new ApiResponse(404, null, "User not found") | ||
|
|
@@ -133,35 +133,33 @@ const getMe = asyncHandler(async (req: Request, res: Response) => { | |
| ); | ||
| }); | ||
|
|
||
| const refreshAccessToken = asyncHandler(async (req:Request, res: Response)=>{ | ||
| let incomingRefreshToken =req.cookies.refreshToken; | ||
| if(!incomingRefreshToken){ | ||
| const refreshAccessToken = asyncHandler(async (req: Request, res: Response) => { | ||
| let incomingRefreshToken = req.cookies.refreshToken; | ||
| if (!incomingRefreshToken) { | ||
| throw new ApiError(401, "Refresh Token is required"); | ||
| } | ||
|
|
||
| try { | ||
| const decodedToken = jwt.verify( | ||
| incomingRefreshToken, | ||
| incomingRefreshToken, | ||
| process.env.REFRESH_TOKEN_SECRET! | ||
| ) as {tokenVersion: number, sub: string}; | ||
| ) as { tokenVersion: number, sub: string }; | ||
|
|
||
| const user = await User.findById(decodedToken?.sub); | ||
| if(!user){ | ||
| if (!user) { | ||
| throw new ApiError(404, "Invalid refresh Token"); | ||
| } | ||
|
|
||
| if(decodedToken?.tokenVersion! != user?.tokenVersion){ | ||
| if (decodedToken?.tokenVersion! != user?.tokenVersion) { | ||
| throw new ApiError(404, "Invalid Refresh Token"); | ||
|
Comment on lines
+146
to
154
|
||
| } | ||
|
|
||
| const options = { | ||
|
|
||
| } | ||
| const newRefreshToken = user.generateRefreshToken(); | ||
| const newAccessToken = user.generateAccessToken(); | ||
|
|
||
| setAuthCookies(res, newAccessToken, newRefreshToken); | ||
| res.status(200).json(new ApiResponse(200, {newAccessToken, newRefreshToken}, "Refresh token generated successfully")); | ||
| res.status(200).json(new ApiResponse(200, { newAccessToken, newRefreshToken }, "Refresh token generated successfully")); | ||
| } catch (error) { | ||
| throw new ApiError(404, "Failed to refresh refresh-token"); | ||
| } | ||
|
Comment on lines
163
to
165
|
||
|
|
||
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.
module.exportsis assigned twice and there's a top-levelconsole.logthat will run on every require/import. This creates noisy logs in production and makes the module harder to reason about; keep a single export assignment and remove the debug log (or gate it behind an explicit debug flag).