API Docs for: 0.8.0
Show:

ServerInitializer Class

Creates and initializes the HTTP server

Constructor

ServerInitializer

(
  • [pb]
)

Parameters:

  • [pb] Object optional

    The PB object

Methods

_init

(
  • context
  • cb
)
private

Parameters:

  • context Object
    • log Logger
    • config Object

      The PB config object

    • onRequest Function

      Takes 2 parameters: req, res

    • [onHandOffRequest] Function optional

      Takes 2 parameters: req, res. It is required if starting with SSL enabled

  • cb Function

getServer

(
  • context
)

Parameters:

  • context Object
    • onRequest Function

      Takes 2 parameters: req, res return {HttpServer}

getSslServer

(
  • context
)
HttpsServer

Parameters:

  • context Object
    • config Object

      The PB config object

    • onRequest Object

      Takes 2 parameters: req, res

Returns:

HttpsServer:

getSslServerOptions

(
  • config
)
Object

Parameters:

  • config Object
    • server Object
      • ssl Object
      • ssl.key String
      • ssl.cert String
      • ssl.chain String

Returns:

Object:

init

(
  • context
  • cb
)

Initializes the server. Depending on the configuration will start an HTTP server and/or an HTTPs server.

Parameters:

  • context Object
    • log Logger
    • config Object

      The PB config object

    • onRequest Function

      Takes 2 parameters: req, res

    • [onHandOffRequest] Function optional

      Takes 2 parameters: req, res. It is required if starting with SSL enabled

  • cb Function

initHttp

(
  • context
  • cb
)

Parameters:

  • context Object
    • log Logger
    • config Object

      The PB config object

    • onRequest Function

      Takes 2 parameters: req, res

  • cb Function

initHttps

(
  • context
  • cb
)

Parameters:

  • context Object
    • log Logger
    • config Object

      The PB config object

    • onRequest Function

      Takes 2 parameters: req, res

    • onHandOffRequest Function

      Takes 2 parameters: req, res

  • cb Function

startServer

(
  • server
  • port
  • ip
  • cb
)

Does a simple start on a server object by binding to the specified IP address and port.

Parameters:

  • server HttpServer | HttpsServer
  • port Integer
  • ip String
  • cb Function