From 0993d93ccc7595b29a4b71310a23b9a454ed5dfc Mon Sep 17 00:00:00 2001 From: Hubert Van De Walle Date: Tue, 30 Jun 2020 16:23:06 +0200 Subject: [PATCH] Use a single config file --- api/resources/application.dev.yaml | 22 ---------------------- api/resources/application.prod.yaml | 22 ---------------------- api/resources/application.yaml | 22 ++++++++++++++++++++++ api/src/features/ConfigurationFeature.kt | 5 +---- 4 files changed, 23 insertions(+), 48 deletions(-) delete mode 100644 api/resources/application.dev.yaml delete mode 100644 api/resources/application.prod.yaml create mode 100644 api/resources/application.yaml diff --git a/api/resources/application.dev.yaml b/api/resources/application.dev.yaml deleted file mode 100644 index 6f557b4..0000000 --- a/api/resources/application.dev.yaml +++ /dev/null @@ -1,22 +0,0 @@ -database: - host: localhost - port: 3306 - name: notes - username: notes - password: notes - -server: - host: 127.0.0.1 - port: ${PORT:-8081} - cors: true - -jwt: - auth: - secret: uiqzRNiMYwbObn/Ps5xTasYVeu/63ZuI+1oB98Ez+lY= - validity: 1 - unit: HOURS - refresh: - secret: wWchkx44YGig4Q5Z7b7+E/3ymGEGd6PS7UGedMul3bg= - validity: 15 - unit: DAYS - diff --git a/api/resources/application.prod.yaml b/api/resources/application.prod.yaml deleted file mode 100644 index 9b1d5b7..0000000 --- a/api/resources/application.prod.yaml +++ /dev/null @@ -1,22 +0,0 @@ -database: - host: ${MYSQL_HOST} - port: 3306 - name: ${MYSQL_DATABASE} - username: ${MYSQL_USER} - password: ${MYSQL_PASSWORD} - -server: - host: 0.0.0.0 - port: ${PORT:-8081} - cors: ${CORS:-true} - -jwt: - auth: - secret: ${JWT_SECRET} # Can be generated with `openssl rand -base64 32` - validity: 1 - unit: HOURS - refresh: - secret: ${JWT_REFRESH_SECRET} # Can be generated with `openssl rand -base64 32` - validity: 15 - unit: DAYS - diff --git a/api/resources/application.yaml b/api/resources/application.yaml new file mode 100644 index 0000000..2fd75d4 --- /dev/null +++ b/api/resources/application.yaml @@ -0,0 +1,22 @@ +database: + host: ${MYSQL_HOST:-localhost} + port: ${MYSQL_PORT:-3306} + name: ${MYSQL_DATABASE:-notes} + username: ${MYSQL_USER:-notes} + password: ${MYSQL_PASSWORD:-notes} + +server: + host: ${HOST:-127.0.0.1} + port: ${PORT:-8081} + cors: ${CORS:-true} + +jwt: + auth: + secret: ${JWT_SECRET:-uiqzRNiMYwbObn/Ps5xTasYVeu/63ZuI+1oB98Ez+lY=} # Can be generated with `openssl rand -base64 32` + validity: 1 + unit: HOURS + refresh: + + secret: ${JWT_REFRESH_SECRET=-wWchkx44YGig4Q5Z7b7+E/3ymGEGd6PS7UGedMul3bg=} # Can be generated with `openssl rand -base64 32` + validity: 15 + unit: DAYS diff --git a/api/src/features/ConfigurationFeature.kt b/api/src/features/ConfigurationFeature.kt index 80c8a7a..e9de45d 100644 --- a/api/src/features/ConfigurationFeature.kt +++ b/api/src/features/ConfigurationFeature.kt @@ -16,10 +16,7 @@ import javax.sql.DataSource * [Kodein] controller module containing the app configuration */ val configurationModule = Kodein.Module(name = "Configuration") { - bind() from singleton { - val configFile by this.kodein.instance(tag = "config file") - ConfigLoader().loadConfigOrThrow(configFile) - } + bind() from singleton { ConfigLoader().loadConfigOrThrow("/application.yaml") } bind(tag = "auth") with singleton { configureAuthJwt(this.kodein) } bind(tag = "refresh") with singleton { configureRefreshJwt(this.kodein) } bind() with singleton { configureDatasource(this.kodein) }