2014-04-28 11:45:59 -04:00
|
|
|
Settings = require('settings-sharelatex')
|
|
|
|
logger = require('logger-sharelatex')
|
|
|
|
logger.initialize("docstore")
|
|
|
|
|
|
|
|
express = require('express')
|
|
|
|
HttpController = require "./app/js/HttpController"
|
2014-04-28 12:43:19 -04:00
|
|
|
Errors = require "./app/js/Errors"
|
2014-04-28 11:45:59 -04:00
|
|
|
|
|
|
|
app = express()
|
|
|
|
|
|
|
|
app.get '/project/:project_id/doc/:doc_id', HttpController.getDoc
|
|
|
|
|
|
|
|
app.get '/status', (req, res)->
|
|
|
|
res.send('docstore is alive')
|
|
|
|
|
|
|
|
app.use (error, req, res, next) ->
|
|
|
|
logger.error err: error, "request errored"
|
2014-04-28 12:43:19 -04:00
|
|
|
if error instanceof Errors.NotFoundError
|
|
|
|
res.send 404
|
|
|
|
else
|
|
|
|
res.send(500, "Oops, something went wrong")
|
2014-04-28 11:45:59 -04:00
|
|
|
|
|
|
|
port = Settings.internal.docstore.port
|
|
|
|
host = Settings.internal.docstore.host
|
|
|
|
app.listen port, host, (error) ->
|
|
|
|
throw error if error?
|
|
|
|
logger.log("docstore listening on #{host}:#{port}")
|