Class: Gwisp

gwisp.Gwisp

Gwisp

Constructor

new Gwisp(config) → {Gwisp}

  • Create a new Gwisp from configuration

  • It use to start http service which help people store and retrieve schedulers

Parameters:
Name Type Description
config module:gwisp.Config

configuration of gwisp

Source:
Returns:
  • The new gwisp object
Type
Gwisp
Example
var app = new Gwisp({
  verbose: true,
  port: 9001,
  dbUrl: 'mongodb://localhost/gwisp',
  clientId: '327834646153-27e424bo1lpofea0lkfs8bvrf7sv5j2e.apps.googleusercontent.com',
  clientSecret: 'y7RCBAr4AT26oACJBJUSJIxv',
  redirectUrl: 'http://localhost:9001/v1/oauth/login',
  scopes: [
    'https://www.googleapis.com/auth/plus.me',
    'profile',
    'email'
  ]
})

Members

_config :module:gwisp.Config

Apllication configuration. It is assign by config parameter

Type:
Source:

_db :module:database.Database

Instance of mongo client. Use to do transaction with mongo server. It is initialize during start phase, not construt phase

Type:
Source:

_logger :module:flatlog.FlatLog

Use to make log message iniform

Type:
Source:

_treant :module:protector.Treant

Instance of treant protector. It will be initialize during gwisp start

Type:
Source:

Methods

_serveHttp() → {Number}

  • create an http server follow configure then listen on specify port
Source:
Returns:
  • 0 on success, 1 on error
Type
Number

reincarnate(assetDir, callback)

  • Drop databse if it is early exists then install an sample data to database
Parameters:
Name Type Description
assetDir module:database.AssetDir

Path to asset directory, contains static data file in json format

callback StdCallback

Function will be call when setup done. In this case, result parameter of callback will not specify

Source:
Example
// see constructor for detail
var app = new Gwisp(config)

app.setup('asset/sample-data', function(err, res) {
  if (err) {
    console.log('setup new database fails', err)
    process.exit(1)
  }

  console.log('setup new database successfully')
})

start(callback)

  • Start service
Parameters:
Name Type Description
callback StdCallback

function will be call after start done

Source:
Example
// see constructor for detail
var app = gwisp(config)

app.start(function(err) {
  // do some thing here
})