@whook/http-server
TypeScript icon, indicating that this package has built-in type declarations

16.0.0 • Public • Published

@whook/http-server

The Whook base HTTP server

GitHub license

The Whook's httpServer service is responsible for instanciating the NodeJS HTTP Server and handling its start/shutdown.

It can be easily replaced by any other HTTP server (an HTTPS one for instance if you cannot use a gateway or a proxy to handle HTTPS connections).

The server takes in charge graceful shutdown by awaiting connections to be closed before shutting down which can take a long time (basically if a browser is still maintaining an open socket with it). You can short circuit this behavior, basically for development, by setting the DESTROY_SOCKETS=1 environment variable.

API

Functions

initHTTPServer(services)Promise.<HTTPServer>

Initialize an HTTP server

Typedefs

HTTPServer

initHTTPServer(services) ⇒ Promise.<HTTPServer>

Initialize an HTTP server

Kind: global function
Returns: Promise.<HTTPServer> - A promise of an object with a NodeJS HTTP server in its service property.

Param Type Default Description
services Object The services the server depends on
[services.ENV] Object The process environment variables
services.ENV.DESTROY_SOCKETS String Whether the server sockets whould be destroyed or if the server should wait while sockets are kept alive
[services.HTTP_SERVER_OPTIONS] Object See https://nodejs.org/docs/latest/api/http.html#class-httpserver
services.HOST String The server host
services.PORT Number The server port
services.httpRouter function The function to run with the req/res tuple
[services.log] function noop A logging function

HTTPServer

Kind: global typedef

Authors

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 16.0.0
    87
    • latest

Version History

Package Sidebar

Install

npm i @whook/http-server

Weekly Downloads

103

Version

16.0.0

License

MIT

Unpacked Size

36.9 kB

Total Files

12

Last publish

Collaborators

  • nfroidure