-
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.
- Loading branch information
1 parent
43e861d
commit 4e7b90a
Showing
5 changed files
with
65 additions
and
0 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 |
---|---|---|
|
@@ -28,3 +28,6 @@ PRAYER_TIMES_LATITUDE= | |
#Jabarprov | ||
JABARPROV_URL= | ||
JABARPROV_KEYWORD= | ||
|
||
#Core Data | ||
CORE_DATA_URL= |
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 |
---|---|---|
|
@@ -33,4 +33,7 @@ export interface Config { | |
url: string | ||
keyword: string | ||
} | ||
coreData: { | ||
url: 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,55 @@ | ||
import axios from 'axios' | ||
import winston from 'winston' | ||
import { Config } from '../config/config.interface' | ||
|
||
class CoreData { | ||
constructor(private config: Config, private logger: winston.Logger) {} | ||
|
||
async Banner() { | ||
try { | ||
const response = await axios.get( | ||
this.config.coreData.url + `/banner` | ||
) | ||
const { data } = response | ||
return data | ||
} catch (error) { | ||
this.logger.error(error) | ||
throw error | ||
} | ||
} | ||
|
||
async Activity(startDate: string, endDate: string) { | ||
try { | ||
const response = await axios.get( | ||
this.config.coreData.url + `/kegiatan`, | ||
{ | ||
params: { | ||
start_date: startDate, | ||
end_date: endDate, | ||
}, | ||
} | ||
) | ||
const { data } = response | ||
return data | ||
} catch (error) { | ||
this.logger.error(error) | ||
throw error | ||
} | ||
} | ||
|
||
async ActivityById(id: string) { | ||
try { | ||
const response = await axios.get( | ||
this.config.coreData.url + `/kegiatan/${id}` | ||
) | ||
|
||
const { data } = response | ||
return data | ||
} catch (error) { | ||
this.logger.error(error) | ||
throw error | ||
} | ||
} | ||
} | ||
|
||
export default CoreData |