1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
import {
getRequiredEnv,
getStdout,
type HealthCheckInput,
HealthCheckOutput,
type IEither,
type ITraceable,
TraceUtil,
} from "@emprespresso/pengueno";
import {} from "../../u/trace/mod.ts";
const healthCheck = <Trace>(
input: ITraceable<HealthCheckInput, Trace>,
): Promise<IEither<Error, HealthCheckOutput>> =>
input.bimap(TraceUtil.withFunctionTrace(healthCheck))
.move(getRequiredEnv("LAMINAR_HOST"))
// we need to test LAMINAR_HOST is propagated to getStdout for other procedures
.map(({ item }) => item.moveRight(["laminarc", "show-jobs"]))
.map((i) =>
i.item.mapRight(i.move.apply)
.flatMapAsync(getStdout.apply)
.then((gotJobs) => gotJobs.moveRight(HealthCheckOutput.YAASQUEEN))
)
.item;
//export class LizCIServer {
// private constructor(
// private readonly healthCheckActivity = HealthCheckActivity(healthCheck),
// private readonly jobHookActivity = JobHookActivity(jobQueuer)
// ) {}
//
// private async route(req: ITraceable<req: Request, LogTraceable>) {
// return req.flatMap((req) => {
// const { logger, item: { method, pathname } } = req;
// if (pathname === "/health") {
// return this.healthCheckActivity.healthCheck(req);
// }
// return this.jobHookActivity.processHook(req);
// });
// }
//
// public async serve(req: Request): Promise<Response> {
// return LogTraceable(req).bimap(TraceUtil.withClassTrace(this)).map(this.route)
// }
//}
//private route(
// req: Traceable<Request & { pathname: string }>,
//): Traceable<Promise<Response>> {
// return req.flatMap((req) => {
// const { logger, item: { method, pathname } } = req;
// if (pathname === "/health") {
// return this.healthCheckActivity.healthCheck(req);
// }
// return this.jobHookActivity.processHook(req);
// });
//}
|