From 4fd63822ac29dfc71154ba0a8a93d0b6ce553994 Mon Sep 17 00:00:00 2001 From: nordin Date: Tue, 25 Apr 2023 21:38:02 +0800 Subject: [PATCH 1/3] feat utils: added function to fetch prayer times, fetch zones --- index.js | 3 + package.json | 9 + utils/index.js | 87 ++++++++++ yarn.lock | 450 +++++++++++++++++++++++++++++++++++++++++++++++++ zone.json | 89 ++++++++++ 5 files changed, 638 insertions(+) create mode 100644 index.js create mode 100644 package.json create mode 100644 utils/index.js create mode 100644 yarn.lock create mode 100644 zone.json diff --git a/index.js b/index.js new file mode 100644 index 0000000000..c667a5fd56 --- /dev/null +++ b/index.js @@ -0,0 +1,3 @@ +const { getPrayerTimes } = require('./utils') + +getPrayerTimes('today', 'SGR03') \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000000..6a006be0ee --- /dev/null +++ b/package.json @@ -0,0 +1,9 @@ +{ + "dependencies": { + "axios": "^1.3.6", + "express": "^4.18.2" + }, + "scripts": { + "dev": "node index" + } +} diff --git a/utils/index.js b/utils/index.js new file mode 100644 index 0000000000..bd6886657e --- /dev/null +++ b/utils/index.js @@ -0,0 +1,87 @@ +const axios = require('axios'); +const https = require('https') + +const Period = { + Today: 'today', + Week: 'week', + Month: 'month', + Year: 'year', + Duration: 'duration' +} + +const getZones = () => { + return new Promise((resolve, reject) => { + const url = "https://www.e-solat.gov.my/index.php?siteId=24&pageId=24"; + https.get(url, (res) => { + let result = ''; + res.on('data', (chunk) => { + result += chunk; + }); + res.on('end', () => { + const pattern = /