Giter Club home page Giter Club logo

alldata-server-http's Introduction

alldata-server-http

Stability: 1 - Experimental

NPM version

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

Usage

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

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

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

Test

npm test

Overview

AllDataServer will listen to HTTP POST requests containing the event encoded as a JSON string in the POST body.

Documentation

AllDataServer

Public API

AllDataServer.listen(options, [callback])

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

Creates new AllDataServer and starts the server.

new AllDataServer(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 AllDataServer instance.

allDataServer.close([callback])

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

Stops the server from accepting new connections.

allDataServer.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 (event, callback) {}
    • 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 client.

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

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.