From 58be1809c46cbe517a18d86d0af52179dcc5cbf6 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sun, 29 Jun 2025 17:31:30 -0700 Subject: Move to nodejs and also lots of significant refactoring that should've been broken up but idgaf --- server/ci.ts | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'server/ci.ts') diff --git a/server/ci.ts b/server/ci.ts index f57c426..c8aa6a1 100644 --- a/server/ci.ts +++ b/server/ci.ts @@ -1,34 +1,41 @@ import { FourOhFourActivityImpl, - getRequiredEnv, + getEnv, HealthCheckActivityImpl, type HealthChecker, type IFourOhFourActivity, type IHealthCheckActivity, type ITraceable, PenguenoRequest, + Server, type ServerTrace, - TraceUtil, } from '@emprespresso/pengueno'; import type { Job } from '@emprespresso/ci_model'; -import { type IJobHookActivity, type IJobQueuer, JobHookActivityImpl, LaminarJobQueuer } from './job'; -import { healthCheck as _healthCheck } from '.'; +import { + healthCheck as _healthCheck, + type IJobHookActivity, + type IJobQueuer, + JobHookActivityImpl, + LaminarJobQueuer, +} from '@emprespresso/ci_server'; export const DEFAULT_CI_SERVER = 'https://ci.liz.coffee'; -export class CiHookServer { +export class CiHookServer implements Server { constructor( healthCheck: HealthChecker = _healthCheck, jobQueuer: IJobQueuer> = new LaminarJobQueuer( - getRequiredEnv('LAMINAR_URL').fold(({ isLeft, value }) => (isLeft ? DEFAULT_CI_SERVER : value)), + getEnv('LAMINAR_URL') + .orSome(() => DEFAULT_CI_SERVER) + .get(), ), private readonly healthCheckActivity: IHealthCheckActivity = new HealthCheckActivityImpl(healthCheck), private readonly jobHookActivity: IJobHookActivity = new JobHookActivityImpl(jobQueuer), private readonly fourOhFourActivity: IFourOhFourActivity = new FourOhFourActivityImpl(), ) {} - private route(req: ITraceable) { - const url = new URL(req.get().url); + public serve(req: ITraceable) { + const url = new URL(req.get().req.url); if (url.pathname === '/health') { return this.healthCheckActivity.checkHealth(req); } @@ -37,11 +44,4 @@ export class CiHookServer { } return this.fourOhFourActivity.fourOhFour(req); } - - public serve(req: Request): Promise { - return PenguenoRequest.from(req) - .bimap(TraceUtil.withClassTrace(this)) - .map((req) => this.route(req)) - .get(); - } } -- cgit v1.2.3-70-g09d2