Show:
Defined in: lib/application.js:16
Module: application

Creates an instance of Application

   var util = require('util');
   var ferrum = require('ferrum');

   var options = {
     routes: {
       '^/$': MainHandler
     }
   };

   function MainHandler () {
     ferrum.RequestHandler.call(this);

     this.get = function () {
       this.write("Hello world!");
     };
   }
   util.inherits(MainHandler, ferrum.RequestHandler);

   ferrum.Application(options).run();

Constructor

Application

(
  • options
)
Object chainable

Parameters:

  • options Object

    Application options

    • [host] String optional

      A domain name or IP address of the server to handle the requests. 'localhost' by default.

    • [port] String optional

      Port of the server to be listened. '8888' by default.

    • [routes] Object optional

      Dictionary of application routes. Where 'keys' are route paths and 'values' are their handlers. By default it includes only route for static files.

    • [debugMode] Boolean optional

      Defines logger level and other staff needed for debugging. 'false' by default.

    • [logger] Object optional

      ...

    • [loggerTransports] Array optional

      Array of extra logger transports. You can add other transports which supported by winston. List of existing transport you can find here - https://github.com/flatiron/winston#working-with-transports. By default ferrum includes File and Console transports.

Returns:

Object: Application instance.

Item Index

Methods

Methods

run

()

Runs application

stop

()

Stops application