implement admin config checking

This commit is contained in:
Ulf Gebhardt 2022-03-22 13:14:13 +01:00
parent 703217e938
commit 1d6dace9f4
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
4 changed files with 30 additions and 6 deletions

View File

@ -1,3 +1,5 @@
CONFIG_VERSION=v1.2022-03-18
GRAPHQL_URI=http://localhost:4000/graphql GRAPHQL_URI=http://localhost:4000/graphql
WALLET_AUTH_URL=http://localhost/authenticate?token={token} WALLET_AUTH_URL=http://localhost/authenticate?token={token}
WALLET_URL=http://localhost/login WALLET_URL=http://localhost/login

View File

@ -1,3 +1,5 @@
CONFIG_VERSION=$ADMIN_CONFIG_VERSION
GRAPHQL_URI=$GRAPHQL_URI GRAPHQL_URI=$GRAPHQL_URI
WALLET_AUTH_URL=$WALLET_AUTH_URL WALLET_AUTH_URL=$WALLET_AUTH_URL
WALLET_URL=$WALLET_URL WALLET_URL=$WALLET_URL

View File

@ -4,11 +4,20 @@
// Load Package Details for some default values // Load Package Details for some default values
const pkg = require('../../package') const pkg = require('../../package')
const constants = {
CONFIG_VERSION: {
DEFAULT: 'DEFAULT',
EXPECTED: 'v1.2022-03-18',
CURRENT: '',
},
}
const version = { const version = {
APP_VERSION: pkg.version, APP_VERSION: pkg.version,
BUILD_COMMIT: process.env.BUILD_COMMIT || null, BUILD_COMMIT: process.env.BUILD_COMMIT || null,
// self reference of `version.BUILD_COMMIT` is not possible at this point, hence the duplicate code // self reference of `version.BUILD_COMMIT` is not possible at this point, hence the duplicate code
BUILD_COMMIT_SHORT: (process.env.BUILD_COMMIT || '0000000').substr(0, 7), BUILD_COMMIT_SHORT: (process.env.BUILD_COMMIT || '0000000').substr(0, 7),
PORT: process.env.PORT || 8080,
} }
const environment = { const environment = {
@ -27,14 +36,24 @@ const debug = {
DEBUG_DISABLE_AUTH: process.env.DEBUG_DISABLE_AUTH === 'true' || false, DEBUG_DISABLE_AUTH: process.env.DEBUG_DISABLE_AUTH === 'true' || false,
} }
const options = {} // Check config version
constants.CONFIG_VERSION.CURRENT = process.env.CONFIG_VERSION || constants.CONFIG_VERSION.DEFAULT
if (
![constants.CONFIG_VERSION.EXPECTED, constants.CONFIG_VERSION.DEFAULT].includes(
constants.CONFIG_VERSION.CURRENT,
)
) {
throw new Error(
`Fatal: Config Version incorrect - expected "${constants.CONFIG_VERSION.EXPECTED}" or "${constants.CONFIG_VERSION.DEFAULT}", but found "${constants.CONFIG_VERSION.CURRENT}"`,
)
}
const CONFIG = { const CONFIG = {
...constants,
...version, ...version,
...environment, ...environment,
...endpoints, ...endpoints,
...options,
...debug, ...debug,
} }
export default CONFIG module.exports = CONFIG

View File

@ -2,11 +2,12 @@ const path = require('path')
const webpack = require('webpack') const webpack = require('webpack')
const Dotenv = require('dotenv-webpack') const Dotenv = require('dotenv-webpack')
const StatsPlugin = require('stats-webpack-plugin') const StatsPlugin = require('stats-webpack-plugin')
const CONFIG = require('./src/config')
// vue.config.js // vue.config.js
module.exports = { module.exports = {
devServer: { devServer: {
port: process.env.PORT || 8080, port: CONFIG.PORT,
}, },
pluginOptions: { pluginOptions: {
i18n: { i18n: {
@ -34,7 +35,7 @@ module.exports = {
// 'process.env.DOCKER_WORKDIR': JSON.stringify(process.env.DOCKER_WORKDIR), // 'process.env.DOCKER_WORKDIR': JSON.stringify(process.env.DOCKER_WORKDIR),
// 'process.env.BUILD_DATE': JSON.stringify(process.env.BUILD_DATE), // 'process.env.BUILD_DATE': JSON.stringify(process.env.BUILD_DATE),
// 'process.env.BUILD_VERSION': JSON.stringify(process.env.BUILD_VERSION), // 'process.env.BUILD_VERSION': JSON.stringify(process.env.BUILD_VERSION),
'process.env.BUILD_COMMIT': JSON.stringify(process.env.BUILD_COMMIT), 'process.env.BUILD_COMMIT': JSON.stringify(CONFIG.BUILD_COMMIT),
// 'process.env.PORT': JSON.stringify(process.env.PORT), // 'process.env.PORT': JSON.stringify(process.env.PORT),
}), }),
// generate webpack stats to allow analysis of the bundlesize // generate webpack stats to allow analysis of the bundlesize
@ -46,7 +47,7 @@ module.exports = {
}, },
css: { css: {
// Enable CSS source maps. // Enable CSS source maps.
sourceMap: process.env.NODE_ENV !== 'production', sourceMap: CONFIG.NODE_ENV !== 'production',
}, },
outputDir: path.resolve(__dirname, './dist'), outputDir: path.resolve(__dirname, './dist'),
} }