mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
use settings instead of ENV for web/api split
This commit is contained in:
parent
4b188ce120
commit
62d6933886
1 changed files with 15 additions and 19 deletions
|
@ -161,25 +161,21 @@ 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)
|
||||||
|
|
||||||
# can set WEB_TYPE=api-only or WEB_TYPE=web-only for separate web and
|
# provide settings for separate web and api processes
|
||||||
# api processes
|
# if enableApiRouter and enableWebRouter are not defined they default
|
||||||
switch process.env.WEB_TYPE
|
# to true.
|
||||||
when "api-only"
|
notDefined = (x) -> !x?
|
||||||
|
enableApiRouter = Settings.web?.enableApiRouter
|
||||||
|
if enableApiRouter or notDefined(enableApiRouter)
|
||||||
logger.info("providing api router");
|
logger.info("providing api router");
|
||||||
app.use(apiRouter)
|
app.use(apiRouter)
|
||||||
app.use(ErrorController.handleApiError)
|
app.use(ErrorController.handleApiError)
|
||||||
when "web-only"
|
|
||||||
|
enableWebRouter = Settings.web?.enableWebRouter
|
||||||
|
if enableWebRouter or notDefined(enableWebRouter)
|
||||||
logger.info("providing web router");
|
logger.info("providing web router");
|
||||||
app.use(webRouter)
|
app.use(webRouter)
|
||||||
app.use(ErrorController.handleError)
|
app.use(ErrorController.handleError)
|
||||||
else
|
|
||||||
logger.info("providing web and api router");
|
|
||||||
# process api routes first, if nothing matched fall though and use
|
|
||||||
# web middleware + routes
|
|
||||||
app.use(apiRouter)
|
|
||||||
app.use(ErrorController.handleApiError)
|
|
||||||
app.use(webRouter)
|
|
||||||
app.use(ErrorController.handleError)
|
|
||||||
|
|
||||||
router = new Router(webRouter, apiRouter)
|
router = new Router(webRouter, apiRouter)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue