mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #241 from sharelatex/ta-analytics-proxy
Proxy requests to analytics service
This commit is contained in:
commit
bdef7b707d
5 changed files with 65 additions and 7 deletions
|
@ -0,0 +1,17 @@
|
|||
settings = require "settings-sharelatex"
|
||||
Errors = require '../Errors/Errors'
|
||||
httpProxy = require 'express-http-proxy'
|
||||
URL = require 'url'
|
||||
|
||||
module.exports =
|
||||
call: (basePath) ->
|
||||
analyticsUrl = settings?.apis?.analytics?.url
|
||||
if analyticsUrl?
|
||||
httpProxy(analyticsUrl,
|
||||
proxyReqPathResolver: (req) ->
|
||||
requestPath = URL.parse(req.url).path
|
||||
"#{basePath}#{requestPath}"
|
||||
)
|
||||
else
|
||||
(req, res, next) ->
|
||||
next(new Errors.ServiceNotConfiguredError('Analytics service not configured'))
|
|
@ -1,5 +1,10 @@
|
|||
AuthenticationController = require './../Authentication/AuthenticationController'
|
||||
AnalyticsController = require('./AnalyticsController')
|
||||
AnalyticsProxy = require('./AnalyticsProxy')
|
||||
|
||||
module.exports =
|
||||
apply: (webRouter, apiRouter) ->
|
||||
apply: (webRouter, privateApiRouter) ->
|
||||
webRouter.post '/event/:event', AnalyticsController.recordEvent
|
||||
privateApiRouter.use '/analytics/graphs',
|
||||
AuthenticationController.httpAuth,
|
||||
AnalyticsProxy.call('/graphs')
|
||||
|
|
|
@ -149,6 +149,9 @@ module.exports = settings =
|
|||
# url: "http://localhost:3040"
|
||||
notifications:
|
||||
url: "http://localhost:3042"
|
||||
analytics:
|
||||
url: "http://localhost:3050"
|
||||
|
||||
|
||||
templates:
|
||||
user_id: process.env.TEMPLATES_USER_ID or "5395eb7aad1f29a88756c7f2"
|
||||
|
|
44
services/web/npm-shrinkwrap.json
generated
44
services/web/npm-shrinkwrap.json
generated
|
@ -1390,8 +1390,7 @@
|
|||
"es6-promise": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.1.1.tgz",
|
||||
"integrity": "sha1-iBHpCRXZoNujYnTwskLb2nj5ySo=",
|
||||
"dev": true
|
||||
"integrity": "sha1-iBHpCRXZoNujYnTwskLb2nj5ySo="
|
||||
},
|
||||
"escape-html": {
|
||||
"version": "1.0.2",
|
||||
|
@ -1520,6 +1519,26 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"express-http-proxy": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/express-http-proxy/-/express-http-proxy-1.1.0.tgz",
|
||||
"integrity": "sha1-tTOEKt0VtwIdeNJIyAtTV4p7a6A=",
|
||||
"requires": {
|
||||
"debug": "3.1.0",
|
||||
"es6-promise": "4.1.1",
|
||||
"raw-body": "2.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"express-session": {
|
||||
"version": "1.15.5",
|
||||
"resolved": "https://registry.npmjs.org/express-session/-/express-session-1.15.5.tgz",
|
||||
|
@ -3527,7 +3546,7 @@
|
|||
"raven": "1.2.1",
|
||||
"sandboxed-module": "2.0.3",
|
||||
"sinon": "4.1.3",
|
||||
"timekeeper": "2.0.0"
|
||||
"timekeeper": "1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
|
@ -3611,7 +3630,7 @@
|
|||
"integrity": "sha1-h9v8ATg6jdzn2dVJbzYIVkiJ8VY=",
|
||||
"requires": {
|
||||
"jsonfile": "1.1.1",
|
||||
"mkdirp": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"mkdirp": "0.5.1",
|
||||
"ncp": "0.5.1",
|
||||
"rimraf": "2.4.5"
|
||||
},
|
||||
|
@ -3747,6 +3766,14 @@
|
|||
"brace-expansion": "1.1.8"
|
||||
}
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
},
|
||||
"mocha": {
|
||||
"version": "1.20.1",
|
||||
"resolved": "https://registry.npmjs.org/mocha/-/mocha-1.20.1.tgz",
|
||||
|
@ -3793,7 +3820,7 @@
|
|||
"integrity": "sha1-rmzg1vbV4KT32JN5jQPB6pVZtqI=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"mkdirp": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"mkdirp": "0.5.1",
|
||||
"ncp": "2.0.0",
|
||||
"rimraf": "2.4.5"
|
||||
}
|
||||
|
@ -3857,6 +3884,11 @@
|
|||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz",
|
||||
"integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo="
|
||||
},
|
||||
"timekeeper": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/timekeeper/-/timekeeper-1.0.0.tgz",
|
||||
"integrity": "sha1-Lziu4elLEd1m2FgP8aqdzGoroNg="
|
||||
},
|
||||
"type-detect": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.5.tgz",
|
||||
|
@ -6665,7 +6697,7 @@
|
|||
}
|
||||
},
|
||||
"translations-sharelatex": {
|
||||
"version": "git+https://github.com/sharelatex/translations-sharelatex.git#507b6b945bedc604f5db7185ad66386209f95c18",
|
||||
"version": "git+https://github.com/sharelatex/translations-sharelatex.git#6c9d95a6072b4d40621dacbf0f35fefc3469b4b1",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"async": "2.6.0",
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
"csurf": "^1.8.3",
|
||||
"dateformat": "1.0.4-1.2.3",
|
||||
"express": "4.13.0",
|
||||
"express-http-proxy": "^1.1.0",
|
||||
"express-session": "^1.14.2",
|
||||
"fs-extra": "^4.0.2",
|
||||
"heapdump": "^0.3.7",
|
||||
|
|
Loading…
Reference in a new issue