From c8ec6451ceb1628c575a60d2f0310e20f7a00eb5 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Tue, 3 Mar 2015 08:10:47 +0000 Subject: [PATCH] removed the reset of restify --- .../app/coffee/SpellingAPIController.coffee | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/services/spelling/app/coffee/SpellingAPIController.coffee b/services/spelling/app/coffee/SpellingAPIController.coffee index 9a7e4fa8d2..d5b4179c90 100644 --- a/services/spelling/app/coffee/SpellingAPIController.coffee +++ b/services/spelling/app/coffee/SpellingAPIController.coffee @@ -1,31 +1,23 @@ SpellingAPIManager = require './SpellingAPIManager' -restify = require 'restify' logger = require 'logger-sharelatex' metrics = require('metrics-sharelatex') module.exports = SpellingAPIController = check: (req, res, next) -> metrics.inc "spelling-check", 0.1 - if req.is("json") - logger.log token: req?.params?.user_id, word_count: req?.body?.words?.length, "running check" - SpellingAPIManager.runRequest req.params.user_id, req.body, (error, result) -> - if err? - logger.err err:err, user_id:req?.params?.user_id, word_count: req?.body?.words?.length, "error processing spelling request" - return res.send(500) - res.send(result) - else - next(new restify.NotAcceptableError("Please provide a JSON request")) + logger.log token: req?.params?.user_id, word_count: req?.body?.words?.length, "running check" + SpellingAPIManager.runRequest req.params.user_id, req.body, (error, result) -> + if err? + logger.err err:err, user_id:req?.params?.user_id, word_count: req?.body?.words?.length, "error processing spelling request" + return res.send(500) + res.send(result) learn: (req, res, next) -> metrics.inc "spelling-learn", 0.1 - if req.is("json") - logger.log token: req?.params?.user_id, word: req?.body?.word, "learning word" - SpellingAPIManager.learnWord req.params.user_id, req.body, (error, result) -> - return next(error) if error? - res.send(200) - next() - else - next(new restify.NotAcceptableError("Please provide a JSON request")) - + logger.log token: req?.params?.user_id, word: req?.body?.word, "learning word" + SpellingAPIManager.learnWord req.params.user_id, req.body, (error, result) -> + return next(error) if error? + res.send(200) + next()