Add frontend web target
This commit is contained in:
parent
ff70db9280
commit
f2700f7148
7 changed files with 48 additions and 4 deletions
|
@ -128,7 +128,7 @@ fun Application.transactionRoutes(
|
|||
}
|
||||
call.respond(
|
||||
transactionRepository.save(
|
||||
Transaction(
|
||||
transaction.copy(
|
||||
title = request.title ?: transaction.title,
|
||||
description = request.description ?: transaction.description,
|
||||
amount = request.amount ?: transaction.amount,
|
||||
|
|
|
@ -22,6 +22,7 @@ dependencies {
|
|||
implementation(project(":api"))
|
||||
implementation(project(":core"))
|
||||
implementation(project(":db"))
|
||||
implementation(project(":web"))
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
|
||||
implementation("io.ktor:ktor-server-core:$ktorVersion")
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.wbrawner.twigs.server
|
|||
import com.wbrawner.twigs.*
|
||||
import com.wbrawner.twigs.db.*
|
||||
import com.wbrawner.twigs.storage.*
|
||||
import com.wbrawner.twigs.web.webRoutes
|
||||
import com.zaxxer.hikari.HikariConfig
|
||||
import com.zaxxer.hikari.HikariDataSource
|
||||
import io.ktor.application.*
|
||||
|
@ -110,6 +111,7 @@ fun Application.moduleWithDependencies(
|
|||
categoryRoutes(categoryRepository, permissionRepository)
|
||||
transactionRoutes(transactionRepository, permissionRepository)
|
||||
userRoutes(permissionRepository, sessionRepository, userRepository)
|
||||
webRoutes()
|
||||
launch {
|
||||
val metadata = (metadataRepository.findAll().firstOrNull() ?: DatabaseMetadata())
|
||||
var version = metadata.version
|
||||
|
|
|
@ -1,4 +1,2 @@
|
|||
rootProject.name = "twigs"
|
||||
include("core", "api", "app")
|
||||
include("storage")
|
||||
include("db")
|
||||
include("core", "api", "app", "storage", "db", "web")
|
||||
|
|
2
web/.gitignore
vendored
Normal file
2
web/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
build/
|
||||
src/main/resources/twigs/
|
17
web/build.gradle.kts
Normal file
17
web/build.gradle.kts
Normal file
|
@ -0,0 +1,17 @@
|
|||
plugins {
|
||||
kotlin("jvm")
|
||||
`java-library`
|
||||
}
|
||||
|
||||
val ktorVersion: String by rootProject.extra
|
||||
|
||||
dependencies {
|
||||
implementation(kotlin("stdlib"))
|
||||
api("io.ktor:ktor-server-core:$ktorVersion")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.0")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
|
||||
}
|
||||
|
||||
tasks.getByName<Test>("test") {
|
||||
useJUnitPlatform()
|
||||
}
|
24
web/src/main/kotlin/com/wbrawner/twigs/web/WebRoutes.kt
Normal file
24
web/src/main/kotlin/com/wbrawner/twigs/web/WebRoutes.kt
Normal file
|
@ -0,0 +1,24 @@
|
|||
package com.wbrawner.twigs.web
|
||||
|
||||
import io.ktor.application.*
|
||||
import io.ktor.http.content.*
|
||||
import io.ktor.request.*
|
||||
import io.ktor.response.*
|
||||
import io.ktor.routing.*
|
||||
|
||||
fun Application.webRoutes() {
|
||||
routing {
|
||||
static {
|
||||
resources("twigs")
|
||||
default("index.html")
|
||||
}
|
||||
intercept(ApplicationCallPipeline.Setup) {
|
||||
if (!call.request.path().startsWith("/api") && !call.request.path().matches(Regex(".*\\.\\w+$"))) {
|
||||
call.resolveResource("twigs/index.html")?.let {
|
||||
call.respond(it)
|
||||
return@intercept finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue