feat(server): Changed 404 error to match a single response style

This commit is contained in:
Данил 2024-11-08 15:22:52 +03:00
parent b49bd33a93
commit 7f288cbaae

View file

@ -33,6 +33,14 @@ fastify.register(getRateRoute);
fastify.register(configurationRoutes); fastify.register(configurationRoutes);
fastify.register(HomeRoute); fastify.register(HomeRoute);
fastify.setNotFoundHandler(function (res, reply) {
return reply.status(404).send({
status: 404,
message: 'Page not found!',
documentation: 'https://kekkai-docs.redume.su/'
});
});
fastify.addHook('onResponse', async (request, reply) => { fastify.addHook('onResponse', async (request, reply) => {
const routePart = request.raw.url.split('/'); const routePart = request.raw.url.split('/');
const routePartFiltered = routePart const routePartFiltered = routePart