diff --git a/labs/api/meetings-vx/.gitignore b/labs/api/meetings-vx/.gitignore deleted file mode 100644 index 3c3629e647f5ddf82548912e337bea9826b434af..0000000000000000000000000000000000000000 --- a/labs/api/meetings-vx/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/labs/api/meetings-vx/Cakefile b/labs/api/meetings-vx/Cakefile deleted file mode 100755 index f71c67698ab0068f2da4789affbcb80f19950e1d..0000000000000000000000000000000000000000 --- a/labs/api/meetings-vx/Cakefile +++ /dev/null @@ -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() \ No newline at end of file diff --git a/labs/api/meetings-vx/README.md b/labs/api/meetings-vx/README.md deleted file mode 100644 index 17d99532d724a542d2d87348aa400e4dc16d709f..0000000000000000000000000000000000000000 --- a/labs/api/meetings-vx/README.md +++ /dev/null @@ -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 - diff --git a/labs/api/meetings-vx/index.coffee b/labs/api/meetings-vx/index.coffee deleted file mode 100755 index 151b12f6bac00fb4ff238640e3f8ea0727621f94..0000000000000000000000000000000000000000 --- a/labs/api/meetings-vx/index.coffee +++ /dev/null @@ -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 - diff --git a/labs/api/meetings-vx/lib/handlers.coffee b/labs/api/meetings-vx/lib/handlers.coffee deleted file mode 100755 index 9e2fb0fdd392cf4ac899cee2f4b95e1d52157267..0000000000000000000000000000000000000000 --- a/labs/api/meetings-vx/lib/handlers.coffee +++ /dev/null @@ -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 diff --git a/labs/api/meetings-vx/lib/routes.coffee b/labs/api/meetings-vx/lib/routes.coffee deleted file mode 100755 index d2cc3cb0114a6d49bb9289f7e9a17aa142cc8782..0000000000000000000000000000000000000000 --- a/labs/api/meetings-vx/lib/routes.coffee +++ /dev/null @@ -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; \ No newline at end of file diff --git a/labs/api/meetings-vx/lib/util.coffee b/labs/api/meetings-vx/lib/util.coffee deleted file mode 100755 index 05101168f785ac53d287531a1ec927453d0e099b..0000000000000000000000000000000000000000 --- a/labs/api/meetings-vx/lib/util.coffee +++ /dev/null @@ -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 \ No newline at end of file diff --git a/labs/api/meetings-vx/package.json b/labs/api/meetings-vx/package.json deleted file mode 100644 index 3350d153695c57ca58fcc392637c834970f8164a..0000000000000000000000000000000000000000 --- a/labs/api/meetings-vx/package.json +++ /dev/null @@ -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" - } -} diff --git a/labs/api/meetings-vx/test/test_helper.coffee b/labs/api/meetings-vx/test/test_helper.coffee deleted file mode 100755 index 6636bc60e10fab9b98464c4cbde0829f7ccb505e..0000000000000000000000000000000000000000 --- a/labs/api/meetings-vx/test/test_helper.coffee +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/labs/api/meetings-vx/test/testc.coffee b/labs/api/meetings-vx/test/testc.coffee deleted file mode 100644 index 49cae906b6c949f7f5c91dd486e5551138ff8781..0000000000000000000000000000000000000000 --- a/labs/api/meetings-vx/test/testc.coffee +++ /dev/null @@ -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") - - - diff --git a/labs/api/meetings/.gitignore b/labs/api/meetings/.gitignore deleted file mode 100644 index 3c3629e647f5ddf82548912e337bea9826b434af..0000000000000000000000000000000000000000 --- a/labs/api/meetings/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/labs/api/meetings/Cakefile b/labs/api/meetings/Cakefile deleted file mode 100755 index f71c67698ab0068f2da4789affbcb80f19950e1d..0000000000000000000000000000000000000000 --- a/labs/api/meetings/Cakefile +++ /dev/null @@ -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() \ No newline at end of file diff --git a/labs/api/meetings/README.md b/labs/api/meetings/README.md deleted file mode 100644 index 17d99532d724a542d2d87348aa400e4dc16d709f..0000000000000000000000000000000000000000 --- a/labs/api/meetings/README.md +++ /dev/null @@ -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 - diff --git a/labs/api/meetings/index.coffee b/labs/api/meetings/index.coffee deleted file mode 100755 index 151b12f6bac00fb4ff238640e3f8ea0727621f94..0000000000000000000000000000000000000000 --- a/labs/api/meetings/index.coffee +++ /dev/null @@ -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 - diff --git a/labs/api/meetings/lib/handlers.coffee b/labs/api/meetings/lib/handlers.coffee deleted file mode 100755 index 9e2fb0fdd392cf4ac899cee2f4b95e1d52157267..0000000000000000000000000000000000000000 --- a/labs/api/meetings/lib/handlers.coffee +++ /dev/null @@ -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 diff --git a/labs/api/meetings/lib/routes.coffee b/labs/api/meetings/lib/routes.coffee deleted file mode 100755 index d2cc3cb0114a6d49bb9289f7e9a17aa142cc8782..0000000000000000000000000000000000000000 --- a/labs/api/meetings/lib/routes.coffee +++ /dev/null @@ -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; \ No newline at end of file diff --git a/labs/api/meetings/lib/util.coffee b/labs/api/meetings/lib/util.coffee deleted file mode 100755 index 05101168f785ac53d287531a1ec927453d0e099b..0000000000000000000000000000000000000000 --- a/labs/api/meetings/lib/util.coffee +++ /dev/null @@ -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 \ No newline at end of file diff --git a/labs/api/meetings/package.json b/labs/api/meetings/package.json deleted file mode 100644 index d98ce6d3d9067df8f039a06d699f7645b5e004bd..0000000000000000000000000000000000000000 --- a/labs/api/meetings/package.json +++ /dev/null @@ -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" - } -} diff --git a/labs/api/meetings/test/routetests.coffee b/labs/api/meetings/test/routetests.coffee deleted file mode 100644 index 7e099d6c27b671a2c3a73cccc72b2851d4572569..0000000000000000000000000000000000000000 --- a/labs/api/meetings/test/routetests.coffee +++ /dev/null @@ -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() - ) \ No newline at end of file diff --git a/labs/api/meetings/test/test_helper.coffee b/labs/api/meetings/test/test_helper.coffee deleted file mode 100755 index 6636bc60e10fab9b98464c4cbde0829f7ccb505e..0000000000000000000000000000000000000000 --- a/labs/api/meetings/test/test_helper.coffee +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/labs/api/meetings/test/testc.coffee b/labs/api/meetings/test/testc.coffee deleted file mode 100755 index dcb98bc2dfd2515bb99868c8cfe86423500aefbf..0000000000000000000000000000000000000000 --- a/labs/api/meetings/test/testc.coffee +++ /dev/null @@ -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)) - - - diff --git a/labs/api/recordings/.gitignore b/labs/api/recordings/.gitignore deleted file mode 100644 index 3db93c472c5aeda4d1029cabb51f5061193100c8..0000000000000000000000000000000000000000 --- a/labs/api/recordings/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -log/*.log diff --git a/labs/api/recordings/Cakefile b/labs/api/recordings/Cakefile deleted file mode 100755 index f71c67698ab0068f2da4789affbcb80f19950e1d..0000000000000000000000000000000000000000 --- a/labs/api/recordings/Cakefile +++ /dev/null @@ -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() \ No newline at end of file diff --git a/labs/api/recordings/README.md b/labs/api/recordings/README.md deleted file mode 100644 index 8c2d7b726912da78867178b9d9f54db737053343..0000000000000000000000000000000000000000 --- a/labs/api/recordings/README.md +++ /dev/null @@ -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) \ No newline at end of file diff --git a/labs/api/recordings/config.coffee b/labs/api/recordings/config.coffee deleted file mode 100755 index 14b2435fd08f821d3dd14603f940c93d7266a65e..0000000000000000000000000000000000000000 --- a/labs/api/recordings/config.coffee +++ /dev/null @@ -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 \ No newline at end of file diff --git a/labs/api/recordings/index.coffee b/labs/api/recordings/index.coffee deleted file mode 100755 index 5c25ab2b31c381a69e16876133fb17aae085425d..0000000000000000000000000000000000000000 --- a/labs/api/recordings/index.coffee +++ /dev/null @@ -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() diff --git a/labs/api/recordings/lib/handlers.coffee b/labs/api/recordings/lib/handlers.coffee deleted file mode 100755 index 3320d66df2cf2792f4ab69882a0761a47fadea66..0000000000000000000000000000000000000000 --- a/labs/api/recordings/lib/handlers.coffee +++ /dev/null @@ -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 diff --git a/labs/api/recordings/lib/logger.coffee b/labs/api/recordings/lib/logger.coffee deleted file mode 100755 index 94569cbddeb10e9ff16bed2cfb88e32ca5ecba44..0000000000000000000000000000000000000000 --- a/labs/api/recordings/lib/logger.coffee +++ /dev/null @@ -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 diff --git a/labs/api/recordings/lib/recording-dir-watcher.coffee b/labs/api/recordings/lib/recording-dir-watcher.coffee deleted file mode 100755 index 30640f53012e81d274cb1873554c30272cefc622..0000000000000000000000000000000000000000 --- a/labs/api/recordings/lib/recording-dir-watcher.coffee +++ /dev/null @@ -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 \ No newline at end of file diff --git a/labs/api/recordings/lib/routes.coffee b/labs/api/recordings/lib/routes.coffee deleted file mode 100755 index d24cf7118977aa2210112e399823e668e45ccece..0000000000000000000000000000000000000000 --- a/labs/api/recordings/lib/routes.coffee +++ /dev/null @@ -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 \ No newline at end of file diff --git a/labs/api/recordings/lib/util.coffee b/labs/api/recordings/lib/util.coffee deleted file mode 100644 index 13de702b329240b5e65816677b77a8afcae97292..0000000000000000000000000000000000000000 --- a/labs/api/recordings/lib/util.coffee +++ /dev/null @@ -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 diff --git a/labs/api/recordings/log/.gitkeep b/labs/api/recordings/log/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/labs/api/recordings/package.json b/labs/api/recordings/package.json deleted file mode 100644 index 64b90255007128dec5a42400a9604397bff01f61..0000000000000000000000000000000000000000 --- a/labs/api/recordings/package.json +++ /dev/null @@ -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" - } -} diff --git a/labs/api/recordings/test/routetests.coffee b/labs/api/recordings/test/routetests.coffee deleted file mode 100644 index d8d9187e85e58b549d536c07931886fe2fb41f87..0000000000000000000000000000000000000000 --- a/labs/api/recordings/test/routetests.coffee +++ /dev/null @@ -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() - )### \ No newline at end of file diff --git a/labs/api/recordings/test/test_helper.coffee b/labs/api/recordings/test/test_helper.coffee deleted file mode 100755 index 6636bc60e10fab9b98464c4cbde0829f7ccb505e..0000000000000000000000000000000000000000 --- a/labs/api/recordings/test/test_helper.coffee +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/labs/api/recordings/test/testc.coffee b/labs/api/recordings/test/testc.coffee deleted file mode 100755 index dcb98bc2dfd2515bb99868c8cfe86423500aefbf..0000000000000000000000000000000000000000 --- a/labs/api/recordings/test/testc.coffee +++ /dev/null @@ -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)) - - - diff --git a/labs/api/recordings/test/utiltests.coffee b/labs/api/recordings/test/utiltests.coffee deleted file mode 100644 index 16f811fc36df55d93d30e87de83a99fc7509a18a..0000000000000000000000000000000000000000 --- a/labs/api/recordings/test/utiltests.coffee +++ /dev/null @@ -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))) diff --git a/labs/api/recordings/testjson2xml.coffee b/labs/api/recordings/testjson2xml.coffee deleted file mode 100644 index 5d77beb87843d98c2fdcac90f84c6ccd0c989d5c..0000000000000000000000000000000000000000 --- a/labs/api/recordings/testjson2xml.coffee +++ /dev/null @@ -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) \ No newline at end of file