🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

cycle-node-http-driver

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

cycle-node-http-driver

A HTTP server driver for Cycle.js

0.1.0
latest
npm
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

cycle-node-http-driver

A server HTTP driver for Cycle.js

Basic usage

const run = require('@cycle/run').default;
const makeHTTPServerDriver = require('cycle-node-http-driver').makeHTTPServerDriver;

function main({ HTTPServer }) {
  // Get the request from the HTTPServer source
  const request$ = HTTPServer;

  // Build a stream containing your HTTP responses
  const response$ = request$.map(request => ({
    id: request.id, // Don't forget to forward the request id
    statusCode: 200,
    statusMessage: 'OK',
    headers: {
      'Content-Type': 'text/html'
    },
    body: '<h1>Hello, world!</h1>'
  }));

  // Pass your stream to the HTTPServer sink
  return {
    HTTPServer: response$
  };
}

const drivers = {
  HTTPServer: makeHTTPServerDriver(8080) // The driver will create a HTTP server listening on 0.0.0.0:8080
};

run(main, drivers);

FAQs

Package last updated on 26 Apr 2017

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