Skip to content

Commit

Permalink
Merge 199dc60 into 25efb88
Browse files Browse the repository at this point in the history
  • Loading branch information
milosmns authored Oct 16, 2023
2 parents 25efb88 + 199dc60 commit 28ac220
Show file tree
Hide file tree
Showing 180 changed files with 5,543 additions and 8 deletions.
7 changes: 4 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmCompilation

plugins {
application
kotlin("multiplatform") version "1.9.+" // when replacing, search the whole file for "9"
kotlin("plugin.serialization") version "1.9.+"
kotlin("multiplatform") version "1.9.10"
kotlin("plugin.serialization") version "1.9.10"
id("com.apollographql.apollo3") version "4.+"
id("com.github.johnrengelman.shadow") version "8.+"
id("org.jlleitschuh.gradle.ktlint") version "11.+"
id("com.github.breadmoirai.github-release") version "2.+"
id("com.github.breadmoirai.github-release") version "2.4.+"
id("app.cash.sqldelight") version "2.+"
}

Expand Down Expand Up @@ -140,6 +140,7 @@ kotlin {
archiveBaseName.set(output.artifact)
archiveClassifier.set("")
archiveVersion.set("")
isZip64 = true

val jvmMainCompilation = jvmTarget.compilations.getByName<KotlinJvmCompilation>("main")
from(jvmMainCompilation.output)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ org.gradle.jvmargs=-Xmx4096m
# Project properties
config.group = xyz.marinkovic.milos
config.artifact = codestats
config.version = 0.7.0
config.version = 0.8.0
config.gitHubRepoOwner = milosmns
config.gitHubRepoName = code-stats
11 changes: 7 additions & 4 deletions src/commonMain/kotlin/commands/cli/ServeCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
import io.ktor.server.plugins.cors.routing.CORS
import io.ktor.server.plugins.forwardedheaders.ForwardedHeaders
import io.ktor.server.response.respond
import io.ktor.server.routing.Route
import io.ktor.server.routing.get
import io.ktor.server.routing.routing
import kotlinx.coroutines.Runnable
Expand All @@ -31,7 +32,7 @@ class ServeCommand(
) : Runnable {

@Serializable
private data class MessageResponse(val message: String)
data class MessageResponse(val message: String)

private lateinit var server: BaseApplicationEngine
private lateinit var storedRepos: List<Repository>
Expand Down Expand Up @@ -75,18 +76,18 @@ class ServeCommand(
server = embeddedServer(
factory = CIO,
port = serverConfig.portApi,
) { customizeConfiguration() }
) { setUp() }

server.start(wait = true)
}

private fun Application.customizeConfiguration() {
private fun Application.setUp() {
install(ForwardedHeaders)
install(CORS) { allowHost("localhost") }
install(ContentNegotiation) { json() }

routing {
get("/") { call.respond(MessageResponse("Yep, it runs…")) }
setUpRoot()
get("/repos") { call.respond(storedRepos) }
get("/metrics") { call.respond(metricsByName) }
get("/time-series") { call.respond(metricsByNameTimeSeries) }
Expand All @@ -98,3 +99,5 @@ class ServeCommand(
}

}

expect fun Route.setUpRoot(): Route
2 changes: 2 additions & 0 deletions src/commonMain/resources/web/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
Loading

0 comments on commit 28ac220

Please sign in to comment.