MCPcopy
hub / github.com/msgbyte/tianji / handler

Function handler

src/server/middleware/validate.ts:6–16  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

4
5export function validate(...validator: ValidationChain[]): Handler {
6 const handler: Handler = (req, res, next) => {
7 const result = validationResult(req);
8
9 if (!result.isEmpty()) {
10 res
11 .status(422)
12 .json({ errors: result.array(), message: 'Invalid Parameters' });
13 } else {
14 next();
15 }
16 };
17
18 return compose([...validator, handler as any]);
19}

Callers 2

aiRouter.spec.tsFile · 0.50
aiGateway.spec.tsFile · 0.50

Calls 3

nextFunction · 0.85
statusMethod · 0.80
jsonMethod · 0.65

Tested by

no test coverage detected