___ /
_-_- _/\____ / __\\__
_-_-__ / ,-. -| / - ,-.`-.
_-_- `( o )-- / --( o )-'
`-' / `-'
tunel (n): RESTful message tunneling over IPC.
Quick Example
Here’s the code for Electron’s main thread:
const electron = require('electron');
const channel = electron.ipcMain;
const { app, registerChannel } = require('tunel/server');
registerChannel(channel);
app.get('/api/v1/profile', async req => {
void req;
return {
userName: 'robert',
fullName: 'Robert Denir Ona'
};
});
Here’s the cod for Electron’s renderer thread (i.e., the browser):
import request from 'tunel';
const doFetch = async () => {
const response = await request({
method: 'GET',
url: '/api/v1/profile',
data: { some: 'payload' },
headers: {
'Content-Type': 'application/json'
}
});
console.log(response);
};
doFetch();