-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: validation api for grading job configuartions
- Loading branch information
1 parent
293017d
commit 6ed0ac1
Showing
6 changed files
with
48 additions
and
15 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
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
13 changes: 13 additions & 0 deletions
13
orchestrator/packages/api/src/controllers/validations-controller.ts
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,13 @@ | ||
import { Request, Response } from "express"; | ||
import { errorResponse, formatValidationErrors } from "./utils"; | ||
import { validations } from "@codegrade-orca/common"; | ||
|
||
export const gradingJobValidation = async (req: Request, res: Response) => { | ||
if (!req.body || Object.keys(req.body).length === 0) { | ||
return errorResponse(res, 400, ['No request body provided for grading job configuration schema validation.']); | ||
} | ||
const validator = validations.gradingJobConfig; | ||
return validator(req.body) ? | ||
res.json({ "message": "Provided request body is a valid grading job configuration." }) : | ||
res.json({ "errors": formatValidationErrors(validator.errors) }); | ||
} |
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,9 @@ | ||
import { Router } from "express"; | ||
import verifyAPIKey from "../middleware/verify-api-key"; | ||
import { gradingJobValidation } from "../controllers/validations-controller"; | ||
|
||
const validationsRouter = Router(); | ||
|
||
validationsRouter.post('/validate_grading_job', verifyAPIKey, gradingJobValidation); | ||
|
||
export default validationsRouter; |
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