-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathHome.ts
More file actions
35 lines (31 loc) · 1.21 KB
/
Home.ts
File metadata and controls
35 lines (31 loc) · 1.21 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
30
31
32
33
34
35
import { Request, Response } from 'express';
import Handler from './BaseHandler';
class HomeHandler extends Handler {
public index(req: Request, res: Response): void {
try {
res.status(200).send({
maintaner: 'Sutan Gading Fadhillah Nasution <sutan.gnst@gmail.com>',
source: 'https://github.com/gadingnst/hadith-api',
endpoints: {
list: {
pattern: 'https://api.hadith.gading.dev/books',
description: 'Returns the list of available Hadith Books.'
},
hadith: {
pattern: 'https://api.hadith.gading.dev/books/{name}?range={number}-{number}',
example: 'https://api.hadith.gading.dev/books/muslim?range=1-150',
description: 'Returns hadiths within a specified range of numbers. (Note: For performance reasons, max accepted range: 300)'
},
specific: {
pattern: 'https://api.hadith.gading.dev/books/{name}/{number}',
example: 'https://api.hadith.gading.dev/books/bukhari/52',
description: 'Returns specific hadith.'
}
}
});
} catch (err) {
this.handleHttpError(req, res, err as Error);
}
}
}
export default new HomeHandler();