-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Holding all appconfig in a single file * Config fungerer, men får ikke logget inn * Now working with login * Work fine now * Update application.yaml * Update application.yaml * Fix db issues with defaault schema * Remove copy of application.properties as it was removed * Update gitignore frontend and update application.yaml backend * Added .env --------- Co-authored-by: André Perzon <[email protected]>
- Loading branch information
Showing
19 changed files
with
205 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
backend/src/main/kotlin/no/bekk/configuration/AppConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package no.bekk.configuration | ||
|
||
object AppConfig { | ||
lateinit var airTable: AirTableConfig | ||
lateinit var microsoftGraph: MicrosoftGraphConfig | ||
lateinit var oAuth: OAuthConfig | ||
lateinit var frontend: FrontendConfig | ||
lateinit var db: DbConfig | ||
} | ||
|
||
object AirTableConfig { | ||
lateinit var accessToken: String | ||
lateinit var baseUrl: String | ||
lateinit var metadataPath: String | ||
lateinit var metodeVerkPath: String | ||
lateinit var allePath: String | ||
} | ||
|
||
object MicrosoftGraphConfig { | ||
lateinit var baseUrl: String | ||
lateinit var memberOfPath: String | ||
} | ||
|
||
object OAuthConfig { | ||
lateinit var baseUrl: String | ||
lateinit var tenantId: String | ||
lateinit var issuerPath: String | ||
lateinit var authPath: String | ||
lateinit var tokenPath: String | ||
lateinit var jwksPath: String | ||
lateinit var clientId: String | ||
lateinit var clientSecret: String | ||
lateinit var providerUrl: String | ||
} | ||
|
||
fun OAuthConfig.getIssuer() = AppConfig.oAuth.baseUrl + "/" + AppConfig.oAuth.tenantId + AppConfig.oAuth.issuerPath | ||
fun OAuthConfig.getAuthUrl() = AppConfig.oAuth.baseUrl + "/" + AppConfig.oAuth.tenantId + AppConfig.oAuth.authPath | ||
fun OAuthConfig.getTokenUrl() = AppConfig.oAuth.baseUrl + "/" + AppConfig.oAuth.tenantId + AppConfig.oAuth.tokenPath | ||
fun OAuthConfig.getJwksUrl() = AppConfig.oAuth.baseUrl + "/" + AppConfig.oAuth.tenantId + AppConfig.oAuth.jwksPath | ||
|
||
object FrontendConfig { | ||
lateinit var host: String | ||
} | ||
|
||
object DbConfig { | ||
lateinit var url: String | ||
lateinit var username: String | ||
lateinit var password: String | ||
} |
20 changes: 0 additions & 20 deletions
20
backend/src/main/kotlin/no/bekk/configuration/ConfigureDatabase.kt
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
backend/src/main/kotlin/no/bekk/configuration/DbConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package no.bekk.configuration | ||
|
||
import java.sql.Connection | ||
import java.sql.DriverManager | ||
|
||
fun getDatabaseConnection(): Connection { | ||
val dbConfig = AppConfig.db | ||
val connection = DriverManager.getConnection( | ||
dbConfig.url, | ||
dbConfig.username, | ||
dbConfig.password | ||
) | ||
connection.schema = "regelrett" | ||
return connection | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,16 @@ | ||
package no.bekk.plugins | ||
|
||
import io.ktor.server.application.* | ||
import no.bekk.configuration.getEnvVariableOrConfig | ||
import no.bekk.configuration.AppConfig | ||
import org.flywaydb.core.Flyway | ||
|
||
fun Application.runFlywayMigration() { | ||
val dbUser = getEnvVariableOrConfig("DB_USER", "ktor.database.user") | ||
val dbPassword = getEnvVariableOrConfig("DB_PASSWORD", "ktor.database.password") | ||
|
||
val dbUrl = "jdbc:postgresql://localhost:5432/regelrett" | ||
|
||
fun runFlywayMigration() { | ||
val flyway = Flyway.configure() | ||
.createSchemas(true) | ||
.defaultSchema("regelrett") | ||
.dataSource( | ||
dbUrl, dbUser, dbPassword | ||
AppConfig.db.url, | ||
AppConfig.db.username, | ||
AppConfig.db.password | ||
) | ||
.locations("filesystem:src/main/resources/db/migration") | ||
.schemas("regelrett") | ||
.load() | ||
flyway.migrate() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.