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.*
|
import java.util.*
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
embeddedServer(Netty, port = 8098, host = "0.0.0.0", module = Application::module)
|
val properties = loadConfig()
|
||||||
.start(wait = true)
|
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 config = ApplicationConfig("application.conf")
|
||||||
val configFile = loadConfig()
|
|
||||||
val dbUrl = configFile.getProperty("ktor.database.url")
|
val dbUrl = configFile.getProperty("ktor.database.url")
|
||||||
val username = configFile.getProperty("ktor.database.username")
|
val username = configFile.getProperty("ktor.database.username")
|
||||||
val password = configFile.getProperty("ktor.database.password")
|
val password = configFile.getProperty("ktor.database.password")
|
||||||
val secret = config.property("ktor.jwt.secret").getString()
|
val secret = config.property("ktor.jwt.secret").getString()
|
||||||
configureDatabases(dbUrl, username, password)
|
configureDatabases(dbUrl, username, password)
|
||||||
configureSecurity(secret)
|
configureSecurity(secret)
|
||||||
configureRouting(dbUrl, username, password)
|
configureRouting()
|
||||||
configureSerialization()
|
configureSerialization()
|
||||||
|
|
||||||
install(CallLogging)
|
install(CallLogging)
|
||||||
@ -45,7 +47,7 @@ fun Application.module() {
|
|||||||
|
|
||||||
fun loadConfig(): Properties {
|
fun loadConfig(): Properties {
|
||||||
val properties = Properties()
|
val properties = Properties()
|
||||||
val inputStream = FileInputStream("/home/ristocloudadm/config.properties")
|
val inputStream = FileInputStream("/home/backend_api/config.properties")
|
||||||
properties.load(inputStream)
|
properties.load(inputStream)
|
||||||
return properties
|
return properties
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,5 @@
|
|||||||
package eu.maiora.plugins
|
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.AccountsRepositoryImpl
|
||||||
import eu.maiora.model.MovimentiRepositoryImpl
|
import eu.maiora.model.MovimentiRepositoryImpl
|
||||||
import eu.maiora.model.ParametriRepositoryImpl
|
import eu.maiora.model.ParametriRepositoryImpl
|
||||||
@ -15,8 +11,7 @@ import io.ktor.server.application.*
|
|||||||
import io.ktor.server.response.*
|
import io.ktor.server.response.*
|
||||||
import io.ktor.server.routing.*
|
import io.ktor.server.routing.*
|
||||||
|
|
||||||
//fun Application.configureRouting(dbUrl : String, username : String, password : String, repository : LogScriptRepositoryImpl ) {
|
fun Application.configureRouting() {
|
||||||
fun Application.configureRouting(dbUrl : String, username : String, password : String) {
|
|
||||||
routing {
|
routing {
|
||||||
get("/") {
|
get("/") {
|
||||||
call.respondText("Hello World!")
|
call.respondText("Hello World!")
|
||||||
|
@ -16,7 +16,7 @@ import java.util.*
|
|||||||
|
|
||||||
|
|
||||||
fun Route.auth(accountsRepository: AccountsRepositoryImpl) {
|
fun Route.auth(accountsRepository: AccountsRepositoryImpl) {
|
||||||
route("/auth") {
|
route("/api/auth") {
|
||||||
post() {
|
post() {
|
||||||
// Riceve il body della richiesta e lo deserializza in ReceivedResponse
|
// Riceve il body della richiesta e lo deserializza in ReceivedResponse
|
||||||
val receivedResponse = try {
|
val receivedResponse = try {
|
||||||
|
Loading…
Reference in New Issue
Block a user