[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libeufin] 01/02: admit --db option
From: |
gnunet |
Subject: |
[libeufin] 01/02: admit --db option |
Date: |
Tue, 26 May 2020 13:56:12 +0200 |
This is an automated email from the git hooks/post-receive script.
ms pushed a commit to branch master
in repository libeufin.
commit 4ebe7337a586779b7ae8414523188cdf7e768ed8
Author: MS <address@hidden>
AuthorDate: Tue May 26 13:20:43 2020 +0200
admit --db option
---
nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt | 4 ++--
nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 14 ++++++++------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
index 72becea..4566792 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/DB.kt
@@ -269,8 +269,8 @@ class NexusBankConnectionEntity(id: EntityID<String>) :
Entity<String>(id) {
var owner by NexusUserEntity referencedOn NexusBankConnectionsTable.owner
}
-fun dbCreateTables() {
- Database.connect("jdbc:sqlite:libeufin-nexus.sqlite3", "org.sqlite.JDBC")
+fun dbCreateTables(dbName: String) {
+ Database.connect("jdbc:sqlite:${dbName}", "org.sqlite.JDBC")
TransactionManager.manager.defaultIsolationLevel =
Connection.TRANSACTION_SERIALIZABLE
transaction {
addLogger(StdOutSqlLogger)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
index 5a30093..017a27e 100644
--- a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
+++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -32,6 +32,8 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.ProgramResult
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.parameters.arguments.argument
+import com.github.ajalt.clikt.parameters.arguments.default
+import com.github.ajalt.clikt.parameters.options.default
import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.prompt
import io.ktor.application.ApplicationCall
@@ -80,17 +82,18 @@ class NexusCommand : CliktCommand() {
}
class Serve : CliktCommand("Run nexus HTTP server") {
+ private val dbName by option().default("libeufin-nexus.sqlite3")
override fun run() {
- serverMain()
+ serverMain(dbName)
}
}
-
class Superuser : CliktCommand("Add superuser or change pw") {
+ private val dbName by option().default("libeufin-nexus.sqlite3")
private val username by argument()
private val password by option().prompt(requireConfirmation = true,
hideInput = true)
override fun run() {
- dbCreateTables()
+ dbCreateTables(dbName)
transaction {
val hashedPw = hashpw(password)
val user = NexusUserEntity.findById(username)
@@ -221,9 +224,8 @@ fun requireBankConnection(call: ApplicationCall,
parameterKey: String): NexusBan
return conn
}
-
-fun serverMain() {
- dbCreateTables()
+fun serverMain(dbName: String) {
+ dbCreateTables(dbName)
val client = HttpClient {
expectSuccess = false // this way, it does not throw exceptions on !=
200 responses.
}
--
To stop receiving notification emails like this one, please contact
address@hidden.