aboutsummaryrefslogtreecommitdiff
path: root/packages/server/src/app.ts
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-08-15 15:29:53 +0200
committerHampusM <hampus@hampusmat.com>2021-08-15 15:29:53 +0200
commitdfd299d4697a629f09ef20fc05c6d9e474bd5475 (patch)
tree5b47b64afc379101187acec7c0f95baf7b1dba04 /packages/server/src/app.ts
parent9736749a779661a95211a91200617a03a1b9a702 (diff)
Improved route parameter validation
Diffstat (limited to 'packages/server/src/app.ts')
-rw-r--r--packages/server/src/app.ts5
1 files changed, 5 insertions, 0 deletions
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!");
});