Files
superlist/apps/api/src/modules/health/get-status/use-case.ts

24 lines
575 B
TypeScript

import { Ok, type ProblemDetails, type Result } from '@superlist/shared'
export type HealthStatus = {
status: 'ok'
uptimeSeconds: number
timestamp: string
}
/**
* Returns the liveness status of the process.
* No dependencies and no failure mode: it must always succeed.
*/
export class GetStatus {
constructor(private readonly now: () => Date = () => new Date()) {}
execute(): Result<HealthStatus, ProblemDetails> {
return Ok({
status: 'ok',
uptimeSeconds: Math.round(process.uptime()),
timestamp: this.now().toISOString(),
})
}
}