-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleaned up startup and added documentation in anticipation of adding …
…docker deployment next
- Loading branch information
1 parent
849ca9e
commit 75001bd
Showing
12 changed files
with
258 additions
and
173 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* Added gradle task to provide release version to pipelines |
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
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import kotlinx.html.* | ||
|
||
/** | ||
* We use kotlinx to create this HTML index file which contains the reference to `/static/output.js`, the location | ||
* of our generated JS code from KotlinJS. This is also where we load in our external fonts and set the main 'root' div. | ||
*/ | ||
fun HTML.index() { | ||
head { | ||
meta { | ||
charset = "UTF-8" | ||
} | ||
title("Validator GUI") | ||
link( | ||
href = "https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap", | ||
rel = "stylesheet" | ||
) | ||
link( | ||
href = "https://fonts.googleapis.com/css2?family=Source+Code+Pro:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,900;1,200;1,300;1,400;1,500;1,600;1,700;1,900&display=swap", | ||
rel = "stylesheet" | ||
) | ||
} | ||
body { | ||
div { | ||
id = "root" | ||
} | ||
script(src = "/static/output.js") {} | ||
} | ||
} |
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,100 @@ | ||
import com.fasterxml.jackson.databind.DeserializationFeature | ||
import com.fasterxml.jackson.databind.SerializationFeature | ||
import desktop.launchLocalApp | ||
import io.ktor.application.* | ||
import io.ktor.features.* | ||
import io.ktor.html.* | ||
import io.ktor.http.* | ||
import io.ktor.http.content.* | ||
import io.ktor.jackson.* | ||
import io.ktor.routing.* | ||
import kotlinx.html.* | ||
import org.slf4j.event.Level | ||
import routes.debugRoutes | ||
import routes.igRoutes | ||
import routes.validationRoutes | ||
import routes.versionRoutes | ||
|
||
/** | ||
* Entry point of the application. This function is referenced in the resources/application.conf file (see the line | ||
* that says `modules = [ ModuleKt.module ]`, pointing to this method. | ||
*/ | ||
fun Application.module() { | ||
// Any DB initialization will go here. | ||
val starting: (Application) -> Unit = { log.info("Application starting: $it") } | ||
val started: (Application) -> Unit = { | ||
log.info("Application started: $it") | ||
if (runningAsDesktopStandalone) { | ||
launchLocalApp() | ||
} | ||
} | ||
val stopping: (Application) -> Unit = { log.info("Application stopping: $it") } | ||
var stopped: (Application) -> Unit = {} | ||
|
||
stopped = { | ||
log.info("Application stopped: $it") | ||
environment.monitor.unsubscribe(ApplicationStarting, starting) | ||
environment.monitor.unsubscribe(ApplicationStarted, started) | ||
environment.monitor.unsubscribe(ApplicationStopping, stopping) | ||
environment.monitor.unsubscribe(ApplicationStopped, stopped) | ||
} | ||
|
||
environment.monitor.subscribe(ApplicationStarted, starting) | ||
environment.monitor.subscribe(ApplicationStarted, started) | ||
environment.monitor.subscribe(ApplicationStopping, stopping) | ||
environment.monitor.subscribe(ApplicationStopped, stopped) | ||
|
||
// Now we call to a main with the dependencies as arguments. | ||
// Separating this function with its dependencies allows us to provide several modules with | ||
// the same code and different data-sources living in the same application, | ||
// and to provide mocked instances for doing integration tests. | ||
start() | ||
} | ||
|
||
/** | ||
* Application extension function where we configure Ktor application with features, interceptors and routing. | ||
*/ | ||
fun Application.start() { | ||
|
||
install(CallLogging) { | ||
level = Level.DEBUG | ||
} | ||
|
||
install(CORS) { | ||
method(HttpMethod.Get) | ||
method(HttpMethod.Post) | ||
method(HttpMethod.Delete) | ||
anyHost() | ||
} | ||
|
||
install(Compression) { | ||
gzip() | ||
} | ||
|
||
install(ContentNegotiation) { | ||
jackson { | ||
enable(SerializationFeature.INDENT_OUTPUT) | ||
/* | ||
* Right now we need to ignore unknown fields because we take a very simplified version of many of the fhir | ||
* model classes, and map them to classes across JVM/Common/JS. | ||
*/ | ||
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) | ||
} | ||
} | ||
|
||
install(Routing) { | ||
get("/") { | ||
call.respondHtml(HttpStatusCode.OK, HTML::index) | ||
} | ||
|
||
static("/static") { | ||
resources() | ||
} | ||
resources() | ||
validationRoutes() | ||
versionRoutes() | ||
igRoutes() | ||
// Only enable if things have gone horribly, and you need to add a debug logging endpoint. | ||
//debugRoutes() | ||
} | ||
} |
Oops, something went wrong.