From 751e141f919271acc6b76a9d3953d726bd7cf524 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Mon, 14 Nov 2022 21:58:56 +0100 Subject: [PATCH] Fix module state detection --- src/api/v2/index.js | 5 +++-- src/index.js | 5 +++-- src/routes/api.js | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/api/v2/index.js b/src/api/v2/index.js index 9be5548..423ef98 100644 --- a/src/api/v2/index.js +++ b/src/api/v2/index.js @@ -33,10 +33,11 @@ import proxyGetApiRouter from './proxy_get.js' const router = express.Router() -if (process.env.ENABLE_MAIN_MODULE ?? true) { +if (process.env.ENABLE_MAIN_MODULE === 'true') { router.use('/profile', keyoxideProfileApiRouter) } -if (process.env.ENABLE_PROXY_MODULE ?? true) { +console.log(process.env.ENABLE_PROXY_MODULE); +if (process.env.ENABLE_PROXY_MODULE === 'true') { router.use('/get', proxyGetApiRouter) } diff --git a/src/index.js b/src/index.js index ddd251a..f53aac9 100644 --- a/src/index.js +++ b/src/index.js @@ -72,7 +72,9 @@ app.use(stringReplace({ })) // Routes -if (process.env.ENABLE_MAIN_MODULE ?? true) { +app.use('/api', apiRoute) +if (process.env.ENABLE_MAIN_MODULE === 'true') { + console.log("lol", process.env.ENABLE_MAIN_MODULES); app.use('/favicon.svg', express.static('./static/favicon.svg')) app.use('/robots.txt', express.static('./static/robots.txt')) @@ -81,7 +83,6 @@ if (process.env.ENABLE_MAIN_MODULE ?? true) { app.use('/util', utilRoute) app.use('/', profileRoute) } -app.use('/api', apiRoute) app.listen(app.get('port'), () => { console.log(`Server listening at http://localhost:${app.get('port')}`) diff --git a/src/routes/api.js b/src/routes/api.js index 2a6aa3c..d8a8abb 100644 --- a/src/routes/api.js +++ b/src/routes/api.js @@ -34,7 +34,9 @@ import apiRouter2 from '../api/v2/index.js' const router = express.Router() -router.use('/0', apiRouter0) +if (process.env.ENABLE_MAIN_MODULE === 'true') { + router.use('/0', apiRouter0) +} router.use('/1', apiRouter1) router.use('/2', apiRouter2)