aboutsummaryrefslogtreecommitdiffstats
path: root/lib/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/app.js')
-rw-r--r--lib/app.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/app.js b/lib/app.js
index 4691786a..eaef00d1 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -37,4 +37,19 @@ app.register(fastifyStatic, {
app.register(fastifyWs);
app.register(socketServer);
+app.setErrorHandler((error, request, reply) => {
+ if (error instanceof fastify.errorCodes.FST_ERR_BAD_STATUS_CODE) {
+ reply.status(500).send({ ok: false })
+ } else {
+ reply.send(error)
+ }
+})
+
+app.setNotFoundHandler((request, reply) => {
+ reply
+ .code(404)
+ .type("text/html")
+ .send("Not Found");
+});
+
export default app;