-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.ts
More file actions
32 lines (27 loc) · 800 Bytes
/
base.ts
File metadata and controls
32 lines (27 loc) · 800 Bytes
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
30
31
32
import type { Yelix } from "@/src/core/Yelix.ts";
import type { Ctx } from "@/mod.ts";
class APIReferenceBase {
referenceTitle: string = "API Reference";
path: string;
constructor(path: string) {
this.path = path ||
"/" + this.referenceTitle.toLowerCase().replace(/\s+/g, "-");
}
/**
* Gets the API reference response.
* This method should be overridden in derived classes.
* @param ctx The context object
*/
getResponse(ctx: Ctx): Response | Promise<Response> {
return ctx.text(
"API Reference not implemented. Please use the Yelix API documentation for more information.",
501,
);
}
serve(yelix: Yelix): void {
yelix.app.get(this.path, (ctx: Ctx) => {
return this.getResponse(ctx);
});
}
}
export { APIReferenceBase };