diff options
author | Elizabeth Hunt <me@liz.coffee> | 2025-06-29 17:31:30 -0700 |
---|---|---|
committer | Elizabeth Hunt <me@liz.coffee> | 2025-06-29 17:31:30 -0700 |
commit | 58be1809c46cbe517a18d86d0af52179dcc5cbf6 (patch) | |
tree | 9ccc678b3fd48c1a52fe501600dd2c2051740a55 /server/ci.ts | |
parent | d4791f3d357634daf506fb8f91cc5332a794c421 (diff) | |
download | ci-58be1809c46cbe517a18d86d0af52179dcc5cbf6.tar.gz ci-58be1809c46cbe517a18d86d0af52179dcc5cbf6.zip |
Move to nodejs and also lots of significant refactoring that should've been broken up but idgaf
Diffstat (limited to 'server/ci.ts')
-rw-r--r-- | server/ci.ts | 30 |
1 files changed, 15 insertions, 15 deletions
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<ITraceable<Job, ServerTrace>> = 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<PenguenoRequest, ServerTrace>) { - const url = new URL(req.get().url); + public serve(req: ITraceable<PenguenoRequest, ServerTrace>) { + 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<Response> { - return PenguenoRequest.from(req) - .bimap(TraceUtil.withClassTrace(this)) - .map((req) => this.route(req)) - .get(); - } } |