forked from maiora/backend-api
file config esterno
sul file di configurazione esterno vengono mappate le proprietà legate alla connessione al database
This commit is contained in:
parent
74570dc330
commit
8242c78b35
1
.gitignore
vendored
1
.gitignore
vendored
@ -41,3 +41,4 @@ bin/
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
.idea/.name
|
||||
*.log
|
||||
|
@ -9,6 +9,8 @@ import io.ktor.server.engine.*
|
||||
import io.ktor.server.netty.*
|
||||
import io.ktor.server.plugins.callloging.*
|
||||
import io.ktor.server.plugins.cors.routing.*
|
||||
import java.io.FileInputStream
|
||||
import java.util.*
|
||||
|
||||
fun main() {
|
||||
embeddedServer(Netty, port = 8098, host = "0.0.0.0", module = Application::module)
|
||||
@ -17,9 +19,10 @@ fun main() {
|
||||
|
||||
fun Application.module() {
|
||||
val config = ApplicationConfig("application.conf")
|
||||
val dbUrl = config.property("ktor.database.url").getString()
|
||||
val username = config.property("ktor.database.username").getString()
|
||||
val password = config.property("ktor.database.password").getString()
|
||||
val configFile = loadConfig()
|
||||
val dbUrl = configFile.getProperty("ktor.database.url")
|
||||
val username = configFile.getProperty("ktor.database.username")
|
||||
val password = configFile.getProperty("ktor.database.password")
|
||||
val secret = config.property("ktor.jwt.secret").getString()
|
||||
configureDatabases(dbUrl, username, password)
|
||||
configureSecurity(secret)
|
||||
@ -39,3 +42,10 @@ fun Application.module() {
|
||||
allowMethod(HttpMethod.Delete)
|
||||
}
|
||||
}
|
||||
|
||||
fun loadConfig(): Properties {
|
||||
val properties = Properties()
|
||||
val inputStream = FileInputStream("/home/ristocloudadm/config.properties")
|
||||
properties.load(inputStream)
|
||||
return properties
|
||||
}
|
||||
|
@ -1,18 +1,4 @@
|
||||
ktor {
|
||||
database {
|
||||
; url = "jdbc:postgresql://192.168.20.49:5432/caritas"
|
||||
; username = "caritas"
|
||||
; password = "caritas"
|
||||
; driver = "org.postgresql.Driver"
|
||||
driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
|
||||
url = "jdbc:sqlserver://192.168.20.45;databaseName=EP_FAER;integratedSecurity=false;encrypt=true;trustServerCertificate=true;"
|
||||
username = "SA"
|
||||
password = "I5fz9l1a"
|
||||
;driver = "oracle.jdbc.OracleDriver"
|
||||
;url = "jdbc:oracle:thin:@//192.168.20.101:1521/SIR"
|
||||
;username = "EP_DONORIONE"
|
||||
;password = "ep_donorione"
|
||||
}
|
||||
jwt {
|
||||
# secret per JWT generato partendo dalla stringa '?Backend_API*06022025!' codificato in Base64
|
||||
secret = "P0JhY2tlbmRfQVBJKjA2MDIyMDI1IQ=="
|
||||
|
Loading…
Reference in New Issue
Block a user