npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@chix/transport

v2.9.14

Published

Chix Transport

Downloads

45

Readme

Chiχ Transport

Build Status

General purpose transporter.

It's job is:

  • receiving
  • sending
  • keep track of client scope.

Includes several transports:

  • websocket
  • websocket browser (client)
  • websocket client (server)
  • websocket proxy (server)
  • chrome (unfinished)
  • window (unfinished)
  • dummy

These transports will only accept input and output as defined by the provided (JSON) schemas.

When messages are received their payload will be received and emitted, it's then up to the listener what to do with these messages.

When the listener has done it's logic it can choose to send back the data by using the send() method of the transport(s).

Schema:

Both input & output messages have the below structure:

 {
   protocol: 'your-protocol',
   command: '<action>'
   payload: ...data
 }

The schema's must define which commands are available and what their payload structure will look like, this is done by creating json schema's for them.

Examples:

All transport requires a set of schemas.

Schemas

Default set of schemas is available through chix-runtime/schemas

const schemas = require('chix-runtime/schemas')

These define the valid incoming and outgoing messages, any unknown/invalid messages will send out an error message.

Note: The role will determine what is considered incoming and outgoing.

Dummy

import DummyTransport from 'chix-transport/dummy'
const transport = new DummyTransport({
 schemas: schemas
})

const connection = 'fake-conn'

// incoming
transport.receive({
 payload: { bogus: 'data' }
}, connection)

// outgoing
transport.reply('protocol', 'command', {
 bogus: 'data'
}, connection)

Websocket

Websocket server

import WebSocketTransport from 'chix-transport/websocket'
import http from 'http'

const port = 8000

const server = http.createServer((req, res) => res.send('You are being served'))

const options = {
 protocol: 'noflo',
 schemas: schemas,
 secure: true
}

const transport = new WebsocketTransport(options, server)

server.listen(port, () => {
 console.log('Listening on port %s', port)
})

Websocket Browser

In-browser server/client

import WebSocketBrowser from 'chix-transport/websocketBrowser'

const options = {
 protocol: 'noflo',
 schemas: schemas,
 secure: true,
 host: 'www.example.com',
 port: 8000,
 mount: '',
 secret: '123456', // client mode requires secret
 role: 'client'    // 'server' or 'client' mode
}

const transport = new WebsocketBrowser(options, server)

Websocket Client

Server side client

import WebSocketClient from 'chix-transport/websocketClient'

const options = {
 protocol: 'noflo',
 schemas: schemas,
 secure: true,
 host: 'www.example.com',
 port: 8000,
 mount: '',
 secret: '123456', // client mode requires secret
 role: 'client'    // 'server' or 'client' mode
}

const transport = new WebsocketClient(options, server)

Websocket Proxy

Proxy requests by being both client and server

import WebSocketProxy from 'chix-transport/websocketProxy'
import http from 'http'

const port = 8000

const server = http.createServer((req, res) => res.send('You are being served'))

const options = {
 protocol: 'noflo',
 schemas: schemas,
 secure: true
}

const transport = new WebsocketProxy(options, server)

server.listen(port, () => {
 console.log('Listening on port %s', port)
})

Chrome

Meant to be used within chrome content scripts (not used yet)

import ChromeTransport from 'chix-transport/chrome'

const options = {
 protocol: 'noflo',
 schemas: schemas
}

const transport = new ChromeTransport(options)