mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-29 15:44:13 +00:00
28 lines
789 B
JavaScript
28 lines
789 B
JavaScript
require('dotenv').config();
|
|
const { ipcMain } = require('electron');
|
|
const fetch = require('node-fetch');
|
|
|
|
const registerNotificationsIpc = (mainWindow, watcher) => {
|
|
ipcMain.handle('renderer:fetch-notifications', async () => {
|
|
try {
|
|
const notifications = await fetchNotifications();
|
|
return Promise.resolve(notifications);
|
|
} catch (error) {
|
|
return Promise.reject(error);
|
|
}
|
|
});
|
|
};
|
|
|
|
module.exports = registerNotificationsIpc;
|
|
|
|
const fetchNotifications = async () => {
|
|
try {
|
|
let url = process.env.BRUNO_INFO_ENDPOINT || 'https://appinfo.usebruno.com';
|
|
const data = await fetch(url).then((res) => res.json());
|
|
|
|
return data?.notifications || [];
|
|
} catch (error) {
|
|
return Promise.reject('Error while fetching notifications!', error);
|
|
}
|
|
};
|