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

electron-cgi

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-cgi

Library to connect node applications to other apps using the stdin/stdout much like what was done in the 90s with CGI (common gateway interface)

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Electron CGI

Electron CGI is a NodeJs library that makes interacting with executables from other languages easy.

Currently there's support for .Net through the ElectronCgi.DotNet Nuget package.

Here's an example of how you can interact with a .Net application:

In NodeJs/Electron:

const { ConnectionBuilder } = require('electron-cgi');

const connection = new ConnectionBuilder()
        .connectTo('dotnet', 'run', '--project', 'DotNetConsoleProjectWithElectronCgiDotNetNugetPackage')
        .build();

connection.onDisconnect = () => {
    console.log('Lost connection to the .Net process');
};

connection.send('greeting', 'John', theGreeting => {
    console.log(theGreeting); // will print "Hello John!"
});

connection.close();

And in the .Net Console Application:

using ElectronCgi.DotNet;

//...
static void Main(string[] args)
{
    var connection = new ConnectionBuilder()
                        .WithLogging()
                        .Build();

    // expects a request named "greeting" with a string argument and returns a string
    connection.On<string, string>("greeting", name =>
    {
        return $"Hello {name}!";
    });

    // wait for incoming requests
    connection.Listen();        
}

How does it work?

Electron CGI establishes a "connection" with an external process. That external process must be configured to accept that connection. In the example above that's what the Listen method does.

In Node it is then possible to "send" requests (for example "greeting" with "John" as a parameter) and receive a response from the other process.

The way this communication channel is established is by using the connected process' stdin and stdout streams. This approach does not rely on staring up a web server and because of that introduces very little overhead in terms of the requests' round-trip time.

FAQs

Package last updated on 15 Feb 2019

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