aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/App.kt
diff options
context:
space:
mode:
authorclimb2019-04-04 14:54:28 +0200
committerclimb2019-04-04 14:54:28 +0200
commitb0a2b6c5a19e0e20d50d29f52d640b5f7d19f841 (patch)
tree21c65a4d9622f7f8c202344709a659dd70c8baaa /src/main/kotlin/App.kt
parent390db9229b2aaa0a6ca7a920e4901b581ba917e2 (diff)
Moved database to own class
Diffstat (limited to 'src/main/kotlin/App.kt')
-rw-r--r--src/main/kotlin/App.kt40
1 files changed, 5 insertions, 35 deletions
diff --git a/src/main/kotlin/App.kt b/src/main/kotlin/App.kt
index 87055a1..4682e92 100644
--- a/src/main/kotlin/App.kt
+++ b/src/main/kotlin/App.kt
@@ -5,29 +5,23 @@ import io.javalin.*
import io.javalin.core.util.*
import io.javalin.rendering.*
import io.javalin.rendering.template.TemplateUtil.model
-import org.jetbrains.exposed.sql.*
-import org.jetbrains.exposed.sql.transactions.*
import java.io.*
import java.nio.file.*
-import java.sql.*
+
fun main() {
val app = Javalin.create().enableStaticFiles("../resources/").start(7000)
val fileHome = "files"
- // TODO: Move to own database class
- val db: Database = Database.connect("jdbc:sqlite:main.db", "org.sqlite.JDBC")
- TransactionManager.manager.defaultIsolationLevel = Connection.TRANSACTION_SERIALIZABLE
-
- transaction {
- SchemaUtils.createMissingTablesAndColumns(FileLocation, UserData, General)
- }
-
JavalinRenderer.register(
FileRenderer { filepath, model -> Rocker.template(filepath).bind(model).render().toString() }, ".rocker.html"
)
+ val db = DB()
+
+ // TODO: If not initialUse show setup page
+
/**
* Sends a json object of filenames in [fileHome]s
* TODO: Fix possible security issue with "../"
@@ -78,31 +72,7 @@ fun main() {
}
}
-/**
- * Database table for the file location indexing
- */
-object FileLocation : Table() {
- val id = integer("id").autoIncrement().primaryKey()
- val location = text("location")
-}
-/**
- * Database table to index the users with their regarding passwords
- */
-object UserData : Table() {
- // only for multiple users: val id = integer("id").autoIncrement().primaryKey()
- val username = varchar("username", 24).primaryKey() // remove if ID
- val password = varchar("password", 64)
-}
-
-/**
- * Database table storing general data/states
- */
-object General : Table() {
- // redundant: val id = integer("id").autoIncrement().primaryKey()
- val initialUse = integer("initialUse").primaryKey() // remove pKey if ID // boolean -> 0:1
- // TODO: If not isSetup show other front page
-}