Skip to content
Snippets Groups Projects
Commit c82b1da4 authored by Yannis Barlas's avatar Yannis Barlas
Browse files

feat(*): add helpful error message for pubsweet config changes

parent 797ec71c
No related branches found
No related tags found
1 merge request!123v4
class ConfigSchemaError extends Error {
constructor(message) {
super(message)
this.name = 'ConfigSchemaError'
this.message = `${message}`
}
}
module.exports = ConfigSchemaError
......@@ -13,6 +13,7 @@ const { migrate } = require('./dbManager/migrate')
const seedGlobalTeams = require('./startup/seedGlobalTeams')
const ensureTempFolderExists = require('./startup/ensureTempFolderExists')
const { runCustomStartupScripts } = require('./startup/customScripts')
const checkConfig = require('./startup/checkConfig')
let server
......@@ -23,6 +24,7 @@ const startServer = async (app = express()) => {
logInit('Coko server init tasks')
checkConfig()
await ensureTempFolderExists()
await migrate()
await seedGlobalTeams()
......
const config = require('config')
const { logTask } = require('../logger/internals')
const ConfigSchemaError = require('../errors/ConfigSchemaError')
const throwPubsweetKeyError = key => {
throw new ConfigSchemaError(
`The "${key}" key has been removed. Move all configuration that existed under "${key}" to the top level of your config.`,
)
}
const check = () => {
logTask('Checking configuration')
if (config.has('pubsweet')) throwPubsweetKeyError('pubsweet')
if (config.has('pubsweet-server')) throwPubsweetKeyError('pubsweet=server')
}
module.exports = check
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment