overleaf/services/spelling/app.coffee

33 lines
1.1 KiB
CoffeeScript
Raw Normal View History

2014-08-15 07:13:35 -04:00
Settings = require 'settings-sharelatex'
logger = require 'logger-sharelatex'
logger.initialize("spelling-sharelatex")
SpellingAPIController = require './app/js/SpellingAPIController'
restify = require 'restify'
Path = require("path")
metrics = require("metrics-sharelatex")
2015-03-02 09:59:30 -05:00
metrics.initialize("spelling")
2014-08-15 07:13:35 -04:00
metrics.mongodb.monitor(Path.resolve(__dirname + "/node_modules/mongojs/node_modules/mongodb"), logger)
2015-03-01 07:45:14 -05:00
HealthCheckController = require("./app/js/HealthCheckController")
2014-08-15 07:13:35 -04:00
server = restify.createServer
name: "spelling-sharelatex",
version: "0.0.1"
server.use restify.bodyParser(mapParams: false)
server.use metrics.http.monitor(logger)
server.post "/user/:user_id/check", SpellingAPIController.check
server.post "/user/:user_id/learn", SpellingAPIController.learn
server.get "/status", (req, res)->
res.send(status:'spelling api is up')
2015-03-01 07:45:14 -05:00
server.get "/health_check", HealthCheckController.healthCheck
2014-08-15 07:25:54 -04:00
host = Settings.internal?.spelling?.host || "localhost"
port = Settings.internal?.spelling?.port || 3005
server.listen port, host, (error) ->
throw error if error?
logger.log "spelling-sharelatex listening at #{host}:#{port}"