alepha
Version:
Easy-to-use modern TypeScript framework for building many kind of applications.
59 lines (58 loc) • 1.47 kB
JavaScript
import { $inject, $module, Alepha, z } from "alepha";
import { $route, AlephaServer } from "alepha/server";
import { DateTimeProvider } from "alepha/datetime";
//#region ../../src/server/health/schemas/healthSchema.ts
const healthSchema = z.object({
message: z.text(),
uptime: z.number(),
date: z.datetime(),
ready: z.boolean()
});
//#endregion
//#region ../../src/server/health/providers/ServerHealthProvider.ts
/**
* Register `/health` & `/healthz` endpoint.
*
* - Provides basic health information about the server.
*/
var ServerHealthProvider = class {
time = $inject(DateTimeProvider);
alepha = $inject(Alepha);
health = $route({
path: "/health",
schema: { response: healthSchema },
silent: true,
handler: () => this.healthCheck()
});
healthz = $route({
path: "/healthz",
schema: { response: healthSchema },
silent: true,
handler: () => this.healthCheck()
});
healthCheck() {
return {
message: "OK",
uptime: Math.floor(process.uptime()),
date: this.time.nowISOString(),
ready: this.alepha.isReady()
};
}
};
//#endregion
//#region ../../src/server/health/index.ts
/**
* Application health monitoring endpoints.
*
* **Features:**
* - `GET /health` endpoint
*
* @module alepha.server.health
*/
const AlephaServerHealth = $module({
name: "alepha.server.health",
services: [AlephaServer, ServerHealthProvider]
});
//#endregion
export { AlephaServerHealth, ServerHealthProvider, healthSchema };
//# sourceMappingURL=index.js.map