From a4eda59189878d069245b640f76dc48c8c464623 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Wed, 2 Jan 2019 14:46:44 +0000 Subject: [PATCH] add getDic --- services/spelling/app.coffee | 1 + services/spelling/app/coffee/SpellingAPIController.coffee | 6 ++++++ services/spelling/app/coffee/SpellingAPIManager.coffee | 3 +++ 3 files changed, 10 insertions(+) diff --git a/services/spelling/app.coffee b/services/spelling/app.coffee index 9fac369c2c..f82f76ea68 100644 --- a/services/spelling/app.coffee +++ b/services/spelling/app.coffee @@ -20,6 +20,7 @@ server.use bodyParser.json(limit: "2mb") server.use metrics.http.monitor(logger) server.del "/user/:user_id", SpellingAPIController.deleteDic +server.get "/user/:user_id", SpellingAPIController.getDic server.post "/user/:user_id/check", SpellingAPIController.check server.post "/user/:user_id/learn", SpellingAPIController.learn server.get "/status", (req, res)-> diff --git a/services/spelling/app/coffee/SpellingAPIController.coffee b/services/spelling/app/coffee/SpellingAPIController.coffee index 8f04123a7d..d00c8ebb5e 100644 --- a/services/spelling/app/coffee/SpellingAPIController.coffee +++ b/services/spelling/app/coffee/SpellingAPIController.coffee @@ -27,3 +27,9 @@ module.exports = SpellingAPIController = return next(error) if error? res.sendStatus(204) + + getDic: (req, res, next)-> + logger.info token: req?.params?.user_id, "getting user dictionary" + SpellingAPIManager.getDic req.params.user_id, (error, words)-> + return next(error) if error? + res.send(words) \ No newline at end of file diff --git a/services/spelling/app/coffee/SpellingAPIManager.coffee b/services/spelling/app/coffee/SpellingAPIManager.coffee index b8b097c893..9eb5cfc4aa 100644 --- a/services/spelling/app/coffee/SpellingAPIManager.coffee +++ b/services/spelling/app/coffee/SpellingAPIManager.coffee @@ -49,3 +49,6 @@ module.exports = SpellingAPIManager = deleteDic: (token, callback)-> LearnedWordsManager.deleteUsersLearnedWords token, callback + getDic: (token, callback)-> + LearnedWordsManager.getLearnedWords token, callback +