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 |
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:
_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:
_logger :module:flatlog.FlatLog
Use to make log message iniform
Type:
_treant :module:protector.Treant
Instance of treant protector. It will be initialize during gwisp start
Type:
Methods
_serveHttp() → {Number}
- create an http server follow configure then listen on specify port
Returns:
- 0 on success, 1 on error
- Type
- Number
setup(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 |
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 |
Example
// see constructor for detail
var app = gwisp(config)
app.start(function(err) {
// do some thing here
})