arecibo
Version:
Fastify plugin that respondes to Kubernetes readiness and liveness probes.
26 lines • 1.17 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const fastify_plugin_1 = __importDefault(require("fastify-plugin"));
const schema_1 = require("./schema");
const arecibo_message_1 = require("./arecibo-message");
const ROUTES = {
READINESS: '/arecibo/readiness',
LIVENESS: '/arecibo/liveness',
};
function createResponseHandler(message) {
return (_, reply) => reply.type('text/html').send(message);
}
const arecibo = (0, fastify_plugin_1.default)((fastify, opts, next) => {
const { message = arecibo_message_1.areciboMessage, readinessURL = ROUTES.READINESS, livenessURL = ROUTES.LIVENESS, readinessCallback = createResponseHandler(message), livenessCallback = createResponseHandler(message), logLevel = 'info', } = opts;
fastify
.get(readinessURL, { schema: schema_1.readinessSchema, logLevel }, readinessCallback)
.get(livenessURL, { schema: schema_1.livenessSchema, logLevel }, livenessCallback);
next();
}, {
name: 'arecibo',
fastify: '^4.0.0 || ^5.0.0',
});
module.exports = arecibo;
//# sourceMappingURL=index.js.map
;