Use a single config file

This commit is contained in:
Hubert Van De Walle 2020-06-30 16:23:06 +02:00
parent a1e7c8ba98
commit 0993d93ccc
4 changed files with 23 additions and 48 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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<String>(tag = "config file")
ConfigLoader().loadConfigOrThrow<Config>(configFile)
}
bind() from singleton { ConfigLoader().loadConfigOrThrow<Config>("/application.yaml") }
bind<SimpleJWT>(tag = "auth") with singleton { configureAuthJwt(this.kodein) }
bind<SimpleJWT>(tag = "refresh") with singleton { configureRefreshJwt(this.kodein) }
bind<DataSource>() with singleton { configureDatasource(this.kodein) }