summaryrefslogtreecommitdiff
path: root/u/server/activity/health.ts
diff options
context:
space:
mode:
authorElizabeth Hunt <me@liz.coffee>2025-07-27 18:50:33 -0700
committerElizabeth Hunt <me@liz.coffee>2025-07-27 19:31:06 -0700
commit7aa11b7a8abacf81dec20fff21216df35d333756 (patch)
tree40f6a76c37412cf1c5a67f99a4ee30e3aae863c9 /u/server/activity/health.ts
parente4df72cd446270cf867ec308995a05e21b3aa601 (diff)
downloadci-7aa11b7a8abacf81dec20fff21216df35d333756.tar.gz
ci-7aa11b7a8abacf81dec20fff21216df35d333756.zip
Pulls in pengueno from npm
Diffstat (limited to 'u/server/activity/health.ts')
-rw-r--r--u/server/activity/health.ts49
1 files changed, 0 insertions, 49 deletions
diff --git a/u/server/activity/health.ts b/u/server/activity/health.ts
deleted file mode 100644
index 9396490..0000000
--- a/u/server/activity/health.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import {
- type IActivity,
- type IEither,
- IMetric,
- type ITraceable,
- JsonResponse,
- LogLevel,
- type Mapper,
- Metric,
- type PenguenoRequest,
- type ServerTrace,
- TraceUtil,
-} from '@emprespresso/pengueno';
-
-export enum HealthCheckInput {
- CHECK,
-}
-export enum HealthCheckOutput {
- YAASSSLAYQUEEN,
-}
-
-export interface IHealthCheckActivity {
- checkHealth: IActivity;
-}
-
-const healthCheckMetric = Metric.fromName('Health').asResult();
-export interface HealthChecker
- extends Mapper<ITraceable<HealthCheckInput, ServerTrace>, Promise<IEither<Error, HealthCheckOutput>>> {}
-export class HealthCheckActivityImpl implements IHealthCheckActivity {
- constructor(private readonly check: HealthChecker) {}
-
- public checkHealth(req: ITraceable<PenguenoRequest, ServerTrace>) {
- return req
- .flatMap(TraceUtil.withFunctionTrace(this.checkHealth))
- .flatMap(TraceUtil.withMetricTrace(healthCheckMetric))
- .flatMap((r) => r.move(HealthCheckInput.CHECK).map((input) => this.check(input)))
- .peek(TraceUtil.promiseify(TraceUtil.traceResultingEither(healthCheckMetric)))
- .map(
- TraceUtil.promiseify((h) => {
- const { status, message } = h.get().fold(
- () => ({ status: 500, message: 'err' }),
- () => ({ status: 200, message: 'ok' }),
- );
- return new JsonResponse(req, message, { status });
- }),
- )
- .get();
- }
-}