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

@mizuka-wu/ipc-express

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mizuka-wu/ipc-express

This package enables you to use the electron ipc like an express application without the http overhead.

  • 0.3.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

ipc-express for electron

This library enables you to use the express framework in the mainthread of electron but without the http overhead.

Usage

Installation

npm i @mizuka-wu/ipc-express

in your main.js file

const { ipcMain } = require('electron');
const express = require('express');
const { IpcServer } = require('@mizuka-wu/ipc-express');

const expressApp = express();
const ipc = new IpcServer(ipcMain);

const someMiddleware = (req, res, next) => {
  next();
};
expressApp.use(someMiddleware);

expressApp.get('/test/:id', (req, res) => {
  res.send({
    params: req.params,
    query: req.query
  });
});


ipc.listen(expressApp);

In your frontend framework

import { IpcClient } from '@mizuka-wu/ipc-express';
const { ipcRenderer } = window.require('electron');

const ipc = new IpcClient(ipcRenderer);

  async componentDidMount() {
    const testId = 5;
    const { data } = await ipc.get(`/test/${testId}?test=testquery`);
    const { params, query } = data;
    console.log({ params, query })
  }

example

An example can be found in the example-app folder. To start the example-app:

cd example-app
npm run start:main
npm run start:renderer

contribute

  • fork this repo
  • npm i
  • make changes on new branch
  • update README
  • submit PR

Todo

  • extend the response object to an more express-like one

License

MIT

Copyright © 2019-Present, René Heinen. All rights reserved.

Keywords

FAQs

Package last updated on 17 Apr 2024

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