IConnectionServer #

Description #

Interface for creating and using server connection. By default, it presented by http and https node.js's module, but it can be any other internal node.js or some other module (for example, from npm).

Name of file with implemented interface class is a connection name from related configuration options (see usage example below).

Also internal ifnode implementations of server connections have equal to node.js modules names: http and https. Default connection name is http.

Definition #

JSDoc syntax #

/**
 * @callback ServerListener
 *
 * @param {IncomingMessage} request
 * @param {ServerResponse}  response
 */

/**
 * @interface IConnectionServer
 * 
 * @param {ServerListener}  listener
 * @param {IFSiteConfig}  config
 */

/**
 * @function IConnectionServer#configure
 * 
 * @param {function}    configurator
 */

/**
 * @function IConnectionServer#listen
 * 
 * @param {function}    [callback]
 */

/**
 * @function IConnectionServer#close
 * 
 * @param {function}    [callback]
 */

TypeScript syntax #

interface ServerListener {
    (request: IncomingMessage, response: ServerResponse)
}

interface IConnectionServer {
    constructor(listener: ServerListener, config: IFSiteConfig),
    configure(configuration: Function),
    listen(callback?: Function),
    close(callback?: Function)
}

Interface methods #

IConnectionServer#constructor( listener, config ) #

Arguments #
Name Type Description
listener ServerListener listener presented by Express instance and set to app.listener
config [IFSiteConfig] (/api/) Config is app.config.site

IConnectionServer#configure( configurator ) #

Arguments #
Name Type Description
configurator function Set configuration for connection server

IConnectionServer#listen( [callback] ) #

Arguments #
Name Type Description
callback function Starts connection server. Callback is optional and invokes after server will be started

IConnectionServer#close( [callback] ) #

Arguments #
Name Type Description
callback function Stops connection server. Callback is optional and invokes after server will be stopped

Examples #

Table of Content