Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hadith - API

> Simple Islamic Hadith API with Indonesia Translation.
> Simple Islamic Hadith API with Indonesian Translation.

### Deploy
Already deployed in [https://api.hadith.gading.dev] or you can deploy your own at:
Expand Down Expand Up @@ -31,8 +31,8 @@ Already deployed in [https://api.hadith.gading.dev] or you can deploy your own a

### Endpoint usage
- [x] `/books` = Returns the list of available Hadith Books.
- [x] `/books/{name}?range={number}-{number}` = Returns hadiths by range of number. **Example: [/books/bukhari?range=300-500](https://api.hadith.gading.dev/books/bukhari?range=300-500)**. *(Note: For performance reasons, max accepted range: 300)*
- [x] `/books/{name}/{number}` = Returns spesific hadith. **Example: [/books/muslim/5](https://api.hadith.gading.dev/books/muslim/5)**
- [x] `/books/{name}?range={number}-{number}` = Returns hadiths within the specified range of numbers. **Example: [/books/bukhari?range=300-500](https://api.hadith.gading.dev/books/bukhari?range=300-500)**. *(Note: For performance reasons, max accepted range: 300)*
- [x] `/books/{name}/{number}` = Returns specific hadith. **Example: [/books/muslim/5](https://api.hadith.gading.dev/books/muslim/5)**

### Example Response
> Fetching on [HR. Muslim No. 5](https://api.hadith.gading.dev/books/muslim/5)
Expand All @@ -44,9 +44,9 @@ Already deployed in [https://api.hadith.gading.dev] or you can deploy your own a
- [Uthmani](https://groups.google.com/forum/#!topic/colteachers/Y6iKganK0tQ)

### Available Commands
- `yarn start` = run server.
- `yarn dev` = run develop server.
- `yarn crawl` = collect new data from the data source, then unifying it in one JSON file.
- `yarn start` = Run server.
- `yarn dev` = Run develop server.
- `yarn crawl` = Collects new data from the data source and unifies it into a single JSON file.

### LICENSE
MIT
Expand Down
4 changes: 2 additions & 2 deletions api/Handlers/Hadith.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class HadithHandler extends Handler {

if (Number.isNaN(parsedNumber)) this.setHttpError({
code: 400,
message: 'Hadith number must be number.'
message: 'Hadith number must be a number.'
})

const hadith = Hadith.getByName(name)
Expand Down Expand Up @@ -70,7 +70,7 @@ class HadithHandler extends Handler {
if (from && to) {
if (from < 1) this.setHttpError({
code: 400,
message: `Start range shouldn\'t below 1`
message: `Start range shouldn\'t be below 1`
})

const requestedRange = (to - from) + 1
Expand Down
16 changes: 8 additions & 8 deletions api/Handlers/Home.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Request, Response } from 'express'
import Handler from './BaseHandler'
import { Request, Response } from 'express';
import Handler from './BaseHandler';

class HomeHandler extends Handler {

Expand All @@ -16,20 +16,20 @@ class HomeHandler extends Handler {
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 by range of number. (Note: For performance reasons, max accepted range: 300)'
description: 'Returns hadiths within a specified range of numbers. (Note: For performance reasons, max accepted range: 300)'
},
spesific: {
specific: {
pattern: 'https://api.hadith.gading.dev/books/{name}/{number}',
example: 'https://api.hadith.gading.dev/books/bukhari/52',
description: 'Returns spesific hadith.'
description: 'Returns specific hadith.'
}
}
})
});
} catch (err) {
this.handleHttpError(req, res, err as Error)
this.handleHttpError(req, res, err as Error);
}
}

}

export default new HomeHandler()
export default new HomeHandler();
8,940 changes: 4,470 additions & 4,470 deletions books/abu-daud.json

Large diffs are not rendered by default.

8,744 changes: 4,372 additions & 4,372 deletions books/ahmad.json

Large diffs are not rendered by default.

13,526 changes: 6,763 additions & 6,763 deletions books/bukhari.json

Large diffs are not rendered by default.

5,932 changes: 2,966 additions & 2,966 deletions books/darimi.json

Large diffs are not rendered by default.

8,654 changes: 4,327 additions & 4,327 deletions books/ibnu-majah.json

Large diffs are not rendered by default.

3,192 changes: 1,596 additions & 1,596 deletions books/malik.json

Large diffs are not rendered by default.

9,994 changes: 4,997 additions & 4,997 deletions books/muslim.json

Large diffs are not rendered by default.

Loading