Compare commits

..

No commits in common. "96afe62837da3080cad45a60f3f28609e0b3e735" and "311d1fbd3b3b79d7135374532335e187176ecfce" have entirely different histories.

7 changed files with 28 additions and 45 deletions

1
.gitignore vendored
View File

@ -41,4 +41,3 @@ bin/
### Mac OS ###
.DS_Store
.idea/.name
*.log

View File

@ -9,10 +9,6 @@ plugins {
kotlin("plugin.serialization") version "1.9.23" // Aggiungi il plugin di Serialization
}
application {
mainClass.set("eu.maiora.ApplicationKt")
}
group = "org.maiora"
version = "1.0-SNAPSHOT"

View File

@ -9,26 +9,21 @@ 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() {
val properties = loadConfig()
val port = properties.getProperty("server.port").toInt()
embeddedServer(Netty, port = port, host = "0.0.0.0") {
module(properties)
}.start(wait = true)
embeddedServer(Netty, port = 8098, host = "0.0.0.0", module = Application::module)
.start(wait = true)
}
fun Application.module(configFile: Properties) {
fun Application.module() {
val config = ApplicationConfig("application.conf")
val dbUrl = configFile.getProperty("ktor.database.url")
val username = configFile.getProperty("ktor.database.username")
val password = configFile.getProperty("ktor.database.password")
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 secret = config.property("ktor.jwt.secret").getString()
configureDatabases(dbUrl, username, password)
configureSecurity(secret)
configureRouting()
configureRouting(dbUrl, username, password)
configureSerialization()
install(CallLogging)
@ -44,10 +39,3 @@ fun Application.module(configFile: Properties) {
allowMethod(HttpMethod.Delete)
}
}
fun loadConfig(): Properties {
val properties = Properties()
val inputStream = FileInputStream("/home/backend_api/config.properties")
properties.load(inputStream)
return properties
}

View File

@ -1,5 +1,9 @@
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
@ -11,7 +15,8 @@ import io.ktor.server.application.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
fun Application.configureRouting() {
//fun Application.configureRouting(dbUrl : String, username : String, password : String, repository : LogScriptRepositoryImpl ) {
fun Application.configureRouting(dbUrl : String, username : String, password : String) {
routing {
get("/") {
call.respondText("Hello World!")

View File

@ -16,7 +16,7 @@ import java.util.*
fun Route.auth(accountsRepository: AccountsRepositoryImpl) {
route("/api/auth") {
route("/auth") {
post() {
// Riceve il body della richiesta e lo deserializza in ReceivedResponse
val receivedResponse = try {

View File

@ -1,4 +1,18 @@
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=="

View File

@ -1,19 +0,0 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>./logFile.log</file>
<append>true</append>
<encoder>
<pattern>%d{YYYY-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="trace">
<appender-ref ref="FILE"/>
<appender-ref ref="STDOUT"/>
</root>
<logger name="io.netty" level="INFO"/>
</configuration>