mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #513 from sharelatex/bg-split-web-and-web-api
split web and web api
This commit is contained in:
commit
dbbc4966d8
2 changed files with 23 additions and 10 deletions
|
@ -161,16 +161,24 @@ app.get "/heapdump", (req, res)->
|
||||||
logger.info ("creating HTTP server").yellow
|
logger.info ("creating HTTP server").yellow
|
||||||
server = require('http').createServer(app)
|
server = require('http').createServer(app)
|
||||||
|
|
||||||
# process api routes first, if nothing matched fall though and use
|
# provide settings for separate web and api processes
|
||||||
# web middlewear + routes
|
# if enableApiRouter and enableWebRouter are not defined they default
|
||||||
app.use(apiRouter)
|
# to true.
|
||||||
app.use(ErrorController.handleApiError)
|
notDefined = (x) -> !x?
|
||||||
app.use(webRouter)
|
enableApiRouter = Settings.web?.enableApiRouter
|
||||||
app.use(ErrorController.handleError)
|
if enableApiRouter or notDefined(enableApiRouter)
|
||||||
|
logger.info("providing api router");
|
||||||
|
app.use(apiRouter)
|
||||||
|
app.use(ErrorController.handleApiError)
|
||||||
|
|
||||||
|
enableWebRouter = Settings.web?.enableWebRouter
|
||||||
|
if enableWebRouter or notDefined(enableWebRouter)
|
||||||
|
logger.info("providing web router");
|
||||||
|
app.use(webRouter)
|
||||||
|
app.use(ErrorController.handleError)
|
||||||
|
|
||||||
router = new Router(webRouter, apiRouter)
|
router = new Router(webRouter, apiRouter)
|
||||||
|
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
app: app
|
app: app
|
||||||
server: server
|
server: server
|
||||||
|
|
|
@ -271,16 +271,21 @@ module.exports = class Router
|
||||||
apiRouter.get '/perfTest', (req,res)->
|
apiRouter.get '/perfTest', (req,res)->
|
||||||
res.send("hello")
|
res.send("hello")
|
||||||
|
|
||||||
apiRouter.get '/status', (req,res)->
|
webRouter.get '/status', (req,res)->
|
||||||
res.send("websharelatex is up")
|
res.send("websharelatex is up")
|
||||||
|
apiRouter.get '/status', (req,res)->
|
||||||
|
res.send("websharelatex api is up")
|
||||||
|
|
||||||
webRouter.get '/dev/csrf', (req, res) ->
|
webRouter.get '/dev/csrf', (req, res) ->
|
||||||
res.send res.locals.csrfToken
|
res.send res.locals.csrfToken
|
||||||
|
|
||||||
|
webRouter.get '/health_check', HealthCheckController.check
|
||||||
apiRouter.get '/health_check', HealthCheckController.check
|
apiRouter.get '/health_check', HealthCheckController.check
|
||||||
|
|
||||||
|
webRouter.get '/health_check/redis', HealthCheckController.checkRedis
|
||||||
apiRouter.get '/health_check/redis', HealthCheckController.checkRedis
|
apiRouter.get '/health_check/redis', HealthCheckController.checkRedis
|
||||||
|
|
||||||
apiRouter.get "/status/compiler/:Project_id", AuthorizationMiddlewear.ensureUserCanReadProject, (req, res) ->
|
webRouter.get "/status/compiler/:Project_id", AuthorizationMiddlewear.ensureUserCanReadProject, (req, res) ->
|
||||||
project_id = req.params.Project_id
|
project_id = req.params.Project_id
|
||||||
sendRes = _.once (statusCode, message)->
|
sendRes = _.once (statusCode, message)->
|
||||||
res.status statusCode
|
res.status statusCode
|
||||||
|
@ -303,7 +308,7 @@ module.exports = class Router
|
||||||
else
|
else
|
||||||
sendRes 500, "Compiler returned failure #{status}"
|
sendRes 500, "Compiler returned failure #{status}"
|
||||||
|
|
||||||
apiRouter.get "/ip", (req, res, next) ->
|
webRouter.get "/ip", (req, res, next) ->
|
||||||
res.send({
|
res.send({
|
||||||
ip: req.ip
|
ip: req.ip
|
||||||
ips: req.ips
|
ips: req.ips
|
||||||
|
|
Loading…
Reference in a new issue