overleaf/services/track-changes/app.coffee

25 lines
680 B
CoffeeScript
Raw Normal View History

Settings = require "settings-sharelatex"
2013-08-23 09:35:13 -04:00
logger = require "logger-sharelatex"
logger.initialize("history")
HttpController = require "./app/js/HttpController"
express = require "express"
app = express()
2014-02-26 07:11:45 -05:00
app.use express.logger()
2014-02-26 06:34:56 -05:00
app.post "/doc/:doc_id/flush", HttpController.flushUpdatesWithLock
2013-08-23 09:35:13 -04:00
app.use (error, req, res, next) ->
logger.error err: error, "an internal error occured"
2014-02-26 07:11:45 -05:00
res.send 500
2013-08-23 09:35:13 -04:00
2014-02-26 06:34:56 -05:00
port = Settings.internal?.history?.port or 3014
host = Settings.internal?.history?.host or "localhost"
app.listen port, host, (error) ->
if error?
logger.error err: error, "could not start history server"
2014-02-26 06:34:56 -05:00
else
logger.log "history api listening on http://#{host}:#{port}"