mirror of
https://github.com/Hopiu/webapi-eca.git
synced 2026-03-16 22:10:31 +00:00
Doc update and portability improvements
This commit is contained in:
parent
ce36359539
commit
42d16c30d7
9 changed files with 16 additions and 12 deletions
|
|
@ -27,7 +27,7 @@ Download and install dependencies:
|
||||||
cd webapi-eca
|
cd webapi-eca
|
||||||
npm install
|
npm install
|
||||||
|
|
||||||
Get your [redis](http://redis.io/) instance up and running (and find the port for the config file below) or create your own `js/persistence.js`.
|
Get your [redis](http://redis.io/) instance up and running ( and find the port for the config file below ) or create your own `js/persistence.js`.
|
||||||
|
|
||||||
Edit the configuration file:
|
Edit the configuration file:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -225,6 +225,8 @@ storeModule = ( user, oBody, modType, dbMod, callback ) =>
|
||||||
# dbMod.publish oBody.id
|
# dbMod.publish oBody.id
|
||||||
callback answ
|
callback answ
|
||||||
|
|
||||||
|
# Store a rule and inform everybody about it
|
||||||
|
# ------------------------------------------
|
||||||
storeRule = ( user, oBody, callback ) =>
|
storeRule = ( user, oBody, callback ) =>
|
||||||
# This is how a rule is stored in the database
|
# This is how a rule is stored in the database
|
||||||
rule =
|
rule =
|
||||||
|
|
@ -244,22 +246,22 @@ storeRule = ( user, oBody, callback ) =>
|
||||||
db.linkRule rule.id, user.username
|
db.linkRule rule.id, user.username
|
||||||
# activate the rule
|
# activate the rule
|
||||||
db.activateRule rule.id, user.username
|
db.activateRule rule.id, user.username
|
||||||
# if event module parameters were send, store them
|
# if event module parameters were sent, store them
|
||||||
if oBody.eventparams
|
if oBody.eventparams
|
||||||
epModId = rule.eventname.split( ' -> ' )[ 0 ]
|
epModId = rule.eventname.split( ' -> ' )[ 0 ]
|
||||||
db.eventPollers.storeUserParams epModId, user.username, JSON.stringify oBody.eventparams
|
db.eventPollers.storeUserParams epModId, user.username, JSON.stringify oBody.eventparams
|
||||||
oFuncArgs = oBody.eventfunctions
|
oFuncArgs = oBody.eventfunctions
|
||||||
# if event function arguments were send, store them
|
# if event function arguments were sent, store them
|
||||||
for id, args of oFuncArgs
|
for id, args of oFuncArgs
|
||||||
arr = id.split ' -> '
|
arr = id.split ' -> '
|
||||||
db.eventPollers.storeUserArguments user.username, rule.id, arr[ 0 ], arr[ 1 ], JSON.stringify args
|
db.eventPollers.storeUserArguments user.username, rule.id, arr[ 0 ], arr[ 1 ], JSON.stringify args
|
||||||
|
|
||||||
# if action module params were send, store them
|
# if action module params were sent, store them
|
||||||
oParams = oBody.actionparams
|
oParams = oBody.actionparams
|
||||||
for id, params of oParams
|
for id, params of oParams
|
||||||
db.actionInvokers.storeUserParams id, user.username, JSON.stringify params
|
db.actionInvokers.storeUserParams id, user.username, JSON.stringify params
|
||||||
oFuncArgs = oBody.actionfunctions
|
oFuncArgs = oBody.actionfunctions
|
||||||
# if action function arguments were send, store them
|
# if action function arguments were sent, store them
|
||||||
for id, args of oFuncArgs
|
for id, args of oFuncArgs
|
||||||
arr = id.split ' -> '
|
arr = id.split ' -> '
|
||||||
db.actionInvokers.storeUserArguments user.username, rule.id, arr[ 0 ], arr[ 1 ], JSON.stringify args
|
db.actionInvokers.storeUserArguments user.username, rule.id, arr[ 0 ], arr[ 1 ], JSON.stringify args
|
||||||
|
|
@ -450,6 +452,7 @@ commandFunctions =
|
||||||
|
|
||||||
|
|
||||||
# WEBHOOKS
|
# WEBHOOKS
|
||||||
|
# --------
|
||||||
create_webhook: ( user, oBody, callback ) ->
|
create_webhook: ( user, oBody, callback ) ->
|
||||||
answ = hasRequiredParams [ 'hookname' ], oBody
|
answ = hasRequiredParams [ 'hookname' ], oBody
|
||||||
if answ.code isnt 200
|
if answ.code isnt 200
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ isRunning = true
|
||||||
# Register disconnect action. Since no standalone mode is intended
|
# Register disconnect action. Since no standalone mode is intended
|
||||||
# the event poller will shut down
|
# the event poller will shut down
|
||||||
process.on 'disconnect', () ->
|
process.on 'disconnect', () ->
|
||||||
log.info 'EP | Shutting down Event Poller'
|
log.warn 'EP | Shutting down Event Poller'
|
||||||
isRunning = false
|
isRunning = false
|
||||||
# very important so the process doesnt linger on when the paren process is killed
|
# very important so the process doesnt linger on when the paren process is killed
|
||||||
process.exit()
|
process.exit()
|
||||||
|
|
|
||||||
|
|
@ -157,8 +157,6 @@ init = =>
|
||||||
@log.info 'RS | Initialzing DB'
|
@log.info 'RS | Initialzing DB'
|
||||||
db args
|
db args
|
||||||
# > We only proceed with the initialization if the DB is ready
|
# > We only proceed with the initialization if the DB is ready
|
||||||
#TODO eventually we shouldn't let each module load its own persistence
|
|
||||||
#module, but hand this one through them via the args...
|
|
||||||
db.isConnected ( err ) =>
|
db.isConnected ( err ) =>
|
||||||
db.selectDatabase parseInt( args[ 'db-select' ] ) || 0
|
db.selectDatabase parseInt( args[ 'db-select' ] ) || 0
|
||||||
if err
|
if err
|
||||||
|
|
@ -192,6 +190,7 @@ init = =>
|
||||||
# - The keygen phrase, this has to be handled differently in the future!
|
# - The keygen phrase, this has to be handled differently in the future!
|
||||||
args[ 'keygen' ]
|
args[ 'keygen' ]
|
||||||
]
|
]
|
||||||
|
# Initialize the event poller with the required CLI arguments
|
||||||
poller = cp.fork path.resolve( __dirname, nameEP ), cliArgs
|
poller = cp.fork path.resolve( __dirname, nameEP ), cliArgs
|
||||||
|
|
||||||
# after the engine and the event poller have been initialized we can
|
# after the engine and the event poller have been initialized we can
|
||||||
|
|
@ -203,7 +202,7 @@ init = =>
|
||||||
cm.addRuleListener ( evt ) -> poller.send evt
|
cm.addRuleListener ( evt ) -> poller.send evt
|
||||||
|
|
||||||
@log.info 'RS | Initialzing http listener'
|
@log.info 'RS | Initialzing http listener'
|
||||||
# The request handler passes certain requests to the module manager
|
# The request handler passes certain requests to the components manager
|
||||||
args[ 'request-service' ] = cm.processRequest
|
args[ 'request-service' ] = cm.processRequest
|
||||||
# We give the HTTP listener the ability to shutdown the whole system
|
# We give the HTTP listener the ability to shutdown the whole system
|
||||||
args[ 'shutdown-function' ] = shutDown
|
args[ 'shutdown-function' ] = shutDown
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ ProBinder ACTION INVOKER
|
||||||
|
|
||||||
Global variables
|
Global variables
|
||||||
This module requires user-specific parameters:
|
This module requires user-specific parameters:
|
||||||
|
|
||||||
- username
|
- username
|
||||||
- password
|
- password
|
||||||
###
|
###
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ OpenWeather EVENT POLLER
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
This module requires user-specific parameters:
|
This module requires user-specific parameters:
|
||||||
|
|
||||||
- appid
|
- appid
|
||||||
###
|
###
|
||||||
urlService = 'http://api.openweathermap.org/data/2.5/weather'
|
urlService = 'http://api.openweathermap.org/data/2.5/weather'
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env nodejs
|
||||||
/*
|
/*
|
||||||
* # groc Documentation
|
* # groc Documentation
|
||||||
* Create the documentation to be displayed through the webserver.
|
* Create the documentation to be displayed through the webserver.
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
node $DIR/js/webapi-eca | $DIR/node_modules/bunyan/bin/bunyan
|
nodejs $DIR/js/webapi-eca | $DIR/node_modules/bunyan/bin/bunyan
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env nodejs
|
||||||
process.chdir( __dirname );
|
process.chdir( __dirname );
|
||||||
var fs = require( 'fs' ),
|
var fs = require( 'fs' ),
|
||||||
path = require( 'path' ),
|
path = require( 'path' ),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue