-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jabarprov): add a external from jabarprov go id (#2)
* feat(jabarprov): add a external from jabar prov * remove unused in main * add params fuzziness is false * remove schema jwt
- Loading branch information
1 parent
ff55901
commit a1a859c
Showing
6 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,7 @@ REDIS_TTL=0 | |
#PRAYER TIMES | ||
PRAYER_TIMES_URL= | ||
PRAYER_TIMES_LOCATION= | ||
|
||
#Jabarprov | ||
JABARPROV_URL= | ||
JABARPROV_KEYWORD= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,8 @@ export interface Config { | |
url: string | ||
location: string | ||
} | ||
jabarprov: { | ||
url: string | ||
keyword: string | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import axios from 'axios' | ||
import winston from 'winston' | ||
import { Config } from '../config/config.interface' | ||
import { Meta, Paginate } from '../helpers/paginate' | ||
|
||
class Jabarprov { | ||
constructor(private config: Config, private logger: winston.Logger) {} | ||
|
||
public async Search(page: number, limit: number) { | ||
try { | ||
const response = await axios.get( | ||
`${this.config.jabarprov.url}/v1/search`, | ||
{ | ||
params: { | ||
q: this.config.jabarprov.keyword, | ||
page, | ||
per_page: limit, | ||
sort_order: 'DESC', | ||
'domain[]': 'news', | ||
fuzziness: false, | ||
}, | ||
} | ||
) | ||
|
||
const { data, meta } = response.data | ||
const paginate = Paginate({ page, limit }) | ||
return { | ||
data, | ||
meta: Meta(paginate, meta.total_count), | ||
} | ||
} catch (error) { | ||
this.logger.error(error) | ||
throw error | ||
} | ||
} | ||
} | ||
|
||
export default Jabarprov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters