Merge pull request #6428 from ffdixon/cleanup-labs
Removed older Labs examples
This commit is contained in:
commit
bd3e1500a8
1
labs/api/meetings-vx/.gitignore
vendored
1
labs/api/meetings-vx/.gitignore
vendored
@ -1 +0,0 @@
|
||||
node_modules
|
@ -1,65 +0,0 @@
|
||||
fs = require 'fs'
|
||||
{print} = require 'util'
|
||||
{spawn, exec} = require 'child_process'
|
||||
glob = require 'glob'
|
||||
|
||||
REPORTER = "min"
|
||||
|
||||
config = {}
|
||||
config.binPath = './node_modules/.bin/'
|
||||
|
||||
# cake test # run all tests
|
||||
# cake -f test/lib/file.coffee test # run the files passed
|
||||
# cake -b test # run all tests and stop at first failure
|
||||
option '-f', '--file [FILE*]', 'input file(s)'
|
||||
option '-b', '--bail', 'bail'
|
||||
task 'test', 'Run the test suite', (options) ->
|
||||
process.env.NODE_ENV = "test"
|
||||
testFiles = [
|
||||
|
||||
]
|
||||
testOpts = [
|
||||
'--require', 'coffee-script/register',
|
||||
'--compilers', 'coffee:coffee-script/register',
|
||||
'--require', 'should',
|
||||
'--colors',
|
||||
'--ignore-leaks',
|
||||
'--timeout', '15000',
|
||||
'--reporter', 'spec'
|
||||
]
|
||||
if options.bail? and options.bail
|
||||
testOpts = testOpts.concat('-b')
|
||||
|
||||
if options.file?
|
||||
if _.isArray(options.file)
|
||||
files = testFiles.concat(options.file)
|
||||
else
|
||||
files = testFiles.concat([options.file])
|
||||
for opt in testOpts.reverse()
|
||||
files.unshift opt
|
||||
run 'mocha', files
|
||||
|
||||
else
|
||||
glob 'test/**/*.coffee', (error, files) ->
|
||||
for opt in testOpts.reverse()
|
||||
files.unshift opt
|
||||
run 'mocha', files
|
||||
|
||||
# Internal methods
|
||||
|
||||
# Spawns an application with `options` and calls `onExit`
|
||||
# when it finishes.
|
||||
run = (bin, options, onExit) ->
|
||||
bin = config.binPath + bin
|
||||
console.log timeNow() + ' - running: ' + bin + ' ' + (if options? then options.join(' ') else "")
|
||||
cmd = spawn bin, options
|
||||
cmd.stdout.on 'data', (data) -> print data.toString()
|
||||
cmd.stderr.on 'data', (data) -> print data.toString()
|
||||
cmd.on 'exit', (code) ->
|
||||
console.log 'done.'
|
||||
onExit?(code, options)
|
||||
|
||||
# Returns a string with the current time to print out.
|
||||
timeNow = ->
|
||||
today = new Date()
|
||||
today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds()
|
@ -1,41 +0,0 @@
|
||||
exploringHapi
|
||||
=============
|
||||
|
||||
This was used as a playground for attempts to validate URL parameters
|
||||
and to calculate and compare checksum
|
||||
|
||||
Keywords: hapi, joi, OAuth, checksum, hmac_sha1
|
||||
|
||||
Instructions:
|
||||
=============
|
||||
from Terminal:
|
||||
$ coffee index.coffee
|
||||
Listening on http://x.x.x.x:PORT
|
||||
|
||||
go to the browser, open an MCONF API-MATE window
|
||||
modify the "server"(id="input-custom-server-url") field to http://x.x.x.x:PORT
|
||||
click on the link for creating a meeting ("create ...")
|
||||
|
||||
In the Terminal window you should see something like:
|
||||
the checksum from url is
|
||||
e8b540ab61a71c46ebc99e7250e2ca6372115d9a and mine is
|
||||
e8b540ab61a71c46ebc99e7250e2ca6372115d9a
|
||||
YAY! They match!
|
||||
|
||||
or
|
||||
|
||||
the checksum from url is
|
||||
e8b540ab61a71c46ebc99e7250e2ca6372115d9a and mine is
|
||||
dkfjhdkjfhlkafhdfklahfkfhfjhkgfeq349492a
|
||||
|
||||
The browser window will display
|
||||
"everything is fine" if the parameter validation was successful
|
||||
or Error if it was not
|
||||
|
||||
|
||||
LOGGING
|
||||
# To use for CLI
|
||||
npm install -g bunyan
|
||||
|
||||
https://github.com/trentm/node-bunyan
|
||||
|
@ -1,17 +0,0 @@
|
||||
Hapi = require("hapi")
|
||||
pack = require './package'
|
||||
routes = require './lib/routes'
|
||||
bunyan = require 'bunyan'
|
||||
|
||||
log = bunyan.createLogger({name: 'myapp'});
|
||||
log.info('hi')
|
||||
log.warn({lang: 'fr'}, 'au revoir')
|
||||
|
||||
server = Hapi.createServer("0.0.0.0", parseInt(process.env.PORT, 10) or 4000)
|
||||
|
||||
server.start(() ->
|
||||
log.info(['start'], pack.name + ' - web interface: ' + server.info.uri);
|
||||
)
|
||||
|
||||
server.route routes.routes
|
||||
|
@ -1,30 +0,0 @@
|
||||
hapi = require 'hapi'
|
||||
Joi = require 'joi'
|
||||
util = require './util'
|
||||
sha1 = require 'js-sha1'
|
||||
|
||||
sharedSecret = '8cd8ef52e8e101574e400365b55e11a6'
|
||||
|
||||
index = (req, resp) ->
|
||||
resp "Hello World!"
|
||||
|
||||
createHandler = (req, resp) ->
|
||||
console.log("CREATE: " + req.originalUrl )
|
||||
checksum = req.query.checksum
|
||||
console.log("checksum = [" + checksum + "]")
|
||||
|
||||
query = util.removeChecksumFromQuery(req.query)
|
||||
|
||||
baseString = util.buildCreateBaseString(query)
|
||||
ourChecksum = util.calculateChecksum("create", baseString, sharedSecret)
|
||||
|
||||
console.log "the checksum from url is \n" + checksum + " and mine is\n" + ourChecksum
|
||||
|
||||
if checksum isnt ourChecksum
|
||||
resp "Fail!"
|
||||
else
|
||||
resp "everything is fine"
|
||||
|
||||
|
||||
exports.index = index
|
||||
exports.create = createHandler
|
@ -1,33 +0,0 @@
|
||||
hapi = require 'hapi'
|
||||
handlers = require './handlers'
|
||||
Joi = require 'joi'
|
||||
|
||||
createValidation =
|
||||
attendeePW: Joi.string().max(20).required()
|
||||
checksum: Joi.string().required()
|
||||
meetingID: Joi.string().min(3).max(30).required()
|
||||
moderatorPW: Joi.string().required()
|
||||
name: Joi.string().regex(/[a-zA-Z0-9]{3,30}/)
|
||||
record: Joi.boolean()
|
||||
voiceBridge: Joi.string()
|
||||
welcome: Joi.string()
|
||||
|
||||
routes = [{
|
||||
method: 'GET',
|
||||
path: '/',
|
||||
config: {
|
||||
handler: handlers.index
|
||||
}
|
||||
}, {
|
||||
method: "GET",
|
||||
path: "/bigbluebutton/api/create",
|
||||
config: {
|
||||
handler: handlers.create,
|
||||
validate: {
|
||||
query: createValidation
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
exports.routes = routes;
|
@ -1,32 +0,0 @@
|
||||
sha1 = require 'js-sha1'
|
||||
|
||||
|
||||
|
||||
removeChecksumFromQuery = (query) ->
|
||||
for own propName of query
|
||||
console.log(propName + "=" + query[propName])
|
||||
delete query['checksum']
|
||||
query
|
||||
|
||||
buildCreateBaseString = (query) ->
|
||||
baseString = ""
|
||||
for own propName of query
|
||||
propVal = query[propName]
|
||||
if (propName == "welcome")
|
||||
propVal = encodeURIComponent(query.welcome).replace(/%20/g, '+').replace(/[!'()]/g, escape).replace(/\*/g, "%2A")
|
||||
baseString += propName + "=" + propVal + "&"
|
||||
console.log(propName + "=" + query[propName])
|
||||
|
||||
console.log("baseString=[" + baseString.slice(0, -1) + "]")
|
||||
|
||||
baseString.slice(0, -1)
|
||||
|
||||
calculateChecksum = (method, baseString, sharedSecret) ->
|
||||
qStr = method + baseString + sharedSecret
|
||||
console.log("[" + qStr + "]")
|
||||
sha1(qStr)
|
||||
|
||||
|
||||
exports.removeChecksumFromQuery = removeChecksumFromQuery
|
||||
exports.buildCreateBaseString = buildCreateBaseString
|
||||
exports.calculateChecksum = calculateChecksum
|
@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "exploringHapi",
|
||||
"version": "0.0.2",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "coffee index.coffee"
|
||||
},
|
||||
"dependencies": {
|
||||
"hapi": "2.6.0",
|
||||
"joi": "2.7.0",
|
||||
"oauth-signature": "1.1.3",
|
||||
"coffee-script": "1.7.1",
|
||||
"js-sha1": "0.1.1",
|
||||
"bunyan": "0.22.2",
|
||||
"glob": "3.2.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coffee-script": "1.7.1",
|
||||
"mocha": "1.18.2",
|
||||
"should": "3.3.1",
|
||||
"glob": "3.2.6",
|
||||
"chai": "1.9.x"
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
|
||||
|
||||
|
@ -1,31 +0,0 @@
|
||||
assert = require("assert")
|
||||
oauth = require("oauth-signature")
|
||||
|
||||
describe "Array", ->
|
||||
|
||||
describe '#indexOf()', ->
|
||||
|
||||
it 'should return -1 when the value is not present', ->
|
||||
assert.equal(-1, [1,2,3].indexOf(5))
|
||||
|
||||
it "should calc checksum", ->
|
||||
httpMethod = 'GET'
|
||||
url = 'http://photos.example.net/photos'
|
||||
parameters = {
|
||||
oauth_consumer_key : 'dpf43f3p2l4k3l03',
|
||||
oauth_token : 'nnch734d00sl2jdk',
|
||||
oauth_nonce : 'kllo9940pd9333jh',
|
||||
oauth_timestamp : '1191242096',
|
||||
oauth_signature_method : 'HMAC-SHA1',
|
||||
oauth_version : '1.0',
|
||||
file : 'vacation.jpg',
|
||||
size : 'original'
|
||||
}
|
||||
consumerSecret = 'kd94hf93k423kf44'
|
||||
tokenSecret = 'pfkkdhi9sl3r4s00'
|
||||
encodedSignature = oauth.generate(httpMethod, url, parameters, consumerSecret, tokenSecret);
|
||||
console.log(encodedSignature)
|
||||
assert.equal(encodedSignature, "tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D")
|
||||
|
||||
|
||||
|
1
labs/api/meetings/.gitignore
vendored
1
labs/api/meetings/.gitignore
vendored
@ -1 +0,0 @@
|
||||
node_modules
|
@ -1,65 +0,0 @@
|
||||
fs = require 'fs'
|
||||
{print} = require 'util'
|
||||
{spawn, exec} = require 'child_process'
|
||||
glob = require 'glob'
|
||||
|
||||
REPORTER = "min"
|
||||
|
||||
config = {}
|
||||
config.binPath = './node_modules/.bin/'
|
||||
|
||||
# cake test # run all tests
|
||||
# cake -f test/lib/file.coffee test # run the files passed
|
||||
# cake -b test # run all tests and stop at first failure
|
||||
option '-f', '--file [FILE*]', 'input file(s)'
|
||||
option '-b', '--bail', 'bail'
|
||||
task 'test', 'Run the test suite', (options) ->
|
||||
process.env.NODE_ENV = "test"
|
||||
testFiles = [
|
||||
|
||||
]
|
||||
testOpts = [
|
||||
'--require', 'coffee-script/register',
|
||||
'--compilers', 'coffee:coffee-script/register',
|
||||
'--require', 'should',
|
||||
'--colors',
|
||||
'--ignore-leaks',
|
||||
'--timeout', '15000',
|
||||
'--reporter', 'spec'
|
||||
]
|
||||
if options.bail? and options.bail
|
||||
testOpts = testOpts.concat('-b')
|
||||
|
||||
if options.file?
|
||||
if _.isArray(options.file)
|
||||
files = testFiles.concat(options.file)
|
||||
else
|
||||
files = testFiles.concat([options.file])
|
||||
for opt in testOpts.reverse()
|
||||
files.unshift opt
|
||||
run 'mocha', files
|
||||
|
||||
else
|
||||
glob 'test/**/*.coffee', (error, files) ->
|
||||
for opt in testOpts.reverse()
|
||||
files.unshift opt
|
||||
run 'mocha', files
|
||||
|
||||
# Internal methods
|
||||
|
||||
# Spawns an application with `options` and calls `onExit`
|
||||
# when it finishes.
|
||||
run = (bin, options, onExit) ->
|
||||
bin = config.binPath + bin
|
||||
console.log timeNow() + ' - running: ' + bin + ' ' + (if options? then options.join(' ') else "")
|
||||
cmd = spawn bin, options
|
||||
cmd.stdout.on 'data', (data) -> print data.toString()
|
||||
cmd.stderr.on 'data', (data) -> print data.toString()
|
||||
cmd.on 'exit', (code) ->
|
||||
console.log 'done.'
|
||||
onExit?(code, options)
|
||||
|
||||
# Returns a string with the current time to print out.
|
||||
timeNow = ->
|
||||
today = new Date()
|
||||
today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds()
|
@ -1,41 +0,0 @@
|
||||
exploringHapi
|
||||
=============
|
||||
|
||||
This was used as a playground for attempts to validate URL parameters
|
||||
and to calculate and compare checksum
|
||||
|
||||
Keywords: hapi, joi, OAuth, checksum, hmac_sha1
|
||||
|
||||
Instructions:
|
||||
=============
|
||||
from Terminal:
|
||||
$ coffee index.coffee
|
||||
Listening on http://x.x.x.x:PORT
|
||||
|
||||
go to the browser, open an MCONF API-MATE window
|
||||
modify the "server"(id="input-custom-server-url") field to http://x.x.x.x:PORT
|
||||
click on the link for creating a meeting ("create ...")
|
||||
|
||||
In the Terminal window you should see something like:
|
||||
the checksum from url is
|
||||
e8b540ab61a71c46ebc99e7250e2ca6372115d9a and mine is
|
||||
e8b540ab61a71c46ebc99e7250e2ca6372115d9a
|
||||
YAY! They match!
|
||||
|
||||
or
|
||||
|
||||
the checksum from url is
|
||||
e8b540ab61a71c46ebc99e7250e2ca6372115d9a and mine is
|
||||
dkfjhdkjfhlkafhdfklahfkfhfjhkgfeq349492a
|
||||
|
||||
The browser window will display
|
||||
"everything is fine" if the parameter validation was successful
|
||||
or Error if it was not
|
||||
|
||||
|
||||
LOGGING
|
||||
# To use for CLI
|
||||
npm install -g bunyan
|
||||
|
||||
https://github.com/trentm/node-bunyan
|
||||
|
@ -1,17 +0,0 @@
|
||||
Hapi = require("hapi")
|
||||
pack = require './package'
|
||||
routes = require './lib/routes'
|
||||
bunyan = require 'bunyan'
|
||||
|
||||
log = bunyan.createLogger({name: 'myapp'});
|
||||
log.info('hi')
|
||||
log.warn({lang: 'fr'}, 'au revoir')
|
||||
|
||||
server = Hapi.createServer("0.0.0.0", parseInt(process.env.PORT, 10) or 4000)
|
||||
|
||||
server.start(() ->
|
||||
log.info(['start'], pack.name + ' - web interface: ' + server.info.uri);
|
||||
)
|
||||
|
||||
server.route routes.routes
|
||||
|
@ -1,30 +0,0 @@
|
||||
hapi = require 'hapi'
|
||||
Joi = require 'joi'
|
||||
util = require './util'
|
||||
sha1 = require 'js-sha1'
|
||||
|
||||
sharedSecret = '8cd8ef52e8e101574e400365b55e11a6'
|
||||
|
||||
index = (req, resp) ->
|
||||
resp "Hello World!"
|
||||
|
||||
createHandler = (req, resp) ->
|
||||
console.log("CREATE: " + req.originalUrl )
|
||||
checksum = req.query.checksum
|
||||
console.log("checksum = [" + checksum + "]")
|
||||
|
||||
query = util.removeChecksumFromQuery(req.query)
|
||||
|
||||
baseString = util.buildCreateBaseString(query)
|
||||
ourChecksum = util.calculateChecksum("create", baseString, sharedSecret)
|
||||
|
||||
console.log "the checksum from url is \n" + checksum + " and mine is\n" + ourChecksum
|
||||
|
||||
if checksum isnt ourChecksum
|
||||
resp "Fail!"
|
||||
else
|
||||
resp "everything is fine"
|
||||
|
||||
|
||||
exports.index = index
|
||||
exports.create = createHandler
|
@ -1,33 +0,0 @@
|
||||
hapi = require 'hapi'
|
||||
handlers = require './handlers'
|
||||
Joi = require 'joi'
|
||||
|
||||
createValidation =
|
||||
attendeePW: Joi.string().max(20).required()
|
||||
checksum: Joi.string().required()
|
||||
meetingID: Joi.string().min(3).max(30).required()
|
||||
moderatorPW: Joi.string().required()
|
||||
name: Joi.string().regex(/[a-zA-Z0-9]{3,30}/)
|
||||
record: Joi.boolean()
|
||||
voiceBridge: Joi.string()
|
||||
welcome: Joi.string()
|
||||
|
||||
routes = [{
|
||||
method: 'GET',
|
||||
path: '/',
|
||||
config: {
|
||||
handler: handlers.index
|
||||
}
|
||||
}, {
|
||||
method: "GET",
|
||||
path: "/bigbluebutton/api/create",
|
||||
config: {
|
||||
handler: handlers.create,
|
||||
validate: {
|
||||
query: createValidation
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
exports.routes = routes;
|
@ -1,32 +0,0 @@
|
||||
sha1 = require 'js-sha1'
|
||||
|
||||
|
||||
|
||||
removeChecksumFromQuery = (query) ->
|
||||
for own propName of query
|
||||
console.log(propName + "=" + query[propName])
|
||||
delete query['checksum']
|
||||
query
|
||||
|
||||
buildCreateBaseString = (query) ->
|
||||
baseString = ""
|
||||
for own propName of query
|
||||
propVal = query[propName]
|
||||
if (propName == "welcome")
|
||||
propVal = encodeURIComponent(query.welcome).replace(/%20/g, '+').replace(/[!'()]/g, escape).replace(/\*/g, "%2A")
|
||||
baseString += propName + "=" + propVal + "&"
|
||||
console.log(propName + "=" + query[propName])
|
||||
|
||||
console.log("baseString=[" + baseString.slice(0, -1) + "]")
|
||||
|
||||
baseString.slice(0, -1)
|
||||
|
||||
calculateChecksum = (method, baseString, sharedSecret) ->
|
||||
qStr = method + baseString + sharedSecret
|
||||
console.log("[" + qStr + "]")
|
||||
sha1(qStr)
|
||||
|
||||
|
||||
exports.removeChecksumFromQuery = removeChecksumFromQuery
|
||||
exports.buildCreateBaseString = buildCreateBaseString
|
||||
exports.calculateChecksum = calculateChecksum
|
@ -1,23 +0,0 @@
|
||||
{
|
||||
"name": "meetingApi",
|
||||
"version": "0.0.2",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "coffee index.coffee"
|
||||
},
|
||||
"dependencies": {
|
||||
"hapi": "2.6.0",
|
||||
"joi": "2.7.0",
|
||||
"coffee-script": "1.7.1",
|
||||
"js-sha1": "0.1.1",
|
||||
"bunyan": "0.22.2",
|
||||
"glob": "3.2.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coffee-script": "1.7.1",
|
||||
"mocha": "1.18.2",
|
||||
"should": "3.3.1",
|
||||
"glob": "3.2.6",
|
||||
"chai": "1.9.x"
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
hapi = require('hapi')
|
||||
assert = require('assert')
|
||||
chai = require('chai')
|
||||
assert = chai.assert
|
||||
routes = require('../lib/routes')
|
||||
|
||||
|
||||
# integration tests for API endpoint
|
||||
|
||||
|
||||
# setup server with firing up - use inject instead
|
||||
server = new hapi.Server()
|
||||
server.route(routes.routes)
|
||||
|
||||
|
||||
# parseurls endpoint test
|
||||
describe 'add endpoint', ->
|
||||
|
||||
it 'add - should add two numbers together', ->
|
||||
server.inject({method: 'PUT', url: '/sum/add/5/5'}, (res) ->
|
||||
assert.deepEqual({'equals': 10}, JSON.parse(res.payload))
|
||||
done()
|
||||
)
|
||||
|
||||
it 'add - should error if a string is passed', (done) ->
|
||||
server.inject({method: 'PUT', url: '/sum/add/100/x'}, (res) ->
|
||||
assert.deepEqual({
|
||||
'statusCode': 400,
|
||||
'error': 'Bad Request',
|
||||
'message': 'the value of b must be a number',
|
||||
'validation': {
|
||||
'source': 'path',
|
||||
'keys': [
|
||||
'b'
|
||||
]
|
||||
}
|
||||
}, JSON.parse(res.payload))
|
||||
done()
|
||||
)
|
@ -1,3 +0,0 @@
|
||||
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
assert = require("assert")
|
||||
|
||||
describe "Array", ->
|
||||
|
||||
describe '#indexOf()', ->
|
||||
|
||||
it 'should return -1 when the value is not present', ->
|
||||
assert.equal(-1, [1,2,3].indexOf(5))
|
||||
|
||||
|
||||
|
2
labs/api/recordings/.gitignore
vendored
2
labs/api/recordings/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
node_modules
|
||||
log/*.log
|
@ -1,65 +0,0 @@
|
||||
fs = require 'fs'
|
||||
{print} = require 'util'
|
||||
{spawn, exec} = require 'child_process'
|
||||
glob = require 'glob'
|
||||
|
||||
REPORTER = "min"
|
||||
|
||||
config = {}
|
||||
config.binPath = './node_modules/.bin/'
|
||||
|
||||
# cake test # run all tests
|
||||
# cake -f test/lib/file.coffee test # run the files passed
|
||||
# cake -b test # run all tests and stop at first failure
|
||||
option '-f', '--file [FILE*]', 'input file(s)'
|
||||
option '-b', '--bail', 'bail'
|
||||
task 'test', 'Run the test suite', (options) ->
|
||||
process.env.NODE_ENV = "test"
|
||||
testFiles = [
|
||||
|
||||
]
|
||||
testOpts = [
|
||||
'--require', 'coffee-script/register',
|
||||
'--compilers', 'coffee:coffee-script/register',
|
||||
'--require', 'should',
|
||||
'--colors',
|
||||
'--ignore-leaks',
|
||||
'--timeout', '15000',
|
||||
'--reporter', 'spec'
|
||||
]
|
||||
if options.bail? and options.bail
|
||||
testOpts = testOpts.concat('-b')
|
||||
|
||||
if options.file?
|
||||
if _.isArray(options.file)
|
||||
files = testFiles.concat(options.file)
|
||||
else
|
||||
files = testFiles.concat([options.file])
|
||||
for opt in testOpts.reverse()
|
||||
files.unshift opt
|
||||
run 'mocha', files
|
||||
|
||||
else
|
||||
glob 'test/**/*.coffee', (error, files) ->
|
||||
for opt in testOpts.reverse()
|
||||
files.unshift opt
|
||||
run 'mocha', files
|
||||
|
||||
# Internal methods
|
||||
|
||||
# Spawns an application with `options` and calls `onExit`
|
||||
# when it finishes.
|
||||
run = (bin, options, onExit) ->
|
||||
bin = config.binPath + bin
|
||||
console.log timeNow() + ' - running: ' + bin + ' ' + (if options? then options.join(' ') else "")
|
||||
cmd = spawn bin, options
|
||||
cmd.stdout.on 'data', (data) -> print data.toString()
|
||||
cmd.stderr.on 'data', (data) -> print data.toString()
|
||||
cmd.on 'exit', (code) ->
|
||||
console.log 'done.'
|
||||
onExit?(code, options)
|
||||
|
||||
# Returns a string with the current time to print out.
|
||||
timeNow = ->
|
||||
today = new Date()
|
||||
today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds()
|
@ -1,43 +0,0 @@
|
||||
recordingsWatcher
|
||||
=============
|
||||
This app is used to watch the file tree for recording files changes
|
||||
in the directories
|
||||
/var/bigbluebutton/published
|
||||
and
|
||||
/var/bigbluebutton/unpublished
|
||||
|
||||
|
||||
For each recording modified, we push into Redis:
|
||||
key = bbb:recordings:<meetingID>
|
||||
value = a set of JSON strings
|
||||
{"format": "<format>", "timestamp": "<timestamp>"}
|
||||
|
||||
|
||||
For example:
|
||||
|
||||
bbb:recordings:fbdbde6fd7b6499723a101c4c962f03843b4879c
|
||||
[{"format": "presentation", "timestamp": "1396623833035"}, {"format": "capture", "timestamp": "1396623833045"}]
|
||||
|
||||
|
||||
Instructions:
|
||||
=============
|
||||
from Terminal:
|
||||
$ coffee index.coffee
|
||||
|
||||
in another Terminal:
|
||||
$ curl localhost:4000/recordings?meetingid=fbdbde6fd7b6499723a101c4c962f03843b48
|
||||
returns an array of stringified json recordings (see above for the structure of the JSON)
|
||||
|
||||
if there are no recordings for the given meetingID, the message
|
||||
"No recordings for meetingid=some_random_string" appears
|
||||
|
||||
|
||||
Running Tests
|
||||
=============
|
||||
while the application is running // $ coffee index.coffee
|
||||
open another console and enter:
|
||||
$ cake test
|
||||
|
||||
or
|
||||
$ ./node_modules/.bin/mocha --require coffee-script/register --compilers coffee:coffee-script/register --require should --colors --ignore-leaks --timeout 15000 --reporter spec test/routetests.coffee
|
||||
(where test/routetests.coffee is the collecion of tests you want to execute)
|
@ -1,13 +0,0 @@
|
||||
# # Global configurations file
|
||||
|
||||
config = {}
|
||||
|
||||
# Logging
|
||||
config.log = {}
|
||||
|
||||
config.log.path = if process.env.NODE_ENV == "production"
|
||||
"/var/log/bigbluebutton/recording-api.log"
|
||||
else
|
||||
"./log/recording-api-dev.log"
|
||||
|
||||
module.exports = config
|
@ -1,17 +0,0 @@
|
||||
hapi = require 'hapi'
|
||||
|
||||
log = require './lib/logger'
|
||||
pack = require './package'
|
||||
recWatcher = require './lib/recording-dir-watcher'
|
||||
routes = require './lib/routes'
|
||||
|
||||
server = hapi.createServer("0.0.0.0",
|
||||
parseInt(process.env.PORT, 10) or 4000)
|
||||
|
||||
server.start(() ->
|
||||
log.info(['start'], pack.name + ' - web interface: ' + server.info.uri)
|
||||
)
|
||||
|
||||
server.route(routes.routes)
|
||||
|
||||
recWatcher.watch()
|
@ -1,38 +0,0 @@
|
||||
util = require './util'
|
||||
recWatcher = require './recording-dir-watcher'
|
||||
|
||||
sharedSecret = '8cd8ef52e8e101574e400365b55e11a6'
|
||||
|
||||
index = (req, resp) ->
|
||||
resp "Hello World!"
|
||||
|
||||
createHandler = (req, resp) ->
|
||||
console.log("CREATE: " + req.originalUrl )
|
||||
checksum = req.query.checksum
|
||||
console.log("checksum = [" + checksum + "]")
|
||||
|
||||
query = util.removeChecksumFromQuery(req.query)
|
||||
|
||||
baseString = util.buildCreateBaseString(query)
|
||||
ourChecksum = util.calculateChecksum("create", baseString, sharedSecret)
|
||||
|
||||
console.log "the checksum from url is \n" + checksum + " and mine is\n" + ourChecksum
|
||||
|
||||
if checksum isnt ourChecksum
|
||||
resp "Fail!"
|
||||
else
|
||||
resp "everything is fine"
|
||||
|
||||
getRecordings = (req, resp) ->
|
||||
requestedMeetingID = req.query.meetingid
|
||||
console.log("recordings for: " + requestedMeetingID)
|
||||
|
||||
recWatcher.getRecordingsArray requestedMeetingID, (array) ->
|
||||
if array?.length > 0
|
||||
resp JSON.stringify(array)
|
||||
else
|
||||
resp "No recordings for meetingid=#{requestedMeetingID}\n"
|
||||
|
||||
exports.index = index
|
||||
exports.create = createHandler
|
||||
exports.recordings = getRecordings
|
@ -1,19 +0,0 @@
|
||||
bunyan = require 'bunyan'
|
||||
|
||||
config = require '../config'
|
||||
|
||||
logger = bunyan.createLogger({
|
||||
name: 'bbbnode'
|
||||
streams: [
|
||||
{
|
||||
level: 'debug'
|
||||
stream: process.stdout
|
||||
},
|
||||
{
|
||||
level: 'info'
|
||||
path: config.log.path
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
module.exports = logger
|
@ -1,57 +0,0 @@
|
||||
##
|
||||
## Watches the recording dirs for new recordings
|
||||
##
|
||||
|
||||
chokidar = require 'chokidar'
|
||||
redis = require 'redis'
|
||||
|
||||
log = require './logger'
|
||||
|
||||
|
||||
client = redis.createClient()
|
||||
|
||||
baseKey = 'bbb:recordings:'
|
||||
|
||||
watch = ->
|
||||
#clear the keys first
|
||||
keys = client.keys(baseKey.concat('*'))
|
||||
client.del(keys)
|
||||
|
||||
#start watching
|
||||
chokidar.watch('/var/bigbluebutton/published', {ignored: /[\/\\]\./}).on 'all', (event, path) ->
|
||||
somethingChanged(event,path)
|
||||
chokidar.watch('/var/bigbluebutton/unpublished', {ignored: /[\/\\]\./}).on 'all', (event, path) ->
|
||||
somethingChanged(event,path)
|
||||
|
||||
|
||||
somethingChanged = (event, path) ->
|
||||
uri = path.split('/')
|
||||
|
||||
if uri[5]? #excludes the parent directories being added
|
||||
pathArray = path.substring(path.lastIndexOf('/')+1).split('-')
|
||||
meetingID = pathArray[0]
|
||||
timestamp = pathArray[1]
|
||||
|
||||
thisKey = baseKey.concat(meetingID)
|
||||
|
||||
json = {
|
||||
"format": uri[4]
|
||||
"timestamp": timestamp
|
||||
}
|
||||
|
||||
log.info(event, path)
|
||||
str = JSON.stringify(json)
|
||||
|
||||
client.sadd(thisKey, str)
|
||||
|
||||
getRecordingsArray = (meetingID, callback) ->
|
||||
thisKey = baseKey.concat(meetingID)
|
||||
|
||||
client.smembers thisKey, (err, members) ->
|
||||
if err
|
||||
console.log "Error: #{err}"
|
||||
else
|
||||
callback members
|
||||
|
||||
exports.watch = watch
|
||||
exports.getRecordingsArray = getRecordingsArray
|
@ -1,44 +0,0 @@
|
||||
Joi = require 'joi'
|
||||
|
||||
handlers = require './handlers'
|
||||
|
||||
createValidation =
|
||||
attendeePW: Joi.string().max(20).required()
|
||||
checksum: Joi.string().required()
|
||||
meetingID: Joi.string().min(3).max(30).required()
|
||||
moderatorPW: Joi.string().required()
|
||||
name: Joi.string().regex(/[a-zA-Z0-9]{3,30}/)
|
||||
record: Joi.boolean()
|
||||
voiceBridge: Joi.string()
|
||||
welcome: Joi.string()
|
||||
|
||||
recordingsValidation =
|
||||
meetingid: Joi.string().min(3).max(45).required()
|
||||
|
||||
routes = [{
|
||||
method: 'GET'
|
||||
path: '/'
|
||||
config: {
|
||||
handler: handlers.index
|
||||
}
|
||||
}, {
|
||||
method: "GET"
|
||||
path: "/bigbluebutton/api/create"
|
||||
config: {
|
||||
handler: handlers.create
|
||||
validate: {
|
||||
query: createValidation
|
||||
}
|
||||
}
|
||||
}, {
|
||||
method: "GET"
|
||||
path: "/recordings"
|
||||
config: {
|
||||
handler: handlers.recordings
|
||||
validate: {
|
||||
query: recordingsValidation
|
||||
}
|
||||
}
|
||||
}]
|
||||
|
||||
exports.routes = routes
|
@ -1,12 +0,0 @@
|
||||
parser1 = require 'xml2json'
|
||||
parser2 = require 'json2xml'
|
||||
|
||||
xml2json = (xmlStr) ->
|
||||
parser1.toJson(xmlStr)
|
||||
|
||||
json2xml = (jsonObj) ->
|
||||
#parser2(jsonObj)
|
||||
parser1.toXml(jsonObj)
|
||||
|
||||
exports.xml2json = xml2json
|
||||
exports.json2xml = json2xml
|
@ -1,29 +0,0 @@
|
||||
{
|
||||
"name": "recordingsWatcher",
|
||||
"version": "0.0.2",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"start": "coffee index.coffee"
|
||||
},
|
||||
"dependencies": {
|
||||
"chokidar": "0.8.2",
|
||||
"redis": "0.10.1",
|
||||
"hiredis": "0.1.16",
|
||||
"hapi": "2.6.0",
|
||||
"joi": "2.7.0",
|
||||
"coffee-script": "1.7.1",
|
||||
"js-sha1": "0.1.1",
|
||||
"bunyan": "0.22.2",
|
||||
"json2xml": "0.1.1",
|
||||
"xml2json": "0.4.0",
|
||||
"easyxml": "0.0.5",
|
||||
"glob": "3.2.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"coffee-script": "1.7.1",
|
||||
"mocha": "1.18.2",
|
||||
"should": "3.3.1",
|
||||
"glob": "3.2.6",
|
||||
"chai": "1.9.x"
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
assert = require('chai').assert
|
||||
hapi = require('hapi')
|
||||
|
||||
routes = require('../lib/routes')
|
||||
|
||||
# integration tests for API endpoint
|
||||
|
||||
|
||||
# setup server with firing up - use inject instead
|
||||
server = new hapi.Server()
|
||||
server.route(routes.routes)
|
||||
|
||||
|
||||
# parseurls endpoint test
|
||||
describe 'checking recordings', ->
|
||||
|
||||
it 'recordings for a given meetingid', ->
|
||||
server.inject({method: 'GET', url: '192.168.0.203:4000/recordings?meetingid=fbdbde6fd7b6499723a101c4c962f03843b4879c'}, (res) ->
|
||||
#console.log "json:" + res.payload
|
||||
array = [
|
||||
{
|
||||
'format': 'presentation'
|
||||
'timestamp':'1396619572523'
|
||||
}, {
|
||||
'format': 'capture'
|
||||
'timestamp':'1396623833044'
|
||||
}, {
|
||||
'format': 'presentation'
|
||||
'timestamp':'1396620788271'
|
||||
}, {
|
||||
'format': 'presentation'
|
||||
'timestamp':'1396622260421'
|
||||
}, {
|
||||
'format': 'capture'
|
||||
'timestamp':'1396623833035'
|
||||
}, {
|
||||
'format': 'capture'
|
||||
'timestamp':'1396623830000'
|
||||
}, {
|
||||
'format': 'capture'
|
||||
'timestamp':'1396619572523'
|
||||
}, {
|
||||
'format': 'capture'
|
||||
'timestamp':'1396622260421'
|
||||
}, {
|
||||
'format': 'capture'
|
||||
'timestamp':'1396620788271'
|
||||
}, {
|
||||
'format': 'presentation'
|
||||
'timestamp':'1396623833035'
|
||||
}, {
|
||||
'format': 'capture'
|
||||
'timestamp':'1396623831111'
|
||||
}
|
||||
]
|
||||
|
||||
parsedOnce = JSON.parse(res.payload)
|
||||
index = 0
|
||||
while index < parsedOnce.length
|
||||
assert.deepEqual(JSON.stringify(array[index]), parsedOnce[index])
|
||||
index++
|
||||
#console.log index
|
||||
)
|
||||
###it 'add - should add two numbers together', ->
|
||||
server.inject({method: 'PUT', url: '/sum/add/5/5'}, (res) ->
|
||||
console.log "json:" +JSON.stringify(res.payload)
|
||||
assert.deepEqual({'equals': 10}, JSON.parse(res.payload))
|
||||
done()
|
||||
)###
|
||||
|
||||
###it 'add - should error if a string is passed', (done) ->
|
||||
server.inject({method: 'PUT', url: '/sum/add/100/1'}, (res) ->
|
||||
console.log "json:" +JSON.stringify(res)
|
||||
assert.deepEqual({
|
||||
'statusCode': 400
|
||||
'error': 'Bad Request'
|
||||
'message': 'the value of b must be a number'
|
||||
'validation': {
|
||||
'source': 'path'
|
||||
'keys': [
|
||||
'b'
|
||||
]
|
||||
}
|
||||
}, JSON.parse(res.payload))
|
||||
done()
|
||||
)###
|
@ -1,3 +0,0 @@
|
||||
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
assert = require("assert")
|
||||
|
||||
describe "Array", ->
|
||||
|
||||
describe '#indexOf()', ->
|
||||
|
||||
it 'should return -1 when the value is not present', ->
|
||||
assert.equal(-1, [1,2,3].indexOf(5))
|
||||
|
||||
|
||||
|
@ -1,58 +0,0 @@
|
||||
assert = require("assert")
|
||||
|
||||
util = require '../lib/util'
|
||||
|
||||
sampleXml = """
|
||||
<recording>
|
||||
<id>6e35e3b2778883f5db637d7a5dba0a427f692e91-1398363221956</id>
|
||||
<state>available</state>
|
||||
<published>true</published>
|
||||
<start_time>1398363223514</start_time>
|
||||
<end_time>1398363348994</end_time>
|
||||
<playback>
|
||||
<format>presentation</format>
|
||||
<link>http://example.com/playback/presentation/playback.html?meetingID=6e35e3b2778883f5db637d7a5dba0a427f692e91-1398363221956</link>
|
||||
<processing_time>5429</processing_time>
|
||||
<duration>101014</duration>
|
||||
<extension>
|
||||
<custom>... Any XML element, to be passed through into playback format element.</custom>
|
||||
</extension>
|
||||
</playback>
|
||||
<meta>
|
||||
<meetingId>English 101</meetingId>
|
||||
<meetingName>English 101</meetingName>
|
||||
<description>Test recording</description>
|
||||
<title>English 101</title>
|
||||
</meta>
|
||||
</recording>
|
||||
"""
|
||||
|
||||
jsonResult = {
|
||||
"recording": {
|
||||
"id": "6e35e3b2778883f5db637d7a5dba0a427f692e91-1398363221956",
|
||||
"state": "available",
|
||||
"published": true,
|
||||
"start_time": 1398363223514,
|
||||
"end_time": 1398363348994,
|
||||
"playback": {
|
||||
"format": "presentation",
|
||||
"link": "http://example.com/playback/presentation/playback.html?meetingID=6e35e3b2778883f5db637d7a5dba0a427f692e91-1398363221956",
|
||||
"processing_time": 5429,
|
||||
"duration": 101014,
|
||||
"extension": {
|
||||
"custom": "... Any XML element, to be passed through into playback format element."
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"meetingId": "English 101",
|
||||
"meetingName": "English 101",
|
||||
"description": "Test recording",
|
||||
"title": "English 101"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe "util", ->
|
||||
describe 'xml2json()', ->
|
||||
it 'should return a json string', ->
|
||||
assert.deepEqual(jsonResult, JSON.parse(util.xml2json(sampleXml)))
|
@ -1,34 +0,0 @@
|
||||
util = require './lib/util'
|
||||
|
||||
sampleXml = """
|
||||
<recording>
|
||||
<id>6e35e3b2778883f5db637d7a5dba0a427f692e91-1398363221956</id>
|
||||
<state>available</state>
|
||||
<published>true</published>
|
||||
<start_time>1398363223514</start_time>
|
||||
<end_time>1398363348994</end_time>
|
||||
<playback>
|
||||
<format>presentation</format>
|
||||
<link>http://example.com/playback/presentation/playback.html?meetingID=6e35e3b2778883f5db637d7a5dba0a427f692e91-1398363221956</link>
|
||||
<processing_time>5429</processing_time>
|
||||
<duration>101014</duration>
|
||||
<extension>
|
||||
<custom>... Any XML element, to be passed through into playback format element.</custom>
|
||||
</extension>
|
||||
</playback>
|
||||
<meta>
|
||||
<meetingId>English 101</meetingId>
|
||||
<meetingName>English 101</meetingName>
|
||||
<description>Test recording</description>
|
||||
<title>English 101</title>
|
||||
</meta>
|
||||
</recording>
|
||||
"""
|
||||
|
||||
jsonObj = util.xml2json( sampleXml )
|
||||
|
||||
console.log(jsonObj)
|
||||
|
||||
jstr = util.json2xml(JSON.parse(jsonObj))
|
||||
|
||||
console.log(jstr)
|
Loading…
Reference in New Issue
Block a user