@piggly/fastify-chassis
Version:
An ESM/CommonJS toolkit to help you to do common operations in your back-end applications with Fastify and NodeJS.
20 lines • 683 B
JavaScript
/**
* Health check route.
*
* It will run the health check service and return the result.
* If success, it will return 200. Otherwise, it will return 503.
*
* The response will be a JSON object with the following properties:
* - [service]: boolean
*
* @param {Object} deps
* @param {HealthCheckService} deps.HEALTH_CHECK_SERVICE
* @returns Route handler.
* @since 7.0.0
* @author Caique Araujo <caique@piggly.com.br>
*/
export const HealthCheckRoute = (deps) => async (request, reply) => {
const response = await deps.HEALTH_CHECK_SERVICE.check();
return reply.status(response.success ? 200 : 503).send(response);
};
//# sourceMappingURL=HealthCheckRoute.js.map