diff options
author | Elizabeth <me@liz.coffee> | 2025-06-02 11:14:52 -0700 |
---|---|---|
committer | Elizabeth <me@liz.coffee> | 2025-06-02 11:14:52 -0700 |
commit | 373d9ec700c0097a22cf665a8e33cf48998d1dc2 (patch) | |
tree | 71297ac69177037929e1bfb00b8c71038058acd5 /hooks/server/ci.ts | |
parent | 646c5eb11d3b9240f8434163d103a117d30c88c7 (diff) | |
download | ci-373d9ec700c0097a22cf665a8e33cf48998d1dc2.tar.gz ci-373d9ec700c0097a22cf665a8e33cf48998d1dc2.zip |
Minor things
Diffstat (limited to 'hooks/server/ci.ts')
-rw-r--r-- | hooks/server/ci.ts | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/hooks/server/ci.ts b/hooks/server/ci.ts deleted file mode 100644 index 4f0d7ba..0000000 --- a/hooks/server/ci.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { - FourOhFourActivityImpl, - getRequiredEnv, - HealthCheckActivityImpl, - type HealthChecker, - type IFourOhFourActivity, - type IHealthCheckActivity, - type ITraceable, - PenguenoRequest, - type ServerTrace, - TraceUtil, -} from "@emprespresso/pengueno"; -import type { Job } from "@emprespresso/ci-model"; -import { - healthCheck as _healthCheck, - type IJobHookActivity, - type IJobQueuer, - JobHookActivityImpl, - LaminarJobQueuer, -} from "@emprespresso/ci-hooks"; - -export class CiHookServer { - constructor( - healthCheck: HealthChecker = _healthCheck, - jobQueuer: IJobQueuer<ITraceable<Job, ServerTrace>> = new LaminarJobQueuer( - getRequiredEnv("LAMINAR_URL").fold((err, val) => - err ? "https://ci.liz.coffee" : val, - ), - ), - private readonly healthCheckActivity: IHealthCheckActivity = new HealthCheckActivityImpl( - healthCheck, - ), - private readonly jobHookActivity: IJobHookActivity = new JobHookActivityImpl( - jobQueuer, - ), - private readonly fourOhFourActivity: IFourOhFourActivity = new FourOhFourActivityImpl(), - ) {} - - private route(req: ITraceable<PenguenoRequest, ServerTrace>) { - const url = new URL(req.get().url); - if (url.pathname === "/health") { - return this.healthCheckActivity.checkHealth(req); - } - if (url.pathname === "/job") { - return this.jobHookActivity.processHook(req); - } - return this.fourOhFourActivity.fourOhFour(req); - } - - public serve(req: Request): Promise<Response> { - return PenguenoRequest.from(req) - .bimap(TraceUtil.withClassTrace(this)) - .map(this.route) - .get(); - } -} |