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UAAU,EAAe,WAAY,EAAe,QACjE,GACJ,CAGA,SAAS,qBAAqB,EAAS,GACnC,IAAI,EAAS,kCACb,EAAS,UAAU,IAAK,CACpB,eAAgB,aAChB,iBAAkB,KAEtB,EAAS,MAAM,GACf,EAAS,KACb,CAEA,IAAI,IAAI,KAAK,SAAS,EAAK,GACvB,EAAI,SAAS,mBACjB,IAGA,IAAI,IAAI,YAAY,SAAS,EAAS,GAClC,EAAQ,QAAQ,KAAO,aACvB,eAAe,EAAS,EAC5B,IACA,QAAQ,IAAI,iBAAkB,aAAc,IAAK,aAAa,KAC9D,QAAQ,IAAI,qBAAsB,MAElC,IAAI,OAAO,KAAM","file":"/npm/saiku-ui@3.6.0/server.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/saiku-ui@3.6.0/server.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\n *   Copyright 2012 OSBI Ltd\n *\n *   Licensed under the Apache License, Version 2.0 (the \"License\");\n *   you may not use this file except in compliance with the License.\n *   You may obtain a copy of the License at\n *\n *       http://www.apache.org/licenses/LICENSE-2.0\n *\n *   Unless required by applicable law or agreed to in writing, software\n *   distributed under the License is distributed on an \"AS IS\" BASIS,\n *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *   See the License for the specific language governing permissions and\n *   limitations under the License.\n */\n\n/**\n * Node.js proxy for Saiku\n * Use this proxy to develop for the UI without having to install the server.\n * Requests will be proxied to demo.analytical-labs.com,\n * or a Saiku server installation of your choice.\n *\n * To play with the chaos monkey, set the CHAOS_MONKEY environment variable\n * to anything (Preferably a nice name for your chaos monkey).\n *\n * To start the server, run `node server.js [port] [backend_host] [backend_port]`\n */\n\n// newer versions of node.js use the lower-case argv\nvar argv = process.ARGV || process.argv;\n\nvar http = require('http');\nvar express = require('express');\nvar path = require('path');\nvar compression = require('compression')\nvar app = express();\nvar port = process.env.C9_PORT || parseInt(argv[2], 10) || 8080;\nvar backend_host = argv[3] || 'dev.analytical-labs.com';\nvar backend_port = argv[4] || 80;\nvar backend_path_prefix = argv[5] || '';\nvar auth = argv[6] || null;\n\n// Load static server\nvar twoHours = 1000 * 60 * 60 * 2;\napp.use(express['static'](__dirname));\n\n// compress all responses\napp.use(compression());\n\nvar standard_prefix = \"/saiku/rest/saiku/\";\n\n// Proxy request\nfunction get_from_proxy(request, response) {\n\n    // if a path prefix is set, remove the existing one\n    if (backend_path_prefix !== '') {\n      if (request.url.indexOf(standard_prefix) === 0) {\n        request.url = backend_path_prefix + request.url.substr(standard_prefix.length);\n      }\n    }\n\n    if (auth) {\n        request.headers['authorization']     = 'Basic ' + new Buffer(auth).toString('base64');\n        request.headers['www-authorization'] = 'Basic ' + new Buffer(auth).toString('base64');\n        delete request.headers['cookie'];\n    }\n\n    var options = {\n        hostname : backend_host,\n        port     : backend_port,\n        path     : request.url,\n        method   : request.method,\n        headers  : request.headers\n    };\n\n    console.log(options.method, options.path);\n\n    var proxy_request = http.request(options);\n    request.addListener('data', function(chunk) {\n        proxy_request.write(chunk, 'binary');\n    });\n    request.addListener('end', function() {\n        proxy_request.end();\n    });\n\n    proxy_request.addListener('error', function (error) {\n        console.log(\"ERROR:\",error);\n    });\n    proxy_request.addListener('response', function (proxy_response) {\n        proxy_response.addListener('data', function(chunk) {\n            response.write(chunk, 'binary');\n        });\n\n        proxy_response.addListener('end', function() {\n            response.end();\n        });\n        response.writeHead(proxy_response.statusCode, proxy_response.headers);\n    });\n}\n\n// Unleash the chaos monkey!\nfunction unleash_chaos_monkey(request, response) {\n    var monkey = \"The chaos monkey strikes again!\";\n    response.writeHead(500, {\n        \"Content-Type\": \"text/plain\",\n        \"Content-Length\": monkey.length\n    });\n    response.write(monkey);\n    response.end();\n}\n\napp.get('/', function(req, res) {\n    res.redirect('/dist/html/index');\n});\n\n// Handle incoming requests\napp.all(\"/saiku/*\", function(request, response) {\n    request.headers.host = backend_host;\n    get_from_proxy(request, response);\n});\nconsole.log(\"Connected to '\", backend_host, \":\", backend_port,\"'\");\nconsole.log(\"Proxy listening on\", port);\n\napp.listen(port, '0.0.0.0');\n"]}