-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.ts
More file actions
29 lines (24 loc) · 1.17 KB
/
controller.ts
File metadata and controls
29 lines (24 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { Context, TypedResponse } from "hono";
import { withControllerErrorHandling } from "../../utilities/error";
import { IFemaRiskIndexService } from "./service";
import { FemaRiskIndexDataResult } from "./types";
export interface IFemaRiskIndex {
updateFemaRiskIndexData(ctx: Context): Promise<TypedResponse<number, 200> | Response>;
getFemaRiskIndexData(ctx: Context): Promise<TypedResponse<FemaRiskIndexDataResult, 200> | Response>;
}
export class FemaRiskIndexController implements IFemaRiskIndex {
private femaRiskIndexService: IFemaRiskIndexService;
constructor(service: IFemaRiskIndexService) {
this.femaRiskIndexService = service;
}
updateFemaRiskIndexData = withControllerErrorHandling(async (ctx: Context): Promise<TypedResponse<number, 200>> => {
await this.femaRiskIndexService.updateFemaRiskIndexData();
return ctx.json(1, 200);
});
getFemaRiskIndexData = withControllerErrorHandling(
async (ctx: Context): Promise<TypedResponse<FemaRiskIndexDataResult, 200>> => {
const result = await this.femaRiskIndexService.getFemaRiskIndexData();
return ctx.json(result, 200);
}
);
}