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

beamed

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beamed

A blazing fast, slim communication protocol for NodeJS IPC

  • 0.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by80%
Maintainers
1
Weekly downloads
 
Created
Source

beamed

Build Status

A blazing fast, slim communication protocol for NodeJS IPC.

NPM

Features

  • A lightweight protocol minimizes network traffic and provides high processing performance
  • The TypeScript API enables you to specify strictly typed endpoints and reuse the same type definitions on client and server side
  • Support for Unix, Windows, TCP and TLS sockets
  • Requesting, messaging and publish / subscribe
  • Send any payload (objects, buffers and strings)
  • No third party dependencies

Example

shared.ts

enum AuthTopics {
  login, // can be strings or numbers
}
interface AuthApi {
  [AuthTopics.login]: {
    req: Credentials;
    res: User;
  };
}

server.ts

import { createServer } from "beamed";
import { AuthApi, AuthTopics } from "./shared";

const bs = createServer<AuthApi>()
  .onRequest(AuthTopics.login, authenticate)
  .listen("/tmp/auth-test");

client.ts

import { connect } from "beamed";
import { AuthApi, AuthTopics } from "./shared";

const bc = connect<AuthApi>("/tmp/auth-test");
bc.request(AuthTopics.login, new Credentials("user", "p4ssw0rd")).then((user) =>
  console.log(user)
);

Protocol

Message types (Not completely implementing yet).

TypeMessage-PatternExamples
Request<length>?<topic>|<id>[|payload]19?1|8|J{"foo":"bar"}
5?2|45
Response<length>.<id>[|payload]17.8|J{"foo":"bar"}
3.45
Error-Response<length>X<id>|<error-code>[|message]17.8|J{"foo":"bar"}
6X45|42
Subscribe<length>+<topic>2+1
Unsubscribe<length>-<topic>2-1
Message / Push<length>!<topic>[|payload]17!1|J{"foo":"bar"}
2!2

Where the tokens have the following format

TokenFormatNote
lengthnumericThe byte length of the message content without this length (auto-generated)
topicutf-8 (except |)You can use TS Enums
idnumericThe request id (auto-generated)
error-codeutf-8 (except |)You can use TS Enums
messageutf-8Custom Error decription
payloadutf-8 or BufferPrefixed by a character that determines the content type:
J for Json,
B for binary data,
T for text

Keywords

FAQs

Package last updated on 14 Jul 2020

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