feat(monitoring): wrote plugin for /monitoring endpoint and updated service to use them

This commit is contained in:
Maieul BOYER 2025-11-14 19:25:10 +01:00
parent e44a3af76d
commit a4bf71cc6a
No known key found for this signature in database
4 changed files with 11 additions and 3 deletions

View file

@ -10,6 +10,13 @@ import {
import { FastifyReply } from 'fastify';
import fp from 'fastify-plugin';
export const useMonitoring = fp(async (fastify) => {
fastify.get('/monitoring', { schema: { hide: true } }, (req, res) => {
void req;
res.code(200).send('Ok');
});
});
const kMakeResponseSym = Symbol('make-response-sym');
declare module 'fastify' {
export interface RouteOptions {

View file

@ -23,6 +23,7 @@ declare module 'fastify' {
const app: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
void opts;
await fastify.register(utils.useMakeResponse);
await fastify.register(utils.useMonitoring);
await fastify.register(swagger.useSwagger, { service: __SERVICE_NAME });
await fastify.register(db.useDatabase as FastifyPluginAsync, {});
await fastify.register(auth.jwtPlugin as FastifyPluginAsync, {});
@ -38,7 +39,6 @@ const app: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
void fastify.register(fastifyFormBody, {});
void fastify.register(fastifyMultipart, {});
fastify.get('/monitoring', () => 'Ok');
};
export default app;

View file

@ -4,6 +4,7 @@ import fastifyMultipart from '@fastify/multipart';
import { mkdir } from 'node:fs/promises';
import fp from 'fastify-plugin';
import * as db from '@shared/database';
import * as utils from '@shared/utils';
import { authPlugin, jwtPlugin } from '@shared/auth';
// @ts-expect-error: import.meta.glob is a vite thing. Typescript doesn't know this...
@ -32,6 +33,7 @@ const app: FastifyPluginAsync = async (
void fastify.register(route as FastifyPluginAsync, {});
}
await fastify.register(utils.useMonitoring);
await fastify.register(db.useDatabase as FastifyPluginAsync, {});
await fastify.register(authPlugin as FastifyPluginAsync, {});
await fastify.register(jwtPlugin as FastifyPluginAsync, {});
@ -46,7 +48,6 @@ const app: FastifyPluginAsync = async (
fastify2.decorate('image_store', image_store);
await mkdir(fastify2.image_store, { recursive: true });
}));
fastify.get('/monitoring', () => 'Ok');
};
export default app;

View file

@ -16,6 +16,7 @@ const routes = import.meta.glob('./routes/**/*.ts', { eager: true });
const app: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
void opts;
await fastify.register(utils.useMakeResponse);
await fastify.register(utils.useMonitoring);
await fastify.register(swagger.useSwagger, { service: __SERVICE_NAME });
await fastify.register(db.useDatabase as FastifyPluginAsync, {});
await fastify.register(auth.jwtPlugin as FastifyPluginAsync, {});
@ -31,7 +32,6 @@ const app: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
void fastify.register(fastifyFormBody, {});
void fastify.register(fastifyMultipart, {});
fastify.get('/monitoring', () => 'Ok');
};
export default app;