MCPcopy
hub / github.com/felixmosh/bull-board / HapiAdapter

Class HapiAdapter

packages/hapi/src/HapiAdapter.ts:22–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20};
21
22export class HapiAdapter implements IServerAdapter {
23 private basePath = '';
24 private bullBoardQueues: BullBoardQueues | undefined;
25 private errorHandler: ((error: Error) => ControllerHandlerReturnType) | undefined;
26 private statics: { path: string; route: string } | undefined;
27 private viewPath: string | undefined;
28 private entryRoute: AppViewRoute | undefined;
29 private apiRoutes: HapiRouteDef[] | undefined;
30 private uiConfig: UIConfig = {};
31
32 public setBasePath(path: string): HapiAdapter {
33 this.basePath = path;
34 return this;
35 }
36
37 public setStaticPath(staticsRoute: string, staticsPath: string): HapiAdapter {
38 this.statics = { route: staticsRoute, path: staticsPath };
39
40 return this;
41 }
42
43 public setViewsPath(viewPath: string): HapiAdapter {
44 this.viewPath = viewPath;
45 return this;
46 }
47
48 public setErrorHandler(handler: (error: Error) => ControllerHandlerReturnType) {
49 this.errorHandler = handler;
50 return this;
51 }
52
53 public setApiRoutes(routes: AppControllerRoute[]): HapiAdapter {
54 this.apiRoutes = routes.reduce((result, routeRaw) => {
55 const routes = Array.isArray(routeRaw.route) ? routeRaw.route : [routeRaw.route];
56 const methods = Array.isArray(routeRaw.method) ? routeRaw.method : [routeRaw.method];
57
58 routes.forEach((path) => {
59 result.push({
60 method: methods.map((method) => method.toUpperCase()) as any,
61 path: toHapiPath(path),
62 handler: routeRaw.handler,
63 });
64 });
65
66 return result;
67 }, [] as HapiRouteDef[]);
68
69 return this;
70 }
71
72 public setEntryRoute(routeDef: AppViewRoute): HapiAdapter {
73 this.entryRoute = routeDef;
74
75 return this;
76 }
77
78 public setQueues(bullBoardQueues: BullBoardQueues): HapiAdapter {
79 this.bullBoardQueues = bullBoardQueues;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected