2013-08-23 09:35:13 -04:00
|
|
|
express = require "express"
|
|
|
|
app = express()
|
|
|
|
|
|
|
|
ConversoinManager = require "./app/js/ConversionManager"
|
|
|
|
logger = require "logger-sharelatex"
|
|
|
|
logger.initialize("history")
|
|
|
|
|
2013-09-03 12:17:27 -04:00
|
|
|
app.post express.bodyParser(), "/doc/:doc_id/flush", (req, res, next) ->
|
2013-08-23 09:35:13 -04:00
|
|
|
project_id = req.params.project_id
|
2013-09-03 12:17:27 -04:00
|
|
|
docOps = req.body.docOps
|
2013-08-23 09:35:13 -04:00
|
|
|
logger.log doc_id: doc_id, "compressing doc history"
|
2013-09-03 12:17:27 -04:00
|
|
|
ConversionManager.convertAndSaveRawOps doc_id, docOps, (error) ->
|
2013-08-23 09:35:13 -04:00
|
|
|
return next(error) if error?
|
|
|
|
res.send 204 # No content
|
|
|
|
|
|
|
|
app.use (error, req, res, next) ->
|
|
|
|
logger.error err: error, "an internal error occured"
|
|
|
|
req.send 500
|
|
|
|
|
|
|
|
app.listen(3014)
|