electron-transponder
v0.1.4
Published
Lightweight library that brings a request/response-like communication to Electron
Downloads
59
Readme
Electron Communicator
An electron router that has a similar interface/usage as an HTTP server, Express, and similar libraries.
Usage
In electron:
import { ipcMain } from 'electron';
import { mainTransponder } from 'electron-transponder';
// bootstrap transponder to start listening
const transponder = mainTransponder(ipcMain);
// register routes -- works similarly to app.get() or app.post()
transponder.register('GET', 'users', async (req, res) => {
let users = await getUsers();
res.send(users);
});
In front-end:
import { renderTransponder } from 'electron-transponder';
let users = await renderTansponder.request('GET' || requestMethods.GET, 'api/users', {
organization_id: 3
});