Stats

 Latest version : 0.15.0

 Last updated on 2015-07-23T20:35:50.136Z

 Keywords : 39f, 39-framework, socket.io, framework, WebSocket, MongoDB

 Downloads :

  • 193 in Last Month

 Links :

 Examples

¯\_(ツ)_/¯
No examples found for this package

 Readme

39f-meta

39-framework meta-module designed to develop WebSocket web-application, designed to work with MongoDB.

Motivation

tl;dr?: To provide complex framework, constructed with 39f-* modules, and provide addition functionality.

Usage

Module exports next object:

  • loadApp(...): application initialization method, creates 39f-socket.io application instance, described below;
  • auth(...): 39f-socket.io-auth module initializer, described below;
  • database: object with fields 'init', 'ObjectID' and 'DBRef', where 'ObjectID' and 'DBRef' are imported from 'mongodb' module and 'init' is a method, which accepts array mongodb configuration objects, object structure is described below;
  • logger: winston instance with pre-configured Console and File loggers, if you need details see index.js script;
  • initLogger: initialized additional Mail and MongoDB loggers if corresponding settings are provided, accepts object with two fields: 'mail' and 'mongo', every field should contain valid configuration object for winston-mail and winston-mongodb loggers except logging level configuration and subject (for mail logger), they will be overwritten anyway;
  • callbacks: 39f-callbacks module;
  • errors: errs module with predefined InternalError type.

loadApp(...) method

/**
 * @param {number} port
 * @param {string} host
 * @param {number} instances
 * @param {boolean=true} opt_cluster Resets instances to 1 if false. Will use no
 * cluster module. Maybe useful in case you use external process watcher.
 * @param {Object=null} opt_https_options If present will use https instead of
 * http
 * @param {function(?Error, !Object)} onLoad
 */

It creates cluster with instances of nodes, running 39f-socket.io application instances, which are passed to onLoad method as second argument.

Passed application object is node http-server, with associated io-instance stored in app.io.

If NODE_ENV was set to 'debug', it will run in single process mode without cluster.

Auth module

Auth module is an auth instance constructor itself, it has next signature:

/**
 * @param {number} redisPort
 * @param {number} redisHost
 * @param {Object} redisOptions
 * @param {Object=} opt_options
 * @param {number=} opt_options.idleTimeout
 * @param {string=} opt_options.prefix
 * @return {Object}
 */

It constructs 39f-socket.io-auth instance with 39f-socket.io-auth-sm-redis sessions manager according to provided data.

Database module

Database configuration object structure (note that you should pass array of such objects even if you need only one connection):

{
  name: string, // connection name
  settings: { // connection settings
    connString: string, // mongodb connection string
    poolSize: number, // connection pool size
    ssl: boolean, // use SSL or not
  }
}

Installation

$ npm install 39f-meta

Author: Yurij Mikhalevich

 Comments