summaryrefslogtreecommitdiff
path: root/u/server/activity
diff options
context:
space:
mode:
authorElizabeth Hunt <lizhunt@amazon.com>2025-05-14 18:02:34 -0700
committerElizabeth Hunt <lizhunt@amazon.com>2025-05-14 18:03:15 -0700
commit3a3fb9c8ab0c798a278f76d40de216fa96f6e2c4 (patch)
treebb44512bccceee43c57372a4ae325b5b70a6e192 /u/server/activity
parentf316b4a015b5b2e2988b250b3c34bbb7f9994709 (diff)
downloadci-3a3fb9c8ab0c798a278f76d40de216fa96f6e2c4.tar.gz
ci-3a3fb9c8ab0c798a278f76d40de216fa96f6e2c4.zip
moar
Diffstat (limited to 'u/server/activity')
-rw-r--r--u/server/activity/health.ts39
-rw-r--r--u/server/activity/mod.ts8
2 files changed, 47 insertions, 0 deletions
diff --git a/u/server/activity/health.ts b/u/server/activity/health.ts
new file mode 100644
index 0000000..bf1f52c
--- /dev/null
+++ b/u/server/activity/health.ts
@@ -0,0 +1,39 @@
+import {
+ Either,
+ getRequiredEnv,
+ getStdout,
+ type ITraceable,
+ LogLevel,
+ type Mapper,
+ TraceUtil,
+} from "@emprespresso/pengueno";
+
+type HealthCheckInput = "healthy?";
+type HealthCheckOutput = "healthy!";
+
+const HealthCheckActivity = <Trace>(
+ check: Mapper<
+ ITraceable<HealthCheckInput, Trace>,
+ Promise<Either<Error, HealthCheckOutput>>
+ >,
+) =>
+(req: ITraceable<Request, Trace>) =>
+ req.bimap(TraceUtil.withFunctionTrace(HealthCheckActivity))
+ .flatMap((r) => r.move(<HealthCheckInput> "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 },
+ );
+ });
+ }));
diff --git a/u/server/activity/mod.ts b/u/server/activity/mod.ts
new file mode 100644
index 0000000..6908c26
--- /dev/null
+++ b/u/server/activity/mod.ts
@@ -0,0 +1,8 @@
+import type { RequestFilter } from "@emprespresso/pengueno";
+
+export class r200 extends Response {
+ public override readonly status = 200;
+}
+
+export interface IActivity<Trace> extends RequestFilter<r200, Trace> {
+}