🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

alldata-peer-server-http

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alldata-peer-server-http

AllData Peer HTTP server module

latest
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

alldata-peer-server-http

Stability: 1 - Experimental

NPM version

Peer Server HTTP module for AllData, a distributed master-less write-once immutable event store database implementing "All Data" part of Lambda Architecture.

Usage

var AllDataPeerServer = require('alldata-peer-server-http');
var allDataPeerServer = new AllDataPeerServer({
    hostname: 'localhost',
    port: 8080
});

allDataPeerServer.on('_put', function (key, event, callback) {
    console.log('received request to _put: ' + key + ' ' + event);
    // process the _put
    callback(); // indicate success
});

allDataPeerServer.listen(function () {
    console.log('server listening...'); 
});

Test

npm test

Overview

AllDataPeerServer will listen to HTTP POST requests containing the _put request key and event encoded as a JSON string in the POST body.

Documentation

AllDataServer

Public API

AllDataPeerServer.listen(options, [callback])

  • options: See new AllDataPeerServer(options) options.
  • callback: See allDataPeerServer.listen(callback) callback.
  • Return: Object An instance of AllDataPeerServer with server running.

Creates new AllDataPeerServer and starts the server.

new AllDataPeerServer(options)

  • options: Object
    • hostname: String (Default: undefined) Hostname for the server to listen on. If not specified, the server will accept connections directed to any IPv4 address (INADDR_ANY).
    • port: Integer (Default: 8080) Port number for the server to listen on.

Creates a new AllDataPeerServer instance.

allDataPeerServer.close([callback])

  • callback: Function (Default: undefined) function () {} Optional callback to call once the server is stopped.

Stops the server from accepting new connections.

allDataPeerServer.listen([callback])

  • callback: Function (Default: undefined) function () {} Optional callback to call once the server is up.

Starts the server to listen to new connections.

Event _put

  • function (key, event, callback) {}
    • key: String AllData key generated for the event.
    • event: Object JavaScript object representation of the event to _put.
    • callback: Function function (error) {} The callback to call with an error or success of the _put operation.

Emitted when the server receives a new _put request from a peer client.

Signal error via callback(true) and success via callback().

allDataPeerServer.on('_put', function (key, event, callback) {
    console.log('received request to put: ' + key + ' ' + event); 
    // ... process the put
    callback();
});

Keywords

alldata

FAQs

Package last updated on 16 Oct 2013

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