Stratumn agent for NodeJS
This NodeJS module exposes functions to create Stratumn agents using Javascript.
Creating an HTTP server for an agent
var express = require('express');
var agent = require('stratumn-agent-js');
var transitions = require('./lib/transitions');
var app = express();
var storeHttpClient = agent.storeHttpClient(process.env.STRATUMN_STORE_URL || 'http://store:5000');
app.disable('x-powered-by');
var agentHttpServer = agent.httpServer(transitions, storeHttpClient);
app.use('/', agentHttpServer);
app.listen(3000, function() {
console.log('Listening on :' + this.address().port);
});
Advanced usage
httpServer
creates an HTTP server for an agent.storeHttpClient
creates an instance to work with stores via HTTP.agent
creates an instance to work directly with an agent without a server.