From dfd299d4697a629f09ef20fc05c6d9e474bd5475 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 15 Aug 2021 15:29:53 +0200 Subject: Improved route parameter validation --- packages/server/src/app.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'packages/server/src/app.ts') diff --git a/packages/server/src/app.ts b/packages/server/src/app.ts index 9ca3769..42d096a 100644 --- a/packages/server/src/app.ts +++ b/packages/server/src/app.ts @@ -11,6 +11,11 @@ export default function buildApp(settings: Settings): FastifyInstance { const fastify = fastifyFactory(); fastify.setErrorHandler((err, req, reply) => { + if(err.validation) { + reply.code(400).send(`${err.validation[0].dataPath} ${err.validation[0].message}`); + return; + } + console.log(err); reply.code(500).send("Internal server error!"); }); -- cgit v1.2.3-18-g5258