change error handling on spelling

This commit is contained in:
Henry Oswald 2015-10-22 20:15:50 +01:00
parent 084b0d8548
commit 5e19d710ba

View file

@ -2,13 +2,15 @@ request = require 'request'
Settings = require 'settings-sharelatex' Settings = require 'settings-sharelatex'
logger = require 'logger-sharelatex' logger = require 'logger-sharelatex'
TEN_SECONDS = 1000 * 10
module.exports = SpellingController = module.exports = SpellingController =
proxyRequestToSpellingApi: (req, res, next) -> proxyRequestToSpellingApi: (req, res, next) ->
url = req.url.slice("/spelling".length) url = req.url.slice("/spelling".length)
url = "/user/#{req.session.user._id}#{url}" url = "/user/#{req.session.user._id}#{url}"
req.headers["Host"] = Settings.apis.spelling.host req.headers["Host"] = Settings.apis.spelling.host
getReq = request(url: Settings.apis.spelling.url + url, method: req.method, headers: req.headers, json: req.body) request(url: Settings.apis.spelling.url + url, method: req.method, headers: req.headers, json: req.body, timeout:TEN_SECONDS)
getReq.on "error", (error) -> .on "error", (error) ->
logger.error err: error, "Spelling API error" logger.error err: error, "Spelling API error"
res.sendStatus 500 res.sendStatus 500
getReq.pipe(res) .pipe(res)