Server

Server

Takes HTTP requests

Example (in the main script):

const server = new Server(somebot, someotherbot);
server.listen(80, 'localhost');

Constructor

new Server(botsopt, optionsopt)

Parameters:
Name Type Attributes Description
bots Array.<function()> <optional>

Bots whose handle method will be called on incoming requests

options object <optional>
Properties
Name Type Attributes Description
log object <optional>

npmlog-like logger; pass null to disable

Source:

Methods

addBot(bot)

Adds bots whose handle functions are called on HTTP requests

Parameters:
Name Type Description
bot Bot
Source:

listen(port, host)

Executes the HTTP Server's listen method

Parameters:
Name Type Description
port number

Port to listen on

host string

Hostname for the server

Source:
See:

request(req, res)

Receives HTTP requests from the API

Parameters:
Name Type Description
req IncomingMessage

Request

res ServerResponse

Response

Source: