feat: add initial API
This commit is contained in:
@@ -1,8 +1,34 @@
|
||||
import { type FastifyPluginAsync } from 'fastify';
|
||||
import { manageEndpoints } from './endpoints/endpoints.manage.ts';
|
||||
import { authPlugin } from './plugins/plugins.auth.ts';
|
||||
import { messageEndpoints } from './endpoints/endpoints.message.ts';
|
||||
import { z } from 'zod';
|
||||
|
||||
const api: FastifyPluginAsync = async (fastify) => {
|
||||
fastify.get('/healthz', () => {
|
||||
return { status: 'ok' };
|
||||
fastify.route({
|
||||
method: 'get',
|
||||
url: '/health',
|
||||
schema: {
|
||||
operationId: 'health.get',
|
||||
summary: 'Get health status',
|
||||
tags: ['system'],
|
||||
response: {
|
||||
200: z.object({
|
||||
status: z.literal('ok'),
|
||||
}),
|
||||
},
|
||||
},
|
||||
handler: () => {
|
||||
return { status: 'ok' };
|
||||
},
|
||||
});
|
||||
await authPlugin(fastify, {});
|
||||
|
||||
await fastify.register(manageEndpoints, {
|
||||
prefix: '/manage',
|
||||
});
|
||||
await fastify.register(messageEndpoints, {
|
||||
prefix: '/message',
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user