diff options
author | Elizabeth Hunt <lizhunt@amazon.com> | 2025-05-16 16:17:13 -0700 |
---|---|---|
committer | Elizabeth Hunt <lizhunt@amazon.com> | 2025-05-16 16:17:13 -0700 |
commit | ef51b25e4388cbdf3a27e23d9f1fa381ae20a5ad (patch) | |
tree | d54be88fa30fd2da97a97fc7006d9ff9d94ed16a /u/server/activity | |
parent | 1ab20482ab37d7962c8e69701163270e687df3ca (diff) | |
download | ci-ef51b25e4388cbdf3a27e23d9f1fa381ae20a5ad.tar.gz ci-ef51b25e4388cbdf3a27e23d9f1fa381ae20a5ad.zip |
snapshot
Diffstat (limited to 'u/server/activity')
-rw-r--r-- | u/server/activity/fourohfour.ts | 30 | ||||
-rw-r--r-- | u/server/activity/health.ts | 12 | ||||
-rw-r--r-- | u/server/activity/mod.ts | 13 |
3 files changed, 47 insertions, 8 deletions
diff --git a/u/server/activity/fourohfour.ts b/u/server/activity/fourohfour.ts new file mode 100644 index 0000000..698dacd --- /dev/null +++ b/u/server/activity/fourohfour.ts @@ -0,0 +1,30 @@ +import { + type ITraceable, + JsonResponse, + TraceUtil, +} from "@emprespresso/pengueno"; + +export enum HealthCheckInput { + CHECK, +} +export enum HealthCheckOutput { + YAASQUEEN, +} + +const messages = [ + "(≧ω≦)ゞ Oopsie! This endpoint has gone a-404-dable!", + "。゚(。ノωヽ。)゚。 Meow-t found! Your API call ran away!", + "404-bidden! But like...in a cute way (・`ω´・) !", + "(=①ω①=) This endpoint is hiss-terically missing!", + "┐(´∀`)┌ Whoopsie fluff! No API here!", + "(つ≧▽≦)つ Your data went on a paw-sible vacation!", + "(ꈍᴗꈍ) Uwu~ not found, but found our hearts instead!", + "ヽ(;▽;)ノ Eep! This route has ghosted you~", +]; +export const FourOhFourActivity = <Trace>(req: ITraceable<Request, Trace>) => + req.bimap(TraceUtil.withFunctionTrace(FourOhFourActivity)) + .map(() => + new JsonResponse(messages[Math.random() * messages.length], { + status: 404, + }) + ); diff --git a/u/server/activity/health.ts b/u/server/activity/health.ts index 7ee6629..98acbb8 100644 --- a/u/server/activity/health.ts +++ b/u/server/activity/health.ts @@ -27,15 +27,19 @@ export const HealthCheckActivity = <Trace>( health.mapBoth((e) => { trace.addTrace(LogLevel.ERROR).trace(`${e}`); return new Response( - "oh no, i need to eat more vegetables (。•́︿•̀。)...\n", - { status: 500 }, + JSON.stringify({ + message: "oh no, i need to eat more vegetables (。•́︿•̀。)...", + }), + { status: 500, headers: { "Content-Type": "application/json" } }, ); }, (_healthy) => { const msg = `think im healthy!! (✿˘◡˘) ready to do work~`; trace.trace(msg); return new Response( - msg + "\n", - { status: 200 }, + JSON.stringify({ + message: "oh no, i need to eat more vegetables (。•́︿•̀。)...", + }), + { status: 500, headers: { "Content-Type": "application/json" } }, ); }); })); diff --git a/u/server/activity/mod.ts b/u/server/activity/mod.ts index 9d05d3c..f0cbed2 100644 --- a/u/server/activity/mod.ts +++ b/u/server/activity/mod.ts @@ -1,10 +1,15 @@ -import type { RequestFilter } from "@emprespresso/pengueno"; +import { JsonResponse, type RequestFilter } from "@emprespresso/pengueno"; -export class r200 extends Response { - public override readonly status = 200; +export enum StatusOK { + FOLLOW = 300, + OK = 200, +} +export interface ActivityOk { + readonly status: StatusOK; } -export interface IActivity<Trace> extends RequestFilter<r200, Trace> { +export interface IActivity<Trace> + extends RequestFilter<ActivityOk, Trace, Response> { } export * from "./health.ts"; |