Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stratumn-agent-js

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stratumn-agent-js

This NodeJS module exposes functions to create Stratumn agents using Javascript.

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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');

// Assumes your transition functions are in ./lib/transitions.
var transitions = require('./lib/transitions');

// The server is an Express server.
var app = express();

// Create an HTTP store client to save segments.
// Assumes an HTTP store server is available on env.STRATUMN_STORE_URL or http://store:5000.
var storeHttpClient = agent.storeHttpClient(process.env.STRATUMN_STORE_URL || 'http://store:5000');

app.disable('x-powered-by');

// Create an agent HTTP server from the transition functions and the store client.
var agentHttpServer = agent.httpServer(transitions, storeHttpClient);

// Mount agent on the root path of the server.
app.use('/', agentHttpServer);

// Start the server.
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.

Keywords

FAQs

Package last updated on 23 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc