-
Notifications
You must be signed in to change notification settings - Fork 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
Added Zod Schema Validation and Error Handling #8
Changes from 1 commit
0541e2c
762eb03
78ca24d
ad2c4e4
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Request, Response, NextFunction, Router } from 'express'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move the middlewares to a commons package. Only retain the module-specific middleware in the recall api There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also use the folder structure in the |
||
import { userValidation } from '../../../validation'; | ||
import { validate } from '../../../validation/validate' | ||
import { zodErrorHandler } from '../../../middleware/zodErrorValidation'; | ||
|
||
|
||
const router = Router(); | ||
|
||
router.post('/register', validate(userValidation), zodErrorHandler, (req: Request, res: Response, next: NextFunction) => { | ||
// Registration logic | ||
res.status(201).json({ message: 'User registered successfully' }); | ||
}); | ||
|
||
export default router; |
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.
The routes are auto-registered if you use the decorators in the
routing-controllers
package. You can read more here