forked from maiora/backend-api
Compare commits
6 Commits
0002313-we
...
main
Author | SHA1 | Date | |
---|---|---|---|
0e061c9eca | |||
7b8eaa6261 | |||
7f6e1fc6cb | |||
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,18 +1,12 @@
|
||||
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.ParametriRepositoryImpl
|
||||
import eu.maiora.routes.auth
|
||||
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 {
|
||||
@ -31,7 +31,7 @@ fun Route.auth(accountsRepository: AccountsRepositoryImpl) {
|
||||
logger.info(
|
||||
"param: " +
|
||||
receivedResponse.param
|
||||
);
|
||||
)
|
||||
|
||||
// Decodifica la stringa da Base64 a oggetto Credentials
|
||||
val decodedBytes = Base64.getDecoder().decode(receivedResponse.param)
|
||||
|
@ -1,19 +1,43 @@
|
||||
<configuration>
|
||||
|
||||
<!-- Appender per la console -->
|
||||
<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>
|
||||
|
||||
<!-- Appender per il file di log con rotazione basata su tempo e dimensione -->
|
||||
<appender name="ROLLING_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>./log/logFile.log</file> <!-- File di log principale -->
|
||||
<append>true</append>
|
||||
|
||||
<!-- RollingPolicy per dimensione e tempo -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!-- Pattern per il nome dei file ruotati: include la data -->
|
||||
<FileNamePattern>./log/logFile.%d{yyyy-MM-dd}.%i.log</FileNamePattern> <!-- %i è il numero di file generato -->
|
||||
|
||||
<!-- Limita la dimensione del file a 100MB -->
|
||||
<maxFileSize>100MB</maxFileSize> <!-- Ruota il file quando raggiunge 100MB -->
|
||||
|
||||
<!-- Conserva i log per due settimane -->
|
||||
<maxHistory>15</maxHistory> <!-- Limita a 15 giorni i log archiviati -->
|
||||
|
||||
<!-- Limita la dimensione totale dei file di log a 5GB -->
|
||||
<totalSizeCap>5GB</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
|
||||
<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"/>
|
||||
|
||||
<!-- Configurazione del livello di log -->
|
||||
<root level="DEBUG">
|
||||
<appender-ref ref="ROLLING_FILE"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</root>
|
||||
|
||||
<logger name="io.netty" level="INFO"/>
|
||||
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user