Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tunel

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tunel

tunel is a RESTful message tunnel over IPC.

  • 0.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-47.06%
Maintainers
1
Weekly downloads
 
Created
Source
  ___                 /
    _-_-  _/\____    / __\\__
 _-_-__  / ,-. -|   /  -  ,-.`-.
    _-_- `( o )--  /  --( o )-'
           `-'    /      `-'
tunel (n): RESTful message tunneling over IPC.

Quick Example

Here’s the code for Electron’s main thread:

//
// Main Thread
//

const electron = require('electron');
const channel = electron.ipcMain;

const { app, registerChannel } = require('tunel/server');

registerChannel(channel);

// `app` API is similar to `express.js`
app.get('/api/v1/profile', async req => {
  // You can access req.body, req.params…
  void req;

  // Unlike express, there is no `res` object.
  // As soon as you return from the function, you’ll relay
  // a response back.
  // So, returning a JSON `json`, is similar to `res.send(json)`.
  return {
    userName: 'robert',
    fullName: 'Robert Denir Ona'
  };
});

Here’s the cod for Electron’s renderer thread (i.e., the browser):

//
// Renderer Thread
//

import request from 'tunel';

const doFetch = async () => {
  // `request` API is similar to `axios`.
  const response = await request({
    method: 'GET',
    url: '/api/v1/profile',
    data: { some: 'payload' },
    headers: {
      'Content-Type': 'application/json'
    }
  });

  // Will log
  // `{ status: 200, data: { userName: 'robert',
  // fullName: 'Robert Denir Ona' }}`
  console.log(response);
};

doFetch();

Keywords

FAQs

Package last updated on 26 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc