diff options
Diffstat (limited to 'src/modules/requests.js')
-rw-r--r-- | src/modules/requests.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/modules/requests.js b/src/modules/requests.js index d4ee678..60e0760 100644 --- a/src/modules/requests.js +++ b/src/modules/requests.js @@ -1,6 +1,6 @@ const fs = require("fs"); const path = require("path"); -const app = require("electron").app; +const { app, ipcMain } = require("electron"); const https = require("follow-redirects").https; const json = require("./json"); @@ -9,6 +9,23 @@ const version = require("./version"); var cache_dir = app.getPath("userData"); var cache_file = path.join(cache_dir, "cached-requests.json"); +// lets renderer delete request cache +ipcMain.on("delete-request-cache", () => { + requests.cache.delete.all(); +}) + +// lets renderer use `requests.get()` +ipcMain.handle("request", async (e, ...args) => { + let res = false; + + try { + res = await requests.get(...args); + }catch(err) {} + + return res; +}) + + // updates `cache_dir` and `cache_file` function set_paths() { cache_dir = app.getPath("userData"); |