scramjet-http-post

A simple stateless http server that emits all posted objects as a stream

Showing:

Popularity

Downloads/wk

29

GitHub Stars

1

Maintenance

Last Commit

3mos ago

Contributors

4

Package

Dependencies

1

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Scramjet HTTP POST

Greenkeeper badge

A simple HTTP server providing a stream of HTTP POST payloads in scramjet.

API

The module exposes the following methods:

scHTTP.body

scHTTP.body([scramjet, ]server) - a stream of post contents sent to the given server.

Arguments:

  • server - your HTTP server

Currently suppotes POST content-types:

  • application/json and text/json
  • application/form-data

Example

Grabs "votes" off a http server and pushes to command line.

    const scramjet = require("scramjet");
    const server = require("http").createServer().listen(6080);
    const scHTTP = require("scramjet-http-post");

    scHTTP.body(scramjet, server)
        .filter((data) => (data && typeof data === "object" && !isNaN(+data.vote) && typeof data.for === "string"))
        .map((data) => ({
            contestant: data.for.substr(0, 1).toUpperCase(),
            vote: data.vote <= 256 && data.vote >= 0 && +data.vote || NaN
        }))
        .filter((nr) => (console.log(nr), !isNaN(nr.vote)))
        .map((vote) => "F:" + vote.contestant + ",V:" + vote.vote.toString(16))
        .on("error", (err) => console.log(err && err.stack))
        .pipe(process.stdout);

License and contributions

As of version 2.0 Scramjet is MIT Licensed and as of 1.0.0 so is this module.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100