feat: /status/ping endpoint (#50697)

This commit is contained in:
Sem Bauke
2023-06-14 17:27:10 +02:00
committed by GitHub
parent c3bca9ffb7
commit f3385dda8e
3 changed files with 29 additions and 0 deletions
+2
View File
@@ -41,6 +41,7 @@ import {
} from './utils/env';
import { userRoutes } from './routes/user';
import { donateRoutes } from './routes/donate';
import { statusRoute } from './routes/status';
export type FastifyInstanceWithTypeProvider = FastifyInstance<
RawServerDefault,
@@ -170,6 +171,7 @@ export const build = async (
void fastify.register(donateRoutes);
void fastify.register(userRoutes);
void fastify.register(deprecatedEndpoints);
void fastify.register(statusRoute);
return fastify;
};
+14
View File
@@ -0,0 +1,14 @@
import { setupServer, superRequest } from '../../jest.utils';
describe('/status', () => {
setupServer();
test('GET returns 200 status code with pong', async () => {
const response = await superRequest('/status/ping', {
method: 'GET'
});
expect(response.body).toStrictEqual({ msg: 'pong' });
expect(response.status).toBe(200);
});
});
+13
View File
@@ -0,0 +1,13 @@
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox';
export const statusRoute: FastifyPluginCallbackTypebox = (
fastify,
_options,
done
) => {
fastify.get('/status/ping', async (_req, _reply) => {
return { msg: 'pong' };
});
done();
};