2014-01-27 12:51:09 -05:00
|
|
|
Settings = require "settings-sharelatex"
|
2013-08-23 09:35:13 -04:00
|
|
|
logger = require "logger-sharelatex"
|
2014-02-26 11:17:15 -05:00
|
|
|
logger.initialize("track-changes")
|
2013-08-23 09:35:13 -04:00
|
|
|
|
2014-05-09 07:44:13 -04:00
|
|
|
Path = require "path"
|
|
|
|
Metrics = require "metrics-sharelatex"
|
|
|
|
Metrics.initialize("track-changes")
|
|
|
|
Metrics.mongodb.monitor(Path.resolve(__dirname + "/node_modules/mongojs/node_modules/mongodb"), logger)
|
|
|
|
|
2014-01-27 13:09:37 -05:00
|
|
|
HttpController = require "./app/js/HttpController"
|
|
|
|
express = require "express"
|
|
|
|
app = express()
|
|
|
|
|
2014-05-09 07:44:13 -04:00
|
|
|
app.use Metrics.http.monitor(logger)
|
2014-02-26 07:11:45 -05:00
|
|
|
|
2014-03-21 11:57:17 -04:00
|
|
|
app.post "/project/:project_id/doc/:doc_id/flush", HttpController.flushDoc
|
2013-08-23 09:35:13 -04:00
|
|
|
|
2014-03-04 10:27:03 -05:00
|
|
|
app.get "/project/:project_id/doc/:doc_id/diff", HttpController.getDiff
|
|
|
|
|
2014-03-20 08:10:04 -04:00
|
|
|
app.get "/project/:project_id/updates", HttpController.getUpdates
|
2014-03-05 10:59:40 -05:00
|
|
|
|
2014-03-21 11:57:17 -04:00
|
|
|
app.post "/project/:project_id/flush", HttpController.flushProject
|
|
|
|
|
2014-03-10 12:58:26 -04:00
|
|
|
app.post "/project/:project_id/doc/:doc_id/version/:version/restore", HttpController.restore
|
|
|
|
|
2014-03-03 08:14:01 -05:00
|
|
|
app.get "/status", (req, res, next) ->
|
|
|
|
res.send "track-changes is alive"
|
|
|
|
|
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-03-03 08:31:10 -05:00
|
|
|
port = Settings.internal?.trackchanges?.port or 3015
|
2014-02-26 11:17:15 -05:00
|
|
|
host = Settings.internal?.trackchanges?.host or "localhost"
|
2014-02-26 06:34:56 -05:00
|
|
|
app.listen port, host, (error) ->
|
2014-01-27 12:51:09 -05:00
|
|
|
if error?
|
2014-02-26 11:17:15 -05:00
|
|
|
logger.error err: error, "could not start track-changes server"
|
2014-02-26 06:34:56 -05:00
|
|
|
else
|
2015-04-30 10:07:03 -04:00
|
|
|
logger.info "trackchanges starting up, listening on #{host}:#{port}"
|
2014-01-27 12:51:09 -05:00
|
|
|
|