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');
var transitions = require('./lib/transitions');
var storeHttpClient = Agent.storeHttpClient(process.env.STRATUMN_STORE_URL || 'http://store:5000');
var agent = Agent.create(transitions, storeHttpClient);
var agentHttpServer = Agent.httpServer(agent, { cors: {} });
var app = express();
app.disable('x-powered-by');
app.use('/', agentHttpServer);
app.listen(3000, function() {
console.log('Listening on :' + this.address().port);
});
Advanced usage
create
creates an agent instance.storeHttpClient
creates an instance to work with stores via HTTP.httpServer
creates an HTTP server for an agent.