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

apx-express-socket.io

v0.3.2

Published

Express HTTP Server, and Socket.IO translator for APX API server

Downloads

13

Readme

APX Express Socket IO

Kado

STOP AND READ THIS

APX or Apex is no longer maintained and is superseded by Kado.

A new package is available to handle all your JavaScript needs. See kado.org for details.

Summary

Express HTTP Server, and Socket.IO translator for APX API server

Usage

Simply add the initializer to the Apx config.

$ npm install apx apx-express-socket.io
var apx = require('apx')
apx.start({
  translators: ['apx-express-socket.io']
})

Note about Socket.IO

As of writing we are using Socket.IO 0.9.16. After quite a bit of research and testing for our test suite it wont quite shut down correctly even when the HTTP server is closed. Express shuts down just fine but Socket.IO uses an instance upstream that doesn't seem to want to shutdown and restart within our tests.

In order to get the tests passing we restructured our tests to use a single instance of the translator rather than restarting it for each section.

In production this should not cause a limitation however we are open to suggestions on how to better handle shutting Socket.IO down. That way when the translator is stopped it can truly be started again.

Configuration

Express

Enabled

  • Variable express.enabled
  • Required no
  • Default true

Enable or disable express also listening on the port.

Host

  • Variable express.host
  • Require no
  • Default null

Host for express to listen on will default to the express default otherwise

Port

  • Variable express.port
  • Required no
  • Default 3000

Port to listen on otherwise will default to 3000

Logger

  • Variable express.logger
  • Require no
  • Default null

Enable or disable the express connection logger explicitly. By default it will be used during development and disabled when NODE_ENV is set to production

Static

  • Variable express.static
  • Required non
  • Default null

Set this to the root path of the static file server to be used with express. No static server will be setup if this variable is not set.

Routes

  • Variable express.routes
  • Required no

Array of routes that should be accepted.

{
  express: {
    routes: [
      {get: {path: '/status', file: 'actions/status.js'}}
      {post: {path: '/page', file: 'actions/page.js', methods: ['list','find','findOne','save','remove']}}
    ]
  }
}

Busboy

Busboy is the HTTP multipart parser for the express translator. In order to configure busboy use any of the prescribed configuration options in the docs see here

Example

{
  express: {
    busboy: {
      limits: {
        fileSize: 33554432 //32MB
      }
    }
  }
}

Socket.IO

Enabled

  • Variable socket-io.enabled
  • Required no
  • Default true

Enable or disable Socket.IO also listening on the express port.

Config

  • Variable socket-io.config
  • Required no
  • Default {}

Configuration object to be passed to socket.io at call time.

Routes

  • Variable socket-io.routes
  • Required no

Array of routes that should be accepted. These would be considered event listeners, eg page:list

{
  'socket-io': {
    routes: [
      {status: 'actions/status.js'},
      {page: {file: 'actions/page.js', methods: ['list','find','findOne','save','remove']}}
    ]
  }
}

Socket.IO in Production / Clustering

It is imperative to use redis to back Socket.IO in production or cluster environments. Here is an example of the configuration.

var redis = require('redis')
  , RedisStore = require('socket.io/lib/stores/redis')
  , IOStore = new RedisStore({
      redisPub: redis.createClient(),
      redisSub: redis.createClient(),
      redisClient: redis.createClient()
    }))
apx.start({
  'socket-io': {
    config: {
      store: IOStore
    }
  }
})

Changelog

0.3.1

  • Added req.raw.req and req.raw.res
  • Added static support through config

0.3.0

  • Upgraded to work with apx 0.6.0
  • Response handling now does the rendering in the translator
  • Added busboy to handle incoming file uploads
  • Works with latest apx file object format
  • Supports sending json, xml, raw, and files
  • Added extensive testing against input and output formats
  • In order to support busboy and mime type detection node support for node ~0.8 has been dropped
  • Redis is no longer started automatically and must be configured by the user
  • Added full config passing to socket.io for better control

0.2.0

  • Upgraded to work with apx 0.4.0
  • Added additional configuration parameters for express
  • Socket.io can now be disabled through the config
  • Added additional configuration parameters for socket.io

0.1.0

  • Initial release