Dominick
04/28/2021, 5:44 AM@Suppress("unused") // Referenced in application.conf
@kotlin.jvm.JvmOverloads
fun Application.module(testing: Boolean = false) {
// <https://ktor.io/servers/features/https-redirect.html#testing>
if (!testing) {
install(HttpsRedirect) {
// The port to redirect to. By default 443, the default HTTPS port.
sslPort = 1818
// 301 Moved Permanently, or 302 Found redirect.
permanentRedirect = true
}
}
install(ContentNegotiation) {
gson {}
}
routing {
userRoutes()
/*
fileRoutes()
miscRoutes()
deliveryRoutes()
*/
static("/") {
files("public")
default("public/index.html")
}
}
val dataSource = HikariDataSource().apply {
maximumPoolSize = 20
driverClassName = "com.mysql.cj.jdbc.Driver"
jdbcUrl = "[removed]"
addDataSourceProperty("user", "mediauser")
addDataSourceProperty("password", "[removed]")
isAutoCommit = false
}
Database.Companion.connect(dataSource)
transaction {
addLogger(StdOutSqlLogger)
SchemaUtils.create(MediaPropertiesTable, MediaContentTable, UserAPIKeysTable, UserTable)
}
Thread(ConsoleRunnable).run()
}
Lynette Midy
06/17/2021, 10:34 PM