-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: checkRequiredFields 미들웨어 추가, schema.ts수정(#11)
- checkRequiredFields 미들웨어 추가, schema.ts수정, travel.route.ts 수정 - checkRequiredFields 미들웨어 추가. 필수 필드를 체크하는 미들웨어 추가 - schema.ts 수정. travel schema에 필수 필드 추가 - travel.route.ts 수정. checkRequiredFields 미들웨어 추가
- Loading branch information
1 parent
91feab1
commit 540231b
Showing
3 changed files
with
111 additions
and
55 deletions.
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
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,14 @@ | ||
import { Request, Response, NextFunction } from 'express'; | ||
import { ResponseDTO } from './ResponseDTO'; | ||
|
||
export const checkRequiredFields = (fields: string[]) => { | ||
return (req: Request, res: Response, next: NextFunction) => { | ||
for (const field of fields) { | ||
if (!req.body[field]) { | ||
res.status(400).json(ResponseDTO.fail(`${field} is required`)); | ||
return; | ||
} | ||
} | ||
next(); | ||
}; | ||
}; |
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