forked from maiora/backend-api
Compare commits
4 Commits
28a9ec86af
...
57597c3d94
Author | SHA1 | Date | |
---|---|---|---|
57597c3d94 | |||
8a934dca5b | |||
23733caca9 | |||
b49577804e |
@ -13,20 +13,22 @@ import java.io.FileInputStream
|
||||
import java.util.*
|
||||
|
||||
fun main() {
|
||||
embeddedServer(Netty, port = 8098, host = "0.0.0.0", module = Application::module)
|
||||
.start(wait = true)
|
||||
val properties = loadConfig()
|
||||
val port = properties.getProperty("server.port").toInt()
|
||||
embeddedServer(Netty, port = port, host = "0.0.0.0") {
|
||||
module(properties)
|
||||
}.start(wait = true)
|
||||
}
|
||||
|
||||
fun Application.module() {
|
||||
fun Application.module(configFile: Properties) {
|
||||
val config = ApplicationConfig("application.conf")
|
||||
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)
|
||||
configureRouting(dbUrl, username, password)
|
||||
configureRouting()
|
||||
configureSerialization()
|
||||
|
||||
install(CallLogging)
|
||||
@ -45,7 +47,7 @@ fun Application.module() {
|
||||
|
||||
fun loadConfig(): Properties {
|
||||
val properties = Properties()
|
||||
val inputStream = FileInputStream("/home/ristocloudadm/config.properties")
|
||||
val inputStream = FileInputStream("/home/backend_api/config.properties")
|
||||
properties.load(inputStream)
|
||||
return properties
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
package eu.maiora.plugins
|
||||
|
||||
//import eu.maiora.model.LogScriptRepositoryImpl
|
||||
//import eu.maiora.routes.analizzaURLRoute
|
||||
//import eu.maiora.routes.eseguiScriptSQLRoute
|
||||
//import eu.maiora.routes.logScriptRouting
|
||||
import eu.maiora.model.AccountsRepositoryImpl
|
||||
import eu.maiora.model.MovimentiRepositoryImpl
|
||||
import eu.maiora.model.ParametriRepositoryImpl
|
||||
@ -15,8 +11,7 @@ import io.ktor.server.application.*
|
||||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
//fun Application.configureRouting(dbUrl : String, username : String, password : String, repository : LogScriptRepositoryImpl ) {
|
||||
fun Application.configureRouting(dbUrl : String, username : String, password : String) {
|
||||
fun Application.configureRouting() {
|
||||
routing {
|
||||
get("/") {
|
||||
call.respondText("Hello World!")
|
||||
|
@ -16,7 +16,7 @@ import java.util.*
|
||||
|
||||
|
||||
fun Route.auth(accountsRepository: AccountsRepositoryImpl) {
|
||||
route("/auth") {
|
||||
route("/api/auth") {
|
||||
post() {
|
||||
// Riceve il body della richiesta e lo deserializza in ReceivedResponse
|
||||
val receivedResponse = try {
|
||||
|
Loading…
Reference in New Issue
Block a user