mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
feat: /status/ping endpoint (#50697)
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -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();
|
||||
};
|
||||
Reference in New Issue
Block a user