overleaf/services/web/app/coffee/Features/Documents/DocumentController.coffee

33 lines
1.2 KiB
CoffeeScript
Raw Normal View History

2014-02-12 05:23:40 -05:00
ProjectEntityHandler = require "../Project/ProjectEntityHandler"
Errors = require "../../errors"
logger = require("logger-sharelatex")
2014-05-08 08:42:30 -04:00
module.exports =
2014-02-12 05:23:40 -05:00
getDocument: (req, res, next = (error) ->) ->
project_id = req.params.Project_id
doc_id = req.params.doc_id
logger.log doc_id:doc_id, project_id:project_id, "receiving get document request from api (docupdater)"
ProjectEntityHandler.getDoc project_id, doc_id, (error, lines, rev) ->
2014-02-12 05:23:40 -05:00
if error?
logger.err err:error, doc_id:doc_id, project_id:project_id, "error finding element for getDocument"
return next(error)
res.type "json"
res.send JSON.stringify {
2014-05-08 08:42:30 -04:00
lines: lines
2014-02-12 05:23:40 -05:00
}
setDocument: (req, res, next = (error) ->) ->
project_id = req.params.Project_id
doc_id = req.params.doc_id
lines = req.body.lines
logger.log doc_id:doc_id, project_id:project_id, "receiving set document request from api (docupdater)"
ProjectEntityHandler.updateDocLines project_id, doc_id, lines, (error) ->
2014-02-12 05:23:40 -05:00
if error?
logger.err err:error, doc_id:doc_id, project_id:project_id, "error finding element for getDocument"
return next(error)
2014-12-11 11:22:00 -05:00
logger.log doc_id:doc_id, project_id:project_id, "finished receiving set document request from api (docupdater)"
2015-07-08 11:56:38 -04:00
res.sendStatus 200
2014-02-12 05:23:40 -05:00