Merge pull request #4312 from overleaf/jpa-module-import-sequence-from-config

[Modules] source list of modules and their import sequence from config

GitOrigin-RevId: 73a552e03f8e9ec6ae8fce3a664625095dc095fc
This commit is contained in:
Jakob Ackermann 2021-07-14 12:54:37 +02:00 committed by Copybot
parent cebad4a774
commit 947eda54e7
4 changed files with 19 additions and 24 deletions

View file

@ -12,17 +12,24 @@ const _hooks = {}
let _viewIncludes = {}
function loadModules() {
for (const moduleName of fs.readdirSync(MODULE_BASE_PATH)) {
if (fs.existsSync(Path.join(MODULE_BASE_PATH, moduleName, 'index.js'))) {
const settingsCheckModule = Path.join(
MODULE_BASE_PATH,
'settings-check',
'index.js'
)
if (fs.existsSync(settingsCheckModule)) {
require(settingsCheckModule)
}
for (const moduleName of Settings.moduleImportSequence) {
const loadedModule = require(Path.join(
MODULE_BASE_PATH,
moduleName,
'index'
'index.js'
))
loadedModule.name = moduleName
_modules.push(loadedModule)
}
}
attachHooks()
}

View file

@ -567,10 +567,6 @@ module.exports = {
},
reloadModuleViewsOnEachRequest: process.env.NODE_ENV === 'development',
disableModule: {
'user-activate': process.env.DISABLE_MODULE_USER_ACTIVATE === 'true',
launchpad: process.env.DISABLE_MODULE_LAUNCHPAD === 'true',
},
rateLimit: {
autoCompile: {
@ -706,6 +702,8 @@ module.exports = {
tprLinkedFileRefreshError: [],
},
moduleImportSequence: ['launchpad', 'user-activate'],
csp: {
percentage: parseFloat(process.env.CSP_PERCENTAGE) || 0,
enabled: process.env.CSP_ENABLED === 'true',

View file

@ -10,17 +10,12 @@
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
*/
const logger = require('logger-sharelatex')
const Settings = require('@overleaf/settings')
const LaunchpadController = require('./LaunchpadController')
const AuthenticationController = require('../../../../app/src/Features/Authentication/AuthenticationController')
const AuthorizationMiddleware = require('../../../../app/src/Features/Authorization/AuthorizationMiddleware')
module.exports = {
apply(webRouter, apiRouter) {
if (Settings.disableModule.launchpad) {
logger.log({}, 'Skipping Init launchpad router')
return
}
logger.log({}, 'Init launchpad router')
webRouter.get('/launchpad', LaunchpadController.launchpadPage)

View file

@ -1,14 +1,9 @@
const logger = require('logger-sharelatex')
const Settings = require('@overleaf/settings')
const UserActivateController = require('./UserActivateController')
const AuthenticationController = require('../../../../app/src/Features/Authentication/AuthenticationController')
module.exports = {
apply(webRouter) {
if (Settings.disableModule['user-activate']) {
logger.log({}, 'Skipping Init UserActivate router')
return
}
logger.log({}, 'Init UserActivate router')
webRouter.get('/user/activate', UserActivateController.activateAccountPage)