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

isnode-mod-router

v0.1.6

Published

ISNode Router Module

Downloads

14

Readme

ISNode Router Module

Introduction

This is just a module for the ISNode Framework. To learn how to use the framework, we strongly suggest obtaining a copy of the Hello World example.

The router module is responsible for creating, managing and utilizing routers. Routers are defined within the system configuration file and are responsible for passing requests from interfaces through to service controllers.

System Configuration

Below is an example configuration for the router module within the system configuration file (config.json). It defines a single router instance that routes messages from all interfaces to all services. You can also define individual interfaces and services by name within the array instead of the "select all" (*) symbol. This module also supports the definition of multiple routers - and thus makes for a very configurable framework.

  "router": {
    "instances": {
      "RouterOne": {
        "interfaces": ["*"],
        "services": ["*"]
      }
    }
  }

Methods

count()

Synchronous Function. Returns a count of the number of routers that have been instantiated

Input Parameters:

N/A

Returns: (Integer) A count of the number of instantiated routers

Example

	console.log(isnode.module("router").count()); // Prints "2" to the console if 2 routers have been instantiated

get(name)

Synchronous Function. Returns a router based on its name

Input Parameters:

  1. name - (Object) Name of the router

Returns: The router object

Example

	var RouterOne = isnode.module("router").get("RouterOne");

router.incoming(message)

Event-Driven Function. Accepts an incoming message from an interface and routes it to the relevent service controller. Also opens a listener for a response event and routes it back to the interface when received.

Input Parameters:

  1. message - (Object) Message Object

Returns: N/A

Example

	var message = {
		"type": "http",
		"interface": "http",
		"msgId": "1234",
		"state": "incoming",
		"directional": "simplex",
		"request": {
			"path": "/",
			"host": "localhost",
			"port": 80,
			"query": "name=john@age=21",
			"headers": {},
			"params": {},
			"cookies": {},
			"ip": "127.0.0.11",
			"verb": "GET",
			"secure": false,
			"body": "",
		}
	}

	var RouterOne = isnode.module("router").get("RouterOne");
	RouterOne.incoming(message);

router.route(hostname, url)

Synchronous Function. Returns a route object that references service+controller, based on a hostname and url (path)

Input Parameters:

  1. hostname - (String) Hostname
  2. url - (String) URL Path

Returns: N/A

Example

	var route = RouterOne.route("localhost", "/test");