3.2.1 • Published 2 years ago

@distributed-systems/http2-server v3.2.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

HTTP2-Server

This server is http2 only. It does not provide upgrades from HTTP 1.1. If you need to provide HTTP 1.1 in conjunction with HTTP 2 you may use Envoy Proxy for translating between the different HTTP Versions. See the examples/envoy directory for a simple example involving envoy.

Compatible with node.js 10+, with the --experimental-modules flag set.

ESM

import HTTP2Server from 'es-modules/distributed-systems/http2-server/1.0.0+/index.mjs';

NPM

import HTTP2Server from '@distributed-systems/http2-server';

Function Reference

HTTP2Server class

The HTTP2Server class provides all functionality to start a HTTP" server. It emits request events which will pass HTTP2Request class instances to its listeners.

Example of a non secure server

Be aware that no browser is sending non secure requests to a HTTP2 Server, since it's quite insecure.

import HTTP2Server from 'es-modules/distributed-systems/http2-server/1.0.0+/index.mjs';

const server = new HTTP2Server({
    port: 8000,
    secure: false,
});


// prepare the server
await server.load();


// intercept request on the GET /status route
const router = server.getRouter();

router.get('/status', (request) => {
    request.response().status(200).send(`I'm very well!`);
});


// start listening. you may also define a port here
await server.listen(8010);

new HTTP2Server (options)

The constructor takes all options required to start the server. The options are an object containing the configuration parameters.

  • key: private key for the server
  • certificate: certificate for the server
  • port = 443: port to listen on
  • router = new Router(): router that handles incoming requests. Defaults to the included Router class
  • secure: if set to false, the server starts without requiring clients to use TLS

HTTP2Server.registerMiddleware (middleware)

Register a middleware that is executed on each request.

3.2.1

2 years ago

3.2.0

2 years ago

3.0.16

2 years ago

3.0.17

2 years ago

3.0.14

2 years ago

3.0.15

2 years ago

3.0.21

2 years ago

3.0.22

2 years ago

3.0.20

2 years ago

3.0.18

2 years ago

3.0.19

2 years ago

3.1.0

2 years ago

3.0.12

2 years ago

3.0.4

2 years ago

3.0.13

2 years ago

3.0.3

2 years ago

3.0.10

2 years ago

3.0.2

2 years ago

3.0.11

2 years ago

3.0.1

2 years ago

3.0.8

2 years ago

3.0.7

2 years ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.0

2 years ago

2.0.11

2 years ago

2.0.10

2 years ago

3.0.9

2 years ago

2.0.9

2 years ago

2.0.8

3 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

5 years ago

1.9.1

5 years ago

1.9.0

5 years ago

1.8.0

5 years ago

1.7.2

5 years ago

1.6.3

5 years ago

1.7.1

5 years ago

1.7.0

5 years ago

1.6.5

5 years ago

1.6.4

5 years ago

1.6.2

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.4

6 years ago

1.5.3

6 years ago

1.5.2

6 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago