feat(monitoring): wrote plugin for /monitoring endpoint and updated service to use them
This commit is contained in:
parent
e44a3af76d
commit
a4bf71cc6a
4 changed files with 11 additions and 3 deletions
|
|
@ -10,6 +10,13 @@ import {
|
||||||
import { FastifyReply } from 'fastify';
|
import { FastifyReply } from 'fastify';
|
||||||
import fp from 'fastify-plugin';
|
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');
|
const kMakeResponseSym = Symbol('make-response-sym');
|
||||||
declare module 'fastify' {
|
declare module 'fastify' {
|
||||||
export interface RouteOptions {
|
export interface RouteOptions {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ declare module 'fastify' {
|
||||||
const app: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
|
const app: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
|
||||||
void opts;
|
void opts;
|
||||||
await fastify.register(utils.useMakeResponse);
|
await fastify.register(utils.useMakeResponse);
|
||||||
|
await fastify.register(utils.useMonitoring);
|
||||||
await fastify.register(swagger.useSwagger, { service: __SERVICE_NAME });
|
await fastify.register(swagger.useSwagger, { service: __SERVICE_NAME });
|
||||||
await fastify.register(db.useDatabase as FastifyPluginAsync, {});
|
await fastify.register(db.useDatabase as FastifyPluginAsync, {});
|
||||||
await fastify.register(auth.jwtPlugin 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(fastifyFormBody, {});
|
||||||
void fastify.register(fastifyMultipart, {});
|
void fastify.register(fastifyMultipart, {});
|
||||||
fastify.get('/monitoring', () => 'Ok');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import fastifyMultipart from '@fastify/multipart';
|
||||||
import { mkdir } from 'node:fs/promises';
|
import { mkdir } from 'node:fs/promises';
|
||||||
import fp from 'fastify-plugin';
|
import fp from 'fastify-plugin';
|
||||||
import * as db from '@shared/database';
|
import * as db from '@shared/database';
|
||||||
|
import * as utils from '@shared/utils';
|
||||||
import { authPlugin, jwtPlugin } from '@shared/auth';
|
import { authPlugin, jwtPlugin } from '@shared/auth';
|
||||||
|
|
||||||
// @ts-expect-error: import.meta.glob is a vite thing. Typescript doesn't know this...
|
// @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, {});
|
void fastify.register(route as FastifyPluginAsync, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await fastify.register(utils.useMonitoring);
|
||||||
await fastify.register(db.useDatabase as FastifyPluginAsync, {});
|
await fastify.register(db.useDatabase as FastifyPluginAsync, {});
|
||||||
await fastify.register(authPlugin as FastifyPluginAsync, {});
|
await fastify.register(authPlugin as FastifyPluginAsync, {});
|
||||||
await fastify.register(jwtPlugin as FastifyPluginAsync, {});
|
await fastify.register(jwtPlugin as FastifyPluginAsync, {});
|
||||||
|
|
@ -46,7 +48,6 @@ const app: FastifyPluginAsync = async (
|
||||||
fastify2.decorate('image_store', image_store);
|
fastify2.decorate('image_store', image_store);
|
||||||
await mkdir(fastify2.image_store, { recursive: true });
|
await mkdir(fastify2.image_store, { recursive: true });
|
||||||
}));
|
}));
|
||||||
fastify.get('/monitoring', () => 'Ok');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ const routes = import.meta.glob('./routes/**/*.ts', { eager: true });
|
||||||
const app: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
|
const app: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
|
||||||
void opts;
|
void opts;
|
||||||
await fastify.register(utils.useMakeResponse);
|
await fastify.register(utils.useMakeResponse);
|
||||||
|
await fastify.register(utils.useMonitoring);
|
||||||
await fastify.register(swagger.useSwagger, { service: __SERVICE_NAME });
|
await fastify.register(swagger.useSwagger, { service: __SERVICE_NAME });
|
||||||
await fastify.register(db.useDatabase as FastifyPluginAsync, {});
|
await fastify.register(db.useDatabase as FastifyPluginAsync, {});
|
||||||
await fastify.register(auth.jwtPlugin 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(fastifyFormBody, {});
|
||||||
void fastify.register(fastifyMultipart, {});
|
void fastify.register(fastifyMultipart, {});
|
||||||
fastify.get('/monitoring', () => 'Ok');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default app;
|
export default app;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue