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

@mh-cbon/bonjour-over-http

v1.0.1

Published

Http server to find / announce bonjour services

Downloads

3

Readme

bonjour-over-http

Http server to find / announce bonjour services.

It provides an API and a binary to install.

API

Publish services

POST /publish

Description : Publish a service over bonjour.

Format : multipart/form-data

Data:

  if ('name' in req.body)       options.name      = req.body.name
  if ('port' in req.body)       options.port      = req.body.port
  if ('type' in req.body)       options.type      = req.body.type
  if ('host' in req.body)       options.host      = req.body.host
  if ('subtypes' in req.body)   options.subtypes  = req.body.subtypes
  if ('protocol' in req.body)   options.protocol  = req.body.protocol
  if ('txt' in req.body)        options.txt       = req.body.txt

Response:

res[id] = {
  id:         publishedServices[id].id,
  name:       publishedServices[id].name,
  protocol:   publishedServices[id].protocol,
  type:       publishedServices[id].type,
  host:       publishedServices[id].host,
  port:       publishedServices[id].port,
  fqdn:       publishedServices[id].fqdn,
  subtypes:   publishedServices[id].subtypes,
  txt:        publishedServices[id].txt,
  published:  publishedServices[id].published,
}

GET /published

Description : List published services from this server.

Format : -

Data: none

Response:

res[id] = {
  id:         publishedServices[id].id,
  name:       publishedServices[id].name,
  protocol:   publishedServices[id].protocol,
  type:       publishedServices[id].type,
  host:       publishedServices[id].host,
  port:       publishedServices[id].port,
  fqdn:       publishedServices[id].fqdn,
  subtypes:   publishedServices[id].subtypes,
  txt:        publishedServices[id].txt,
  published:  publishedServices[id].published,
}

POST /unpublish

Description : unpublish previously published service.

Format : multipart/form-data

Data: req.body.id

Response: -

POST /unpublishall

Description : unpublish all previously published services.

Format : multipart/form-data

Data: -

Response: -

Browse services

POST /findone

Description : Find a service through bonjour.

Format : multipart/form-data

Data:

if( 'timeout' in req.body)  reqTimeout  = req.body.timeout
if( 'type' in req.body)     opt.type      = req.body.type
if( 'subtypes' in req.body) opt.subtypes  = req.body.subtypes
if( 'protocol' in req.body) opt.protocol  = req.body.protocol

Response:

{
  addresses:  [],
  name:       'whateverelse',
  fqdn:       'whateverelse._someother._tcp.local',
  host:       'linux.local',
  port:       8091,
  type:       'someother',
  protocol:   'tcp',
  subtypes:   [],
  rawTxt:     { type: 'Buffer', data: [0] },
  txt:        {}
}

POST /find

Description : Find services through bonjour.

Format : multipart/form-data

Data:

  if( 'timeout' in req.body)  reqTimeout    = req.body.timeout
  if( 'type' in req.body)     opt.type      = req.body.type
  if( 'subtypes' in req.body) opt.subtypes  = req.body.subtypes
  if( 'protocol' in req.body) opt.protocol  = req.body.protocol

Response:

[
  {
    name:       service.name,
    type:       service.type,
    subtypes:   service.subtypes,
    protocol:   service.protocol,
    host:       service.host,
    port:       service.port,
    fqdn:       service.fqdn,
    txt:        service.txt,
    published:  service.published
  }
]

Binary

Usage

bonjour-over-http 1.0.0
  Http server to find / announce bonjour services

Usage
  bonjour-over-http --config=/path/to/config.json

Options
  --config  | -c   Path to the JSON configuration file
  --verbose | -v   Enable verbosity pass in the module list to debug.

Config
  The configuration is a plain json object describing several options to
  apply to your instance of bonjour-over-http.

  {
    "ssl": {
      "port": "a number, or null for a random port",
      "host": "a host value to listen for https requests",
      "key": "a path to an SSL key",
      "ca": "a path to the SSL CA file",
      "cert": "a path to the SSL cert file"
    },
    "clear": {
      "port": "a number, or null for a random port",
      "host": "a host value to listen for http requests"
    },
    "cors": {
      "origin": "*",
      "credentials": "true|false",
      "methods": ["GET", "PUT", "POST"],
      "allowedHeaders": ["Content-Type", "Authorization"],
      "exposedHeaders": ["Content-Range", "X-Content-Range"],
      "maxAge": 600
    }
  }

Todos

  • add support for json body request (config switch + implementation + demo)

Read more

  • https://github.com/watson/bonjour
  • http://expressjs.com/en/api.html