alchemy-router is the gateway from HTTP to Alchemy Resources for the Alchemy Micro-services Framework
Last updated 4 years ago by loyaltynz .
LGPL-3.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install alchemy-router 
SYNC missed versions from official npm registry.

Alchemy Router

npm version Build Status License

Alchemy Router is the gateway from HTTP to Alchemy Resources for the Alchemy Micro-services Framework. It can be used directly as an application or as a library to build and customise using express middleware and routes.

Router Application

To install the alchemy router run:

npm install -g alchemy-router

Then execute:


You can configure the router with the environment variables:

  1. AMQP_URI default 'amqp://localhost': the location of the (RabbitMQ) AMQP server
  2. PORT default 8080: the port to open the HTTP server on
  3. TIMEOUT default 5000: the router will return a 408 timeout response after waiting for the service.
  4. PATHS default '{}': the JSON string that matches service queues directly with paths, e.g. PATHS='{"/hello" : 'service.hello'}' will direct all calls that start with path /hello to the queue service.hello.


This repository also comes with an example Docker container, which is published to the docker hub.

Build the Docker container with:

docker build -t alchemy-router:$VERSION .

Push the docker container with:

docker push alchemy-router:$VERSION

Router Library

To install the router as a library:

npm install alchemy-router

To start a router:

AlchemyRouter = require 'alchemy-router'
router = new AlchemyRouter()


Middleware can be used to extend the routers with custom functionality. Middleware are objects with a callback that is an express middleware callback function, an optional start and stop functions that can control the life cycle of the middleware.

logging_middleware = {
  callback: (req, res, next) ->
    console.log req.path

  # promise to start middleware
  start: -> true

  # promise to stop middleware
  stop: -> true

AlchemyRouter = require 'alchemy-router'
router = new AlchemyRouter()
  middleware: [logging_middleware]

Additional Routes

Additional hard-coded routes can be added to the router, these can be useful for health-checks, logging, versioning ... Note: these routes will override any service routes.

hello_route = (app) ->
  app.get '/hello', (req, res) =>
    res.send {say: "hello"}

AlchemyRouter = require 'alchemy-router'
router = new AlchemyRouter()
  additional_routes: [hello_route]


This Alchemy-Router documentation is generated with docco from its annotated source code.

The Alchemy-Router package exports Router:

module.exports = require("./router")


Current Tags

  • 1.0.2                                ...           latest (4 years ago)

7 Versions

  • 1.0.2                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.0.5                                ...           4 years ago
  • 0.0.4                                ...           4 years ago
  • 0.0.3                                ...           4 years ago
  • 0.0.2                                ...           4 years ago
  • 0.0.1                                ...           4 years ago
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (7)
Dev Dependencies (5)
Dependents (0)

Copyright 2014 - 2016 © |