import { Either, getRequiredEnv, getStdout, type ITraceable, LogLevel, type Mapper, TraceUtil, } from "@emprespresso/pengueno"; type HealthCheckInput = "healthy?"; type HealthCheckOutput = "healthy!"; const HealthCheckActivity = ( check: Mapper< ITraceable, Promise> >, ) => (req: ITraceable) => req.bimap(TraceUtil.withFunctionTrace(HealthCheckActivity)) .flatMap((r) => r.move( "healthy?")) .map(check) .map(TraceUtil.promiseify(({ item: health, trace }) => { health.mapBoth((e) => { trace.addTrace(LogLevel.ERROR).trace(`${e}`); return new Response( "oh no, i need to eat more vegetables (。•́︿•̀。)...\n", { status: 500 }, ); }, (_healthy) => { const msg = `think im healthy!! (✿˘◡˘) ready to do work~`; trace.trace(msg); return new Response( msg + "\n", { status: 200 }, ); }); }));