-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathstartServer.js
2 lines (2 loc) · 20.8 KB
/
startServer.js
1
2
/*! For license information please see startServer.js.LICENSE.txt */
!function(Q,U){if("object"==typeof exports&&"object"==typeof module)module.exports=U(require("cors"),require("express"));else if("function"==typeof define&&define.amd)define(["cors","express"],U);else{var B="object"==typeof exports?U(require("cors"),require("express")):U(Q.cors,Q.express);for(var F in B)("object"==typeof exports?exports:Q)[F]=B[F]}}(global,((__WEBPACK_EXTERNAL_MODULE__1761__,__WEBPACK_EXTERNAL_MODULE__2806__)=>(()=>{var __webpack_modules__={7147:Q=>{"use strict";Q.exports=require("fs")},1761:Q=>{"use strict";Q.exports=__WEBPACK_EXTERNAL_MODULE__1761__},2806:Q=>{"use strict";Q.exports=__WEBPACK_EXTERNAL_MODULE__2806__},2517:(module,__unused_webpack_exports,__webpack_require__)=>{"use strict";eval("\n\nvar fs = __webpack_require__(7147);\nfunction exists(fileUrl, callback) {\n fs.stat(fileUrl, function (error, stat) {\n if (error) {\n callback(false);\n } else {\n callback(true, stat.size);\n }\n });\n}\nvar _promiseCounter = 0;\nvar _promisesObj = {};\nfunction _generateRequestId() {\n var ts = new Date().getTime();\n var requestId;\n _promiseCounter++;\n requestId = _promiseCounter + '-' + ts;\n return requestId;\n}\nfunction processCmd(cmd, args) {\n var requestId = _generateRequestId();\n var promise = new Promise(function (resolve, reject) {\n _promisesObj[requestId] = {\n resolve: resolve,\n reject: reject\n };\n });\n var request = {};\n request.requestId = requestId;\n request.cmd = cmd;\n request.args = args;\n process.send(request);\n return promise;\n}\nfunction processMessage(data) {\n var requestId = data.requestId;\n var error = data.error;\n var result = data.result;\n var promiseObj = _promisesObj[requestId + ''];\n function resolve(result) {\n promiseObj.resolve(result);\n }\n if (promiseObj) {\n if (data.status === 'OK') {\n resolve(result);\n } else {\n promiseObj.reject(error);\n }\n delete _promisesObj[requestId];\n }\n}\n\n/**\n *\n * @private\n * @returns {void}\n */\nfunction _attachEvents() {\n process.on('message', processMessage);\n}\n\n/**\n* ContentRoute\n* @param {object} app - express server instance\n* @constructor\n*/\n\nfunction ContentRoute(app, routeName) {\n var manifestInfo = {};\n _attachEvents();\n\n /*------------------------------------------------------------------------------------------*/\n\n // ROUTER MANAGEMENT\n\n /*------------------------------------------------------------------------------------------*/\n\n /**\n * Handles get movies/manifestId\n */\n app.get('/' + routeName + '/:id/*', function (req, res) {\n var manifestId = req.params['id'];\n\n // send back file data function\n var sendFile = function sendFile(file) {\n var options = {\n dotfiles: 'deny'\n };\n res.sendFile(file, options, function (err) {\n if (err && err.status) {\n // error to open file => remove saved info (maybe moved)\n delete manifestInfo[manifestId];\n res.status(err.status).end();\n }\n });\n };\n var seekIfNeeded = function seekIfNeeded(folder) {\n var file = folder + '/' + manifestId + '/' + req.params[0];\n exists(file, function (exists) {\n if (exists) {\n // fragment exists on disk, let's check if it is not being downloaded\n processCmd('is_downloading', {\n manifest: manifestId,\n file: file\n }).then(function () {\n sendFile(file);\n })[\"catch\"](function () {\n return res.status(404).end();\n });\n } else {\n // fragment doesn't on disk, ask to download it\n processCmd('perform_seek', {\n manifest: manifestId,\n file: file\n }).then(function () {\n sendFile(file);\n })[\"catch\"](function () {\n return res.status(404).end();\n });\n }\n });\n };\n var getFile = function getFile(info) {\n if (info && info.status === 'FINISHED') {\n // if file has status finished, no need to check if fragment is being downloaded\n var file = info.folder + '/' + manifestId + '/' + req.params[0];\n exists(file, function (exists) {\n if (exists) {\n // fragment exists => send data\n sendFile(file);\n } else {\n // fragment doesn't exists => 404 and remove cached data\n delete manifestInfo[manifestId];\n return res.status(404).end();\n }\n });\n } else {\n // file is not finished, let's perform seek if needed\n seekIfNeeded(info.folder);\n }\n };\n\n // check if info have been already saved for the manifest\n if (manifestInfo[manifestId]) {\n getFile(manifestInfo[manifestId]);\n } else {\n // no info for manifest id, asks main process to get manifest info\n processCmd('get_info', {\n manifest: manifestId\n }).then(function (result) {\n manifestInfo[manifestId] = result;\n getFile(manifestInfo[manifestId]);\n })[\"catch\"](function () {\n delete manifestInfo[manifestId];\n return res.status(404).send('Cannot find manifest');\n });\n }\n });\n}\nmodule.exports = ContentRoute;//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMjUxNy5qcyIsIm1hcHBpbmdzIjoiQUFBYTs7QUFFYixJQUFNQSxFQUFFLEdBQUdDLG1CQUFPLENBQUMsSUFBSSxDQUFDO0FBRXhCLFNBQVNDLE1BQU1BLENBQUVDLE9BQU8sRUFBRUMsUUFBUSxFQUFFO0VBQ2xDSixFQUFFLENBQUNLLElBQUksQ0FBQ0YsT0FBTyxFQUFFLFVBQVVHLEtBQUssRUFBRUQsSUFBSSxFQUFFO0lBQ3RDLElBQUlDLEtBQUssRUFBRTtNQUNURixRQUFRLENBQUMsS0FBSyxDQUFDO0lBQ2pCLENBQUMsTUFBTTtNQUNMQSxRQUFRLENBQUMsSUFBSSxFQUFFQyxJQUFJLENBQUNFLElBQUksQ0FBQztJQUMzQjtFQUNGLENBQUMsQ0FBQztBQUNKO0FBRUEsSUFBSUMsZUFBZSxHQUFHLENBQUM7QUFDdkIsSUFBSUMsWUFBWSxHQUFHLENBQUMsQ0FBQztBQUVyQixTQUFTQyxrQkFBa0JBLENBQUEsRUFBSTtFQUM3QixJQUFJQyxFQUFFLEdBQUcsSUFBSUMsSUFBSSxDQUFDLENBQUMsQ0FBQ0MsT0FBTyxDQUFDLENBQUM7RUFDN0IsSUFBSUMsU0FBUztFQUNiTixlQUFlLEVBQUU7RUFDakJNLFNBQVMsR0FBR04sZUFBZSxHQUFHLEdBQUcsR0FBR0csRUFBRTtFQUN0QyxPQUFPRyxTQUFTO0FBQ2xCO0FBRUEsU0FBU0MsVUFBVUEsQ0FBRUMsR0FBRyxFQUFFQyxJQUFJLEVBQUU7RUFDOUIsSUFBTUgsU0FBUyxHQUFHSixrQkFBa0IsQ0FBQyxDQUFDO0VBQ3RDLElBQU1RLE9BQU8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IGRvZXNuJ3Qgb24gZGlzaywgYXNrIHRvIGRvd25sb2FkIGl0XG4gICAgICAgICAgcHJvY2Vzc0NtZCgncGVyZm9ybV9zZWVrJywge21hbmlmZXN0OiBtYW5pZmVzdElkLCBmaWxlOiBmaWxlfSlcbiAgICAgICAgICAgIC50aGVuKCgpID0+IHtcbiAgICAgICAgICAgIHNlbmRGaWxlKGZpbGUpXG4gICAgICAgICAgfSlcbiAgICAgICAgICAgIC5jYXRjaChmdW5jdGlvbiAoKSB7XG4gICAgICAgICAgICByZXR1cm4gcmVzLnN0YXR1cyg0MDQpLmVuZCgpO1xuICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICB9KVxuICAgIH1cblxuICAgIGxldCBnZXRGaWxlID0gZnVuY3Rpb24gKGluZm8pIHtcbiAgICAgIGlmIChpbmZvICYmIGluZm8uc3RhdHVzID09PSAnRklOSVNIRUQnKSB7XG4gICAgICAgIC8vIGlmIGZpbGUgaGFzIHN0YXR1cyBmaW5pc2hlZCwgbm8gbmVlZCB0byBjaGVjayBpZiBmcmFnbWVudCBpcyBiZWluZyBkb3dubG9hZGVkXG4gICAgICAgIGxldCBmaWxlID0gaW5mby5mb2xkZXIgKyAnLycgKyBtYW5pZmVzdElkICsgJy8nICsgcmVxLnBhcmFtc1swXTtcbiAgICAgICAgZXhpc3RzKGZpbGUsIChleGlzdHMpID0+IHtcbiAgICAgICAgICBpZiAoZXhpc3RzKSB7XG4gICAgICAgICAgICAvLyBmcmFnbWVudCBleGlzdHMgPT4gc2VuZCBkYXRhXG4gICAgICAgICAgICBzZW5kRmlsZShmaWxlKVxuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAvLyBmcmFnbWVudCBkb2Vzbid0IGV4aXN0cyA9PiA0MDQgYW5kIHJlbW92ZSBjYWNoZWQgZGF0YVxuICAgICAgICAgICAgZGVsZXRlICBtYW5pZmVzdEluZm9bbWFuaWZlc3RJZF07XG4gICAgICAgICAgICByZXR1cm4gcmVzL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leGlzdHMiLCJmaWxlVXJsIiwiY2FsbGJhY2siLCJzdGF0IiwiZXJyb3IiLCJzaXplIiwiX3Byb21pc2VDb3VudGVyIiwiX3Byb21pc2VzT2JqIiwiX2dlbmVyYXRlUmVxdWVzdElkIiwidHMiLCJEYXRlIiwiZ2V0VGltZSIsInJlcXVlc3RJZCIsInByb2Nlc3NDbWQiLCJjbWQiLCJhcmdzIiwicHJvbWlzZSIsIlByb21pc2UiLCJyZXNvbHZlIiwicmVqZWN0IiwicmVxdWVzdCIsInByb2Nlc3MiLCJzZW5kIiwicHJvY2Vzc01lc3NhZ2UiLCJkYXRhIiwicmVzdWx0IiwicHJvbWlzZU9iaiIsInN0YXR1cyIsIl9hdHRhY2hFdmVudHMiLCJvbiIsIkNvbnRlbnRSb3V0ZSIsImFwcCIsInJvdXRlTmFtZSIsIm1hbmlmZXN0SW5mbyIsImdldCIsInJlcSIsInJlcyIsIm1hbmlmZXN0SWQiLCJwYXJhbXMiLCJzZW5kRmlsZSIsImZpbGUiLCJvcHRpb25zIiwiZG90ZmlsZXMiLCJlcnIiLCJlbmQiLCJzZWVrSWZOZWVkZWQiLCJmb2xkZXIiLCJtYW5pZmVzdCIsInRoZW4iLCJnZXRGaWxlIiwiaW5mbyIsIm1vZHVsZSIsImV4cG9ydHMiXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///2517\n")},2942:(__unused_webpack_module,__unused_webpack_exports,__webpack_require__)=>{eval("var express = __webpack_require__(2806);\nvar cors = __webpack_require__(1761);\n(function () {\n process.send({\n cmd: 'log',\n log: 'Starting HTTP server'\n });\n var server = express();\n server.use(cors());\n\n // listen for messages\n process.on('message', function (data) {\n // handles init message\n if (data.cmd === 'init') {\n // add content route\n __webpack_require__(2517)(server, data.routeName);\n // start http server\n server.listen(data.port, function () {\n // http server is listening => send back listening port\n process.send({\n cmd: 'listening_port',\n port: data.port\n });\n });\n }\n });\n})();//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=ut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icG9ydCJdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///2942\n")}},__webpack_module_cache__={};function __webpack_require__(Q){var U=__webpack_module_cache__[Q];if(void 0!==U)return U.exports;var B=__webpack_module_cache__[Q]={exports:{}};return __webpack_modules__[Q](B,B.exports,__webpack_require__),B.exports}var __webpack_exports__=__webpack_require__(2942);return __webpack_exports__})()));