0.2.3 • Published 6 years ago

@ramlmn/hh2 v0.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

hh2

A zero-dependency wrapper to create various instances of node http interfaces.

Usage

const options = {
  h2: Boolean
  secure: Boolean,
  ..., // other options for the server
};

const server = hh2(app, options);

The app is a requestListener for node http request.

The h2 options is used to create http2 server and the secure option is to create a secureServer variant of http or http2. By default a http server is created.

Simply put, hh2 creates the appropriate server and returns an instance of net.Server.

https server

const express = require('express');
const hh2 = require('@ramlmn/hh2');
const app = express();

const server = hh2(app, {
  secure: true,           // <- explicit https

  // certs as options
  key: fs.readFileSync('server-key.pem'),
  cert: fs.readFileSync('server-cert.pem'),
});

server.listen( _ => {
  console.log('> Server started');
});

http2 server

const express = require('express');
const hh2 = require('@ramlmn/hh2');
const app = express();

const server = hh2(app, {
  h2: true                // <- explicit http2
  secure: true,

  // http2 in SSL
  key: fs.readFileSync('server-key.pem'),
  cert: fs.readFileSync('server-cert.pem'),
});

server.listen(_ => {
  console.log('> Server started');
});

License

MIT

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago