A microservice platform.


License
Unlicense
Install
npm install colosseum@0.8.1

Documentation

Colosseum

Travis npm

A Node JS microservice platform.

A service is a function which accepts a single colosseum parameter. This means that a service can be written without any explicit dependency on Colosseum, which means that the service does not need updating for new versions of Colosseum.

The colosseum object abstracts the way in which services communicate. Each service can handle specific messages using colosseum.handle(message, handler). A service can send a message using colosseum.message(service, message, payload).

Since a service is just a function which operates on the abstract colosseum object, we can run and manage services in many different ways. The simplest is to run all the services inside the same process. More robustly, you could run each service as a separate process on the same machine. To scale, you can run separate services on separte servers. All this is possible without changing the way in which a service is authored.

Usage

Install

npm install --save colosseum

Use

// index.js

import colosseum from 'colosseum';

const options = {
  port: 8080,
  secret: 'my-secret-used-for-json-web-token-generation',
  hash: 'hash-of-password-generated-using-colosseum-hash',
  installDirectory: '/path/to/install/directory'
};

colosseum(options).then(() => {
  console.log('Colosseum is running.');
}).catch((error) => {
  console.error(error.stack);
});

Run

node index.js

Verify Colosseum is running by visiting http://localhost:8080/status

Endpoints

Status

GET /status

Returns 200 👌 if everything is running well.

Authenticate

POST /authenticate

Body { "password": "your-password" }

Returns { "token": "123456" }

Message

POST /<service>/<message>/<token>

Body can be any custom payload for service to handle.

Returns { "success": BOOLEAN, "response": CUSTOM_SERVICE_RESPONSE }