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
|
||||
server = require('http').createServer(app)
|
||||
|
||||
# process api routes first, if nothing matched fall though and use
|
||||
# web middlewear + routes
|
||||
app.use(apiRouter)
|
||||
app.use(ErrorController.handleApiError)
|
||||
app.use(webRouter)
|
||||
app.use(ErrorController.handleError)
|
||||
# provide settings for separate web and api processes
|
||||
# if enableApiRouter and enableWebRouter are not defined they default
|
||||
# to true.
|
||||
notDefined = (x) -> !x?
|
||||
enableApiRouter = Settings.web?.enableApiRouter
|
||||
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)
|
||||
|
||||
|
||||
module.exports =
|
||||
app: app
|
||||
server: server
|
||||
|
|
|
@ -271,16 +271,21 @@ module.exports = class Router
|
|||
apiRouter.get '/perfTest', (req,res)->
|
||||
res.send("hello")
|
||||
|
||||
apiRouter.get '/status', (req,res)->
|
||||
webRouter.get '/status', (req,res)->
|
||||
res.send("websharelatex is up")
|
||||
apiRouter.get '/status', (req,res)->
|
||||
res.send("websharelatex api is up")
|
||||
|
||||
webRouter.get '/dev/csrf', (req, res) ->
|
||||
res.send res.locals.csrfToken
|
||||
|
||||
webRouter.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 "/status/compiler/:Project_id", AuthorizationMiddlewear.ensureUserCanReadProject, (req, res) ->
|
||||
webRouter.get "/status/compiler/:Project_id", AuthorizationMiddlewear.ensureUserCanReadProject, (req, res) ->
|
||||
project_id = req.params.Project_id
|
||||
sendRes = _.once (statusCode, message)->
|
||||
res.status statusCode
|
||||
|
@ -303,7 +308,7 @@ module.exports = class Router
|
|||
else
|
||||
sendRes 500, "Compiler returned failure #{status}"
|
||||
|
||||
apiRouter.get "/ip", (req, res, next) ->
|
||||
webRouter.get "/ip", (req, res, next) ->
|
||||
res.send({
|
||||
ip: req.ip
|
||||
ips: req.ips
|
||||
|
|
Loading…
Reference in a new issue