2014-01-27 17:51:09 +00:00
|
|
|
Settings = require "settings-sharelatex"
|
2013-08-23 13:35:13 +00:00
|
|
|
logger = require "logger-sharelatex"
|
2014-02-26 16:17:15 +00:00
|
|
|
logger.initialize("track-changes")
|
2013-08-23 13:35:13 +00:00
|
|
|
|
2014-03-04 13:02:48 +00:00
|
|
|
require("./app/js/MongoManager").ensureIndices()
|
|
|
|
|
2014-01-27 18:09:37 +00:00
|
|
|
HttpController = require "./app/js/HttpController"
|
|
|
|
express = require "express"
|
|
|
|
app = express()
|
|
|
|
|
2014-02-26 12:11:45 +00:00
|
|
|
app.use express.logger()
|
|
|
|
|
2014-03-21 15:57:17 +00:00
|
|
|
app.post "/project/:project_id/doc/:doc_id/flush", HttpController.flushDoc
|
2013-08-23 13:35:13 +00:00
|
|
|
|
2014-03-04 15:27:03 +00:00
|
|
|
app.get "/project/:project_id/doc/:doc_id/diff", HttpController.getDiff
|
|
|
|
|
2014-03-20 12:10:04 +00:00
|
|
|
app.get "/project/:project_id/updates", HttpController.getUpdates
|
2014-03-05 15:59:40 +00:00
|
|
|
|
2014-03-21 15:57:17 +00:00
|
|
|
app.post "/project/:project_id/flush", HttpController.flushProject
|
|
|
|
|
2014-03-10 16:58:26 +00:00
|
|
|
app.post "/project/:project_id/doc/:doc_id/version/:version/restore", HttpController.restore
|
|
|
|
|
2014-03-03 13:14:01 +00:00
|
|
|
app.get "/status", (req, res, next) ->
|
|
|
|
res.send "track-changes is alive"
|
|
|
|
|
2013-08-23 13:35:13 +00:00
|
|
|
app.use (error, req, res, next) ->
|
|
|
|
logger.error err: error, "an internal error occured"
|
2014-02-26 12:11:45 +00:00
|
|
|
res.send 500
|
2013-08-23 13:35:13 +00:00
|
|
|
|
2014-03-03 13:31:10 +00:00
|
|
|
port = Settings.internal?.trackchanges?.port or 3015
|
2014-02-26 16:17:15 +00:00
|
|
|
host = Settings.internal?.trackchanges?.host or "localhost"
|
2014-02-26 11:34:56 +00:00
|
|
|
app.listen port, host, (error) ->
|
2014-01-27 17:51:09 +00:00
|
|
|
if error?
|
2014-02-26 16:17:15 +00:00
|
|
|
logger.error err: error, "could not start track-changes server"
|
2014-02-26 11:34:56 +00:00
|
|
|
else
|
2014-02-26 16:17:15 +00:00
|
|
|
logger.log "track changes api listening on http://#{host}:#{port}"
|
2014-01-27 17:51:09 +00:00
|
|
|
|