summaryrefslogtreecommitdiff
path: root/u/server/activity
diff options
context:
space:
mode:
Diffstat (limited to 'u/server/activity')
-rw-r--r--u/server/activity/fourohfour.ts28
-rw-r--r--u/server/activity/health.ts49
-rw-r--r--u/server/activity/index.ts8
3 files changed, 0 insertions, 85 deletions
diff --git a/u/server/activity/fourohfour.ts b/u/server/activity/fourohfour.ts
deleted file mode 100644
index cd90ba0..0000000
--- a/u/server/activity/fourohfour.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import {
- type IActivity,
- type ITraceable,
- JsonResponse,
- type PenguenoRequest,
- type ServerTrace,
-} from '@emprespresso/pengueno';
-
-const messages = [
- 'D: meow-t found! your api call ran away!',
- '404-bidden! but like...in a cute way >:3 !',
- ':< your data went on a paw-sible vacation!',
- 'uwu~ not found, but found our hearts instead!',
-];
-const randomFourOhFour = () => messages[Math.floor(Math.random() * messages.length)]!;
-
-export interface IFourOhFourActivity {
- fourOhFour: IActivity;
-}
-
-export class FourOhFourActivityImpl implements IFourOhFourActivity {
- public fourOhFour(req: ITraceable<PenguenoRequest, ServerTrace>) {
- return req
- .move(new JsonResponse(req, randomFourOhFour(), { status: 404 }))
- .map((resp) => Promise.resolve(resp.get()))
- .get();
- }
-}
diff --git a/u/server/activity/health.ts b/u/server/activity/health.ts
deleted file mode 100644
index 9396490..0000000
--- a/u/server/activity/health.ts
+++ /dev/null
@@ -1,49 +0,0 @@
-import {
- type IActivity,
- type IEither,
- IMetric,
- type ITraceable,
- JsonResponse,
- LogLevel,
- type Mapper,
- Metric,
- type PenguenoRequest,
- type ServerTrace,
- TraceUtil,
-} from '@emprespresso/pengueno';
-
-export enum HealthCheckInput {
- CHECK,
-}
-export enum HealthCheckOutput {
- YAASSSLAYQUEEN,
-}
-
-export interface IHealthCheckActivity {
- checkHealth: IActivity;
-}
-
-const healthCheckMetric = Metric.fromName('Health').asResult();
-export interface HealthChecker
- extends Mapper<ITraceable<HealthCheckInput, ServerTrace>, Promise<IEither<Error, HealthCheckOutput>>> {}
-export class HealthCheckActivityImpl implements IHealthCheckActivity {
- constructor(private readonly check: HealthChecker) {}
-
- public checkHealth(req: ITraceable<PenguenoRequest, ServerTrace>) {
- return req
- .flatMap(TraceUtil.withFunctionTrace(this.checkHealth))
- .flatMap(TraceUtil.withMetricTrace(healthCheckMetric))
- .flatMap((r) => r.move(HealthCheckInput.CHECK).map((input) => this.check(input)))
- .peek(TraceUtil.promiseify(TraceUtil.traceResultingEither(healthCheckMetric)))
- .map(
- TraceUtil.promiseify((h) => {
- const { status, message } = h.get().fold(
- () => ({ status: 500, message: 'err' }),
- () => ({ status: 200, message: 'ok' }),
- );
- return new JsonResponse(req, message, { status });
- }),
- )
- .get();
- }
-}
diff --git a/u/server/activity/index.ts b/u/server/activity/index.ts
deleted file mode 100644
index fa0a6b2..0000000
--- a/u/server/activity/index.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import type { ITraceable, PenguenoRequest, PenguenoResponse, ServerTrace } from '@emprespresso/pengueno';
-
-export interface IActivity {
- (req: ITraceable<PenguenoRequest, ServerTrace>): Promise<PenguenoResponse>;
-}
-
-export * from './health.js';
-export * from './fourohfour.js';