summaryrefslogtreecommitdiff
path: root/server/ci.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/ci.ts')
-rw-r--r--server/ci.ts30
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();
- }
}