Initial commit
This commit is contained in:
commit
a00d6b2be2
36
.gitignore
vendored
Normal file
36
.gitignore
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
.gradle
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
46
build.gradle.kts
Normal file
46
build.gradle.kts
Normal file
|
@ -0,0 +1,46 @@
|
|||
val kotlin_version: String by project
|
||||
val logback_version: String by project
|
||||
val postgres_version: String by project
|
||||
val h2_version: String by project
|
||||
val exposed_version: String by project
|
||||
|
||||
plugins {
|
||||
kotlin("jvm") version "2.0.0"
|
||||
id("io.ktor.plugin") version "2.3.11"
|
||||
id("org.jetbrains.kotlin.plugin.serialization") version "2.0.0"
|
||||
}
|
||||
|
||||
group = "dev.frogmc"
|
||||
version = "0.0.1"
|
||||
|
||||
application {
|
||||
mainClass.set("dev.frogmc.ApplicationKt")
|
||||
|
||||
val isDevelopment: Boolean = project.ext.has("development")
|
||||
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=$isDevelopment")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("io.ktor:ktor-server-core-jvm")
|
||||
implementation("io.ktor:ktor-server-host-common-jvm")
|
||||
implementation("io.ktor:ktor-server-cors-jvm")
|
||||
implementation("io.ktor:ktor-server-content-negotiation-jvm")
|
||||
implementation("io.ktor:ktor-server-html-builder")
|
||||
implementation("io.ktor:ktor-serialization-kotlinx-json-jvm")
|
||||
implementation("io.ktor:ktor-client-core-jvm")
|
||||
implementation("io.ktor:ktor-client-cio-jvm")
|
||||
implementation("org.postgresql:postgresql:$postgres_version")
|
||||
implementation("com.h2database:h2:$h2_version")
|
||||
implementation("org.jetbrains.exposed:exposed-core:$exposed_version")
|
||||
implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
|
||||
implementation("org.jetbrains.exposed:exposed-kotlin-datetime:$exposed_version")
|
||||
implementation("io.ktor:ktor-server-netty-jvm")
|
||||
implementation("ch.qos.logback:logback-classic:$logback_version")
|
||||
implementation("io.github.virtualdogbert:logback-groovy-config:1.14.5")
|
||||
testImplementation("io.ktor:ktor-server-tests-jvm")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version")
|
||||
}
|
7
gradle.properties
Normal file
7
gradle.properties
Normal file
|
@ -0,0 +1,7 @@
|
|||
ktor_version=2.3.11
|
||||
kotlin_version=2.0.0
|
||||
logback_version=1.4.14
|
||||
kotlin.code.style=official
|
||||
postgres_version=42.7.3
|
||||
h2_version=2.1.214
|
||||
exposed_version=0.41.1
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
234
gradlew
vendored
Executable file
234
gradlew
vendored
Executable file
|
@ -0,0 +1,234 @@
|
|||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
89
gradlew.bat
vendored
Normal file
89
gradlew.bat
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
1
settings.gradle.kts
Normal file
1
settings.gradle.kts
Normal file
|
@ -0,0 +1 @@
|
|||
rootProject.name = "meta-service"
|
27
src/main/kotlin/dev/frogmc/Application.kt
Normal file
27
src/main/kotlin/dev/frogmc/Application.kt
Normal file
|
@ -0,0 +1,27 @@
|
|||
package dev.frogmc
|
||||
|
||||
import dev.frogmc.plugins.*
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.engine.*
|
||||
import io.ktor.server.netty.*
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
val logger = LoggerFactory.getLogger("FrogMC/Meta")
|
||||
|
||||
fun main() {
|
||||
|
||||
if (!DB.init()) {
|
||||
logger.error("Failed to connect to database. Aborting!")
|
||||
return
|
||||
}
|
||||
|
||||
embeddedServer(Netty, port = 3668, host = "0.0.0.0", module = Application::module)
|
||||
.start(wait = true)
|
||||
}
|
||||
|
||||
fun Application.module() {
|
||||
|
||||
configureHTTP()
|
||||
configureSerialization()
|
||||
configureRouting()
|
||||
}
|
75
src/main/kotlin/dev/frogmc/DB.kt
Normal file
75
src/main/kotlin/dev/frogmc/DB.kt
Normal file
|
@ -0,0 +1,75 @@
|
|||
package dev.frogmc
|
||||
|
||||
import dev.frogmc.types.*
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
||||
object DB {
|
||||
var db: Database? = null
|
||||
|
||||
fun init(): Boolean {
|
||||
// use postgresql
|
||||
try {
|
||||
logger.info("Connecting to the database...")
|
||||
val d = Database.connect(
|
||||
url = "jdbc:postgresql://localhost:5432/frogmc",
|
||||
driver = "org.postgresql.Driver",
|
||||
user = "postgres",
|
||||
password = "example"
|
||||
)
|
||||
db = d
|
||||
transaction(db) {
|
||||
logger.info("what is going on")
|
||||
SchemaUtils.create(
|
||||
LoaderVersions,
|
||||
LibraryVersions
|
||||
)
|
||||
}
|
||||
if (db == null) {
|
||||
logger.error("Failed to connect to the database.")
|
||||
return false
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
db = null!!
|
||||
logger.error("An error occurred while connecting to the database.")
|
||||
logger.error(e.stackTraceToString())
|
||||
return false
|
||||
}
|
||||
if (db == null) {
|
||||
logger.error("Failed to connect to the database.")
|
||||
return false
|
||||
}
|
||||
logger.info(db!!.name)
|
||||
return true
|
||||
}
|
||||
|
||||
fun getLoaderVersions(): List<LoaderVersion> {
|
||||
logger.info("Getting loader versions...")
|
||||
if (db == null) {
|
||||
logger.error("Database is null.")
|
||||
init()
|
||||
}
|
||||
logger.info(db!!.name)
|
||||
return transaction(db) {
|
||||
return@transaction LoaderVersions.selectAll().map {
|
||||
LoaderVersion(
|
||||
it[LoaderVersions.version],
|
||||
it[LoaderVersions.releaseDate],
|
||||
it[LoaderVersions.downloadUrl]
|
||||
)
|
||||
}
|
||||
}.sortedBy { it.releaseDate }.reversed()
|
||||
}
|
||||
|
||||
fun getLibraryVersions(): List<LibraryVersion> {
|
||||
return transaction(db) {
|
||||
return@transaction LibraryVersions.selectAll().map {
|
||||
LibraryVersion(
|
||||
it[LibraryVersions.version],
|
||||
it[LibraryVersions.releaseDate],
|
||||
it[LibraryVersions.modrinthVersion]
|
||||
)
|
||||
}
|
||||
}.sortedBy { it.releaseDate }.reversed()
|
||||
}
|
||||
}
|
18
src/main/kotlin/dev/frogmc/plugins/HTTP.kt
Normal file
18
src/main/kotlin/dev/frogmc/plugins/HTTP.kt
Normal file
|
@ -0,0 +1,18 @@
|
|||
package dev.frogmc.plugins
|
||||
|
||||
import io.ktor.http.*
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.plugins.cors.routing.*
|
||||
import io.ktor.server.response.*
|
||||
|
||||
fun Application.configureHTTP() {
|
||||
install(CORS) {
|
||||
allowMethod(HttpMethod.Options)
|
||||
allowMethod(HttpMethod.Put)
|
||||
allowMethod(HttpMethod.Delete)
|
||||
allowMethod(HttpMethod.Patch)
|
||||
allowHeader(HttpHeaders.Authorization)
|
||||
allowHeader("MyCustomHeader")
|
||||
anyHost() // @TODO: Don't do this in production if possible. Try to limit it.
|
||||
}
|
||||
}
|
158
src/main/kotlin/dev/frogmc/plugins/Routing.kt
Normal file
158
src/main/kotlin/dev/frogmc/plugins/Routing.kt
Normal file
|
@ -0,0 +1,158 @@
|
|||
package dev.frogmc.plugins
|
||||
|
||||
import dev.frogmc.DB
|
||||
import dev.frogmc.types.ModrinthVersion
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.call.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.html.*
|
||||
import io.ktor.server.http.content.*
|
||||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
import kotlinx.html.*
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
fun BODY.route(block: DIV.() -> Unit) =
|
||||
div(classes = "route", block)
|
||||
|
||||
|
||||
fun Application.configureRouting() {
|
||||
routing {
|
||||
staticResources("/static", "static")
|
||||
get("/") {
|
||||
call.respondHtml {
|
||||
head {
|
||||
title { +"FrogMC API" }
|
||||
link { rel = "stylesheet"; type = "text/css"; href = "/static/style.css" }
|
||||
}
|
||||
body {
|
||||
h1 { +"FrogMC API" }
|
||||
p { +"This is the FrogMC Meta API." }
|
||||
p { +"Use this to fetch versions of FrogMC library and loader." }
|
||||
br()
|
||||
p { +"Current API version: v1" }
|
||||
br()
|
||||
div(classes = "routes") {
|
||||
div(classes = "route") {
|
||||
code { +"GET /v1/loader/versions" }
|
||||
p { +"Fetches all versions of FrogMC loader." }
|
||||
}
|
||||
br()
|
||||
div(classes = "route") {
|
||||
code { +"GET /v1/loader/versions/latest" }
|
||||
p { +"Fetches the latest version of FrogMC loader." }
|
||||
}
|
||||
br()
|
||||
div(classes = "route") {
|
||||
code { +"GET /v1/loader/versions/{version}" }
|
||||
p { +"Fetches a specific version of FrogMC loader." }
|
||||
}
|
||||
br()
|
||||
div(classes = "route") {
|
||||
code { +"GET /v1/loader/versions/{version}/download" }
|
||||
p { +"Fetches the download URL of a specific version of FrogMC loader." }
|
||||
}
|
||||
br()
|
||||
div(classes = "route") {
|
||||
code { +"GET /v1/library/versions" }
|
||||
p { +"Fetches all versions of FrogMC library." }
|
||||
}
|
||||
br()
|
||||
div(classes = "route") {
|
||||
code { +"GET /v1/library/versions/latest" }
|
||||
p { +"Fetches the latest version of FrogMC library." }
|
||||
}
|
||||
br()
|
||||
div(classes = "route") {
|
||||
code { +"GET /v1/library/versions/{version}" }
|
||||
p { +"Fetches a specific version of FrogMC library." }
|
||||
}
|
||||
br()
|
||||
div(classes = "route") {
|
||||
code { +"GET /v1/library/versions/{version}/download" }
|
||||
p { +"Fetches the download URL of a specific version of FrogMC library." }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
route("/v1") {
|
||||
route("/loader") {
|
||||
get("/versions") {
|
||||
val versions = DB.getLoaderVersions()
|
||||
call.respond(versions)
|
||||
}
|
||||
get("/versions/latest") {
|
||||
val versions = DB.getLoaderVersions()
|
||||
call.respond(versions.first())
|
||||
}
|
||||
get("/versions/{version}/download") {
|
||||
val version = call.parameters["version"] ?: return@get call.respond(
|
||||
HttpStatusCode.BadRequest,
|
||||
"message" to "Invalid version."
|
||||
)
|
||||
val versions = DB.getLoaderVersions()
|
||||
val versionObj = versions.find { it.version == version } ?: return@get call.respond(
|
||||
HttpStatusCode.NotFound,
|
||||
"message" to "Version not found."
|
||||
)
|
||||
call.respond("url" to versionObj.downloadUrl)
|
||||
}
|
||||
get("/versions/{version}") {
|
||||
val version = call.parameters["version"] ?: return@get call.respond(
|
||||
HttpStatusCode.BadRequest,
|
||||
"message" to "Invalid version."
|
||||
)
|
||||
val versions = DB.getLoaderVersions()
|
||||
val versionObj = versions.find { it.version == version } ?: return@get call.respond(
|
||||
HttpStatusCode.NotFound,
|
||||
"message" to "Version not found."
|
||||
)
|
||||
call.respond(versionObj)
|
||||
}
|
||||
}
|
||||
route("/library") {
|
||||
get("/versions") {
|
||||
val versions = DB.getLibraryVersions()
|
||||
call.respond(versions)
|
||||
}
|
||||
get("/versions/latest") {
|
||||
val versions = DB.getLibraryVersions()
|
||||
call.respond(versions.first())
|
||||
}
|
||||
get("/versions/{version}/download") {
|
||||
val version = call.parameters["version"] ?: return@get call.respond(
|
||||
HttpStatusCode.BadRequest,
|
||||
"message" to "Invalid version."
|
||||
)
|
||||
val versions = DB.getLibraryVersions()
|
||||
val versionObj = versions.find { it.version == version } ?: return@get call.respond(
|
||||
HttpStatusCode.NotFound,
|
||||
"message" to "Version not found."
|
||||
)
|
||||
// fetch https://api.modrinth.com/v2/version/{version} to get json
|
||||
val client = HttpClient()
|
||||
val response = client.get("https://api.modrinth.com/v2/version/${versionObj.modrinthVersion}")
|
||||
val mrVersionString = response.body<String>()
|
||||
val json = Json { ignoreUnknownKeys = true }
|
||||
val mrVersion = json.decodeFromString<ModrinthVersion>(mrVersionString)
|
||||
call.respond(mrVersion.files[0])
|
||||
}
|
||||
get("/versions/{version}") {
|
||||
val version = call.parameters["version"] ?: return@get call.respond(
|
||||
HttpStatusCode.BadRequest,
|
||||
"message" to "Invalid version."
|
||||
)
|
||||
val versions = DB.getLibraryVersions()
|
||||
val versionObj = versions.find { it.version == version } ?: return@get call.respond(
|
||||
HttpStatusCode.NotFound,
|
||||
"message" to "Version not found."
|
||||
)
|
||||
call.respond(versionObj)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
18
src/main/kotlin/dev/frogmc/plugins/Serialization.kt
Normal file
18
src/main/kotlin/dev/frogmc/plugins/Serialization.kt
Normal file
|
@ -0,0 +1,18 @@
|
|||
package dev.frogmc.plugins
|
||||
|
||||
import io.ktor.serialization.kotlinx.json.*
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.plugins.contentnegotiation.*
|
||||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
fun Application.configureSerialization() {
|
||||
install(ContentNegotiation) {
|
||||
json()
|
||||
}
|
||||
routing {
|
||||
get("/json/kotlinx-serialization") {
|
||||
call.respond(mapOf("hello" to "world"))
|
||||
}
|
||||
}
|
||||
}
|
29
src/main/kotlin/dev/frogmc/types/Other.kt
Normal file
29
src/main/kotlin/dev/frogmc/types/Other.kt
Normal file
|
@ -0,0 +1,29 @@
|
|||
package dev.frogmc.types
|
||||
|
||||
import kotlinx.datetime.LocalDateTime
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@Serializable
|
||||
data class LoaderVersion(
|
||||
val version: String,
|
||||
val releaseDate: LocalDateTime,
|
||||
val downloadUrl: String
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class LibraryVersion(
|
||||
val version: String,
|
||||
val releaseDate: LocalDateTime,
|
||||
val modrinthVersion: String
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class ModrinthVersion(
|
||||
val files: List<ModrinthFile>
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class ModrinthFile(
|
||||
val url: String
|
||||
)
|
18
src/main/kotlin/dev/frogmc/types/Tables.kt
Normal file
18
src/main/kotlin/dev/frogmc/types/Tables.kt
Normal file
|
@ -0,0 +1,18 @@
|
|||
package dev.frogmc.types
|
||||
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
import org.jetbrains.exposed.sql.kotlin.datetime.datetime
|
||||
|
||||
object LoaderVersions : Table() {
|
||||
val version = text("version")
|
||||
val releaseDate = datetime("release_date")
|
||||
val downloadUrl = varchar("download_url", 255)
|
||||
override val primaryKey = PrimaryKey(version)
|
||||
}
|
||||
|
||||
object LibraryVersions : Table() {
|
||||
val version = text("version")
|
||||
val releaseDate = datetime("release_date")
|
||||
val modrinthVersion = text("mr_version")
|
||||
override val primaryKey = PrimaryKey(version)
|
||||
}
|
19
src/main/resources/logback.groovy
Normal file
19
src/main/resources/logback.groovy
Normal file
|
@ -0,0 +1,19 @@
|
|||
import ch.qos.logback.core.joran.spi.ConsoleTarget
|
||||
import ch.qos.logback.core.ConsoleAppender
|
||||
|
||||
def environment = System.getenv("ENVIRONMENT") ?: "production"
|
||||
|
||||
def defaultLevel = INFO
|
||||
def defaultTarget = ConsoleTarget.SystemErr
|
||||
|
||||
appender("CONSOLE", ConsoleAppender) {
|
||||
encoder(PatternLayoutEncoder) {
|
||||
pattern = "WAWA:: %boldGreen(%d{yyyy-MM-dd}) %boldYellow(%d{HH:mm:ss}) %gray(|) %highlight(%5level) %gray(|) %boldMagenta(%40.40logger{40}) %gray(|) %msg%n"
|
||||
|
||||
withJansi = true
|
||||
}
|
||||
|
||||
target = defaultTarget
|
||||
}
|
||||
|
||||
root(defaultLevel, ["CONSOLE"])
|
452
src/main/resources/logbackCompiler.groovy
Normal file
452
src/main/resources/logbackCompiler.groovy
Normal file
|
@ -0,0 +1,452 @@
|
|||
importsAcceptList = [
|
||||
'ch.qos.logback.core.testUtil.SampleConverter',
|
||||
|
||||
'ch.qos.logback.core.testUtil.StringListAppender',
|
||||
'java.lang.Object',
|
||||
'org.springframework.beans.factory.annotation.Autowired',
|
||||
'java.nio.charset.Charset.forName',
|
||||
'com.logentries.logback.LogentriesAppender',
|
||||
'grails.util.BuildSettings',
|
||||
'grails.util.Environment',
|
||||
'io.micronaut.context.env.Environment',
|
||||
'org.slf4j.MDC',
|
||||
'org.springframework.boot.logging.logback.ColorConverter',
|
||||
'org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter',
|
||||
'java.nio.charset.Charset',
|
||||
'java.nio.charset.StandardCharsets',
|
||||
|
||||
'ch.qos.logback.core.BasicStatusManager',
|
||||
'ch.qos.logback.core.ConsoleAppender',
|
||||
'ch.qos.logback.core.hook.ShutdownHook',
|
||||
'ch.qos.logback.core.hook.ShutdownHookBase',
|
||||
'ch.qos.logback.core.hook.DelayingShutdownHook',
|
||||
'ch.qos.logback.core.spi.PropertyContainer',
|
||||
'ch.qos.logback.core.spi.ContextAwareBase',
|
||||
'ch.qos.logback.core.spi.LogbackLock',
|
||||
'ch.qos.logback.core.spi.FilterAttachableImpl',
|
||||
'ch.qos.logback.core.spi.ContextAwareImpl',
|
||||
'ch.qos.logback.core.spi.ScanException',
|
||||
'ch.qos.logback.core.spi.DeferredProcessingAware',
|
||||
'ch.qos.logback.core.spi.ContextAware',
|
||||
'ch.qos.logback.core.spi.LifeCycle',
|
||||
'ch.qos.logback.core.spi.FilterReply',
|
||||
'ch.qos.logback.core.spi.PreSerializationTransformer',
|
||||
'ch.qos.logback.core.spi.AppenderAttachable',
|
||||
'ch.qos.logback.core.spi.CyclicBufferTracker',
|
||||
'ch.qos.logback.core.spi.FilterAttachable',
|
||||
'ch.qos.logback.core.spi.ComponentTracker',
|
||||
'ch.qos.logback.core.spi.AppenderAttachableImpl',
|
||||
'ch.qos.logback.core.spi.PropertyDefiner',
|
||||
'ch.qos.logback.core.spi.AbstractComponentTracker',
|
||||
'ch.qos.logback.core.property.FileExistsPropertyDefiner',
|
||||
'ch.qos.logback.core.property.ResourceExistsPropertyDefiner',
|
||||
'ch.qos.logback.core.CoreConstants',
|
||||
'ch.qos.logback.core.layout.EchoLayout',
|
||||
'ch.qos.logback.core.Appender',
|
||||
'ch.qos.logback.core.joran.JoranConfiguratorBase',
|
||||
'ch.qos.logback.core.joran.spi.ActionException',
|
||||
'ch.qos.logback.core.joran.spi.HostClassAndPropertyDouble',
|
||||
'ch.qos.logback.core.joran.spi.JoranException',
|
||||
'ch.qos.logback.core.joran.spi.NoAutoStart',
|
||||
'ch.qos.logback.core.joran.spi.EventPlayer',
|
||||
'ch.qos.logback.core.joran.spi.XMLUtil',
|
||||
'ch.qos.logback.core.joran.spi.ConsoleTarget',
|
||||
'ch.qos.logback.core.joran.spi.Interpreter',
|
||||
'ch.qos.logback.core.joran.spi.SimpleRuleStore',
|
||||
'ch.qos.logback.core.joran.spi.InterpretationContext',
|
||||
'ch.qos.logback.core.joran.spi.RuleStore',
|
||||
'ch.qos.logback.core.joran.spi.NoAutoStartUtil',
|
||||
'ch.qos.logback.core.joran.spi.ElementSelector',
|
||||
'ch.qos.logback.core.joran.spi.ConfigurationWatchList',
|
||||
'ch.qos.logback.core.joran.spi.DefaultNestedComponentRegistry',
|
||||
'ch.qos.logback.core.joran.spi.DefaultClass',
|
||||
'ch.qos.logback.core.joran.spi.ElementPath',
|
||||
'ch.qos.logback.core.joran.conditional.ThenOrElseActionBase',
|
||||
'ch.qos.logback.core.joran.conditional.Condition',
|
||||
'ch.qos.logback.core.joran.conditional.PropertyWrapperForScripts',
|
||||
'ch.qos.logback.core.joran.conditional.ThenAction',
|
||||
'ch.qos.logback.core.joran.conditional.PropertyEvalScriptBuilder',
|
||||
'ch.qos.logback.core.joran.conditional.ElseAction',
|
||||
'ch.qos.logback.core.joran.conditional.IfAction',
|
||||
'ch.qos.logback.core.joran.util.beans.BeanDescriptionCache',
|
||||
'ch.qos.logback.core.joran.util.beans.BeanDescriptionFactory',
|
||||
'ch.qos.logback.core.joran.util.beans.BeanDescription',
|
||||
'ch.qos.logback.core.joran.util.beans.BeanUtil',
|
||||
'ch.qos.logback.core.joran.util.PropertySetter',
|
||||
'ch.qos.logback.core.joran.util.ConfigurationWatchListUtil',
|
||||
'ch.qos.logback.core.joran.util.StringToObjectConverter',
|
||||
'ch.qos.logback.core.joran.GenericConfigurator',
|
||||
'ch.qos.logback.core.joran.action.ImplicitAction',
|
||||
'ch.qos.logback.core.joran.action.IncludeAction',
|
||||
'ch.qos.logback.core.joran.action.NOPAction',
|
||||
'ch.qos.logback.core.joran.action.IADataForBasicProperty',
|
||||
'ch.qos.logback.core.joran.action.TimestampAction',
|
||||
'ch.qos.logback.core.joran.action.AbstractEventEvaluatorAction',
|
||||
'ch.qos.logback.core.joran.action.ParamAction',
|
||||
'ch.qos.logback.core.joran.action.AppenderAction',
|
||||
'ch.qos.logback.core.joran.action.DefinePropertyAction',
|
||||
'ch.qos.logback.core.joran.action.StatusListenerAction',
|
||||
'ch.qos.logback.core.joran.action.ContextPropertyAction',
|
||||
'ch.qos.logback.core.joran.action.NestedComplexPropertyIA',
|
||||
'ch.qos.logback.core.joran.action.NestedBasicPropertyIA',
|
||||
'ch.qos.logback.core.joran.action.Action',
|
||||
'ch.qos.logback.core.joran.action.AppenderRefAction',
|
||||
'ch.qos.logback.core.joran.action.ActionUtil',
|
||||
'ch.qos.logback.core.joran.action.ShutdownHookAction',
|
||||
'ch.qos.logback.core.joran.action.IADataForComplexProperty',
|
||||
'ch.qos.logback.core.joran.action.ConversionRuleAction',
|
||||
'ch.qos.logback.core.joran.action.ActionConst',
|
||||
'ch.qos.logback.core.joran.action.PropertyAction',
|
||||
'ch.qos.logback.core.joran.action.NewRuleAction',
|
||||
'ch.qos.logback.core.joran.node.ComponentNode',
|
||||
'ch.qos.logback.core.joran.event.EndEvent',
|
||||
'ch.qos.logback.core.joran.event.SaxEventRecorder',
|
||||
'ch.qos.logback.core.joran.event.SaxEvent',
|
||||
'ch.qos.logback.core.joran.event.BodyEvent',
|
||||
'ch.qos.logback.core.joran.event.StartEvent',
|
||||
'ch.qos.logback.core.joran.event.InPlayListener',
|
||||
'ch.qos.logback.core.joran.event.stax.EndEvent',
|
||||
'ch.qos.logback.core.joran.event.stax.StaxEventRecorder',
|
||||
'ch.qos.logback.core.joran.event.stax.BodyEvent',
|
||||
'ch.qos.logback.core.joran.event.stax.StartEvent',
|
||||
'ch.qos.logback.core.joran.event.stax.StaxEvent',
|
||||
'ch.qos.logback.core.LogbackException',
|
||||
'ch.qos.logback.core.PropertyDefinerBase',
|
||||
'ch.qos.logback.core.helpers.CyclicBuffer',
|
||||
'ch.qos.logback.core.helpers.ThrowableToStringArray',
|
||||
'ch.qos.logback.core.helpers.Transform',
|
||||
'ch.qos.logback.core.helpers.NOPAppender',
|
||||
'ch.qos.logback.core.net.LoginAuthenticator',
|
||||
'ch.qos.logback.core.net.DefaultSocketConnector',
|
||||
'ch.qos.logback.core.net.ssl.KeyStoreFactoryBean',
|
||||
'ch.qos.logback.core.net.ssl.SSLParametersConfiguration',
|
||||
'ch.qos.logback.core.net.ssl.SSLComponent',
|
||||
'ch.qos.logback.core.net.ssl.SSLNestedComponentRegistryRules',
|
||||
'ch.qos.logback.core.net.ssl.SSLConfigurableSocket',
|
||||
'ch.qos.logback.core.net.ssl.SSLConfigurableServerSocket',
|
||||
'ch.qos.logback.core.net.ssl.SSLConfiguration',
|
||||
'ch.qos.logback.core.net.ssl.ConfigurableSSLSocketFactory',
|
||||
'ch.qos.logback.core.net.ssl.ConfigurableSSLServerSocketFactory',
|
||||
'ch.qos.logback.core.net.ssl.SecureRandomFactoryBean',
|
||||
'ch.qos.logback.core.net.ssl.SSLContextFactoryBean',
|
||||
'ch.qos.logback.core.net.ssl.SSL',
|
||||
'ch.qos.logback.core.net.ssl.SSLConfigurable',
|
||||
'ch.qos.logback.core.net.ssl.TrustManagerFactoryFactoryBean',
|
||||
'ch.qos.logback.core.net.ssl.KeyManagerFactoryFactoryBean',
|
||||
'ch.qos.logback.core.net.SMTPAppenderBase',
|
||||
'ch.qos.logback.core.net.SyslogAppenderBase',
|
||||
'ch.qos.logback.core.net.SocketConnector',
|
||||
'ch.qos.logback.core.net.SyslogOutputStream',
|
||||
'ch.qos.logback.core.net.QueueFactory',
|
||||
'ch.qos.logback.core.net.HardenedObjectInputStream',
|
||||
'ch.qos.logback.core.net.AbstractSocketAppender',
|
||||
'ch.qos.logback.core.net.AbstractSSLSocketAppender',
|
||||
'ch.qos.logback.core.net.ObjectWriterFactory',
|
||||
'ch.qos.logback.core.net.ObjectWriter',
|
||||
'ch.qos.logback.core.net.AutoFlushingObjectWriter',
|
||||
'ch.qos.logback.core.net.SyslogConstants',
|
||||
'ch.qos.logback.core.net.server.ServerRunner',
|
||||
'ch.qos.logback.core.net.server.Client',
|
||||
'ch.qos.logback.core.net.server.ServerListener',
|
||||
'ch.qos.logback.core.net.server.RemoteReceiverStreamClient',
|
||||
'ch.qos.logback.core.net.server.AbstractServerSocketAppender',
|
||||
'ch.qos.logback.core.net.server.ClientVisitor',
|
||||
'ch.qos.logback.core.net.server.RemoteReceiverClient',
|
||||
'ch.qos.logback.core.net.server.RemoteReceiverServerRunner',
|
||||
'ch.qos.logback.core.net.server.SSLServerSocketAppenderBase',
|
||||
'ch.qos.logback.core.net.server.ConcurrentServerRunner',
|
||||
'ch.qos.logback.core.net.server.ServerSocketListener',
|
||||
'ch.qos.logback.core.net.server.RemoteReceiverServerListener',
|
||||
'ch.qos.logback.core.UnsynchronizedAppenderBase',
|
||||
'ch.qos.logback.core.AsyncAppenderBase',
|
||||
'ch.qos.logback.core.util.CloseUtil',
|
||||
'ch.qos.logback.core.util.DatePatternToRegexUtil',
|
||||
'ch.qos.logback.core.util.StatusListenerConfigHelper',
|
||||
'ch.qos.logback.core.util.SystemInfo',
|
||||
'ch.qos.logback.core.util.DefaultInvocationGate',
|
||||
'ch.qos.logback.core.util.CachingDateFormatter',
|
||||
'ch.qos.logback.core.util.InterruptUtil',
|
||||
'ch.qos.logback.core.util.LocationUtil',
|
||||
'ch.qos.logback.core.util.TimeUtil',
|
||||
'ch.qos.logback.core.util.COWArrayList',
|
||||
'ch.qos.logback.core.util.Loader',
|
||||
'ch.qos.logback.core.util.CharSequenceState',
|
||||
'ch.qos.logback.core.util.StatusPrinter',
|
||||
'ch.qos.logback.core.util.Duration',
|
||||
'ch.qos.logback.core.util.ContentTypeUtil',
|
||||
'ch.qos.logback.core.util.FileUtil',
|
||||
'ch.qos.logback.core.util.DynamicClassLoadingException',
|
||||
'ch.qos.logback.core.util.InvocationGate',
|
||||
'ch.qos.logback.core.util.OptionHelper',
|
||||
'ch.qos.logback.core.util.IncompatibleClassException',
|
||||
'ch.qos.logback.core.util.ExecutorServiceUtil',
|
||||
'ch.qos.logback.core.util.StringCollectionUtil',
|
||||
'ch.qos.logback.core.util.CharSequenceToRegexMapper',
|
||||
'ch.qos.logback.core.util.FixedDelay',
|
||||
'ch.qos.logback.core.util.FileSize',
|
||||
'ch.qos.logback.core.util.DelayStrategy',
|
||||
'ch.qos.logback.core.util.EnvUtil',
|
||||
'ch.qos.logback.core.util.ContextUtil',
|
||||
'ch.qos.logback.core.util.AggregationType',
|
||||
'ch.qos.logback.core.util.PropertySetterException',
|
||||
'ch.qos.logback.core.LifeCycleManager',
|
||||
'ch.qos.logback.core.LayoutBase',
|
||||
'ch.qos.logback.core.encoder.NonClosableInputStream',
|
||||
'ch.qos.logback.core.encoder.Encoder',
|
||||
'ch.qos.logback.core.encoder.ByteArrayUtil',
|
||||
'ch.qos.logback.core.encoder.EncoderBase',
|
||||
'ch.qos.logback.core.encoder.EchoEncoder',
|
||||
'ch.qos.logback.core.encoder.LayoutWrappingEncoder',
|
||||
'ch.qos.logback.core.recovery.RecoveryCoordinator',
|
||||
'ch.qos.logback.core.recovery.ResilientOutputStreamBase',
|
||||
'ch.qos.logback.core.recovery.ResilientSyslogOutputStream',
|
||||
'ch.qos.logback.core.recovery.ResilientFileOutputStream',
|
||||
'ch.qos.logback.core.AppenderBase',
|
||||
'ch.qos.logback.core.subst.Node',
|
||||
'ch.qos.logback.core.subst.Parser',
|
||||
'ch.qos.logback.core.subst.Token',
|
||||
'ch.qos.logback.core.subst.NodeToStringTransformer',
|
||||
'ch.qos.logback.core.subst.Tokenizer',
|
||||
'ch.qos.logback.core.FileAppender',
|
||||
'ch.qos.logback.core.sift.AppenderFactory',
|
||||
'ch.qos.logback.core.sift.SiftingAppenderBase',
|
||||
'ch.qos.logback.core.sift.SiftingJoranConfiguratorBase',
|
||||
'ch.qos.logback.core.sift.AbstractDiscriminator',
|
||||
'ch.qos.logback.core.sift.Discriminator',
|
||||
'ch.qos.logback.core.sift.AbstractAppenderFactoryUsingJoran',
|
||||
'ch.qos.logback.core.sift.AppenderTracker',
|
||||
'ch.qos.logback.core.sift.DefaultDiscriminator',
|
||||
'ch.qos.logback.core.html.CssBuilder',
|
||||
'ch.qos.logback.core.html.NOPThrowableRenderer',
|
||||
'ch.qos.logback.core.html.HTMLLayoutBase',
|
||||
'ch.qos.logback.core.html.IThrowableRenderer',
|
||||
'ch.qos.logback.core.rolling.TriggeringPolicyBase',
|
||||
'ch.qos.logback.core.rolling.helper.Compressor',
|
||||
'ch.qos.logback.core.rolling.helper.PeriodicityType',
|
||||
'ch.qos.logback.core.rolling.helper.TokenConverter',
|
||||
'ch.qos.logback.core.rolling.helper.IntegerTokenConverter',
|
||||
'ch.qos.logback.core.rolling.helper.CompressionMode',
|
||||
'ch.qos.logback.core.rolling.helper.ArchiveRemover',
|
||||
'ch.qos.logback.core.rolling.helper.FileFilterUtil',
|
||||
'ch.qos.logback.core.rolling.helper.RenameUtil',
|
||||
'ch.qos.logback.core.rolling.helper.DateTokenConverter',
|
||||
'ch.qos.logback.core.rolling.helper.FileNamePattern',
|
||||
'ch.qos.logback.core.rolling.helper.RollingCalendar',
|
||||
'ch.qos.logback.core.rolling.helper.FileStoreUtil',
|
||||
'ch.qos.logback.core.rolling.helper.SizeAndTimeBasedArchiveRemover',
|
||||
'ch.qos.logback.core.rolling.helper.TimeBasedArchiveRemover',
|
||||
'ch.qos.logback.core.rolling.helper.MonoTypedConverter',
|
||||
'ch.qos.logback.core.rolling.RollingPolicyBase',
|
||||
'ch.qos.logback.core.rolling.RollingFileAppender',
|
||||
'ch.qos.logback.core.rolling.FixedWindowRollingPolicy',
|
||||
'ch.qos.logback.core.rolling.TimeBasedFileNamingAndTriggeringPolicyBase',
|
||||
'ch.qos.logback.core.rolling.TimeBasedFileNamingAndTriggeringPolicy',
|
||||
'ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy',
|
||||
'ch.qos.logback.core.rolling.RollingPolicy',
|
||||
'ch.qos.logback.core.rolling.TimeBasedRollingPolicy',
|
||||
'ch.qos.logback.core.rolling.DefaultTimeBasedFileNamingAndTriggeringPolicy',
|
||||
'ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy',
|
||||
'ch.qos.logback.core.rolling.RolloverFailure',
|
||||
'ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP',
|
||||
'ch.qos.logback.core.rolling.TriggeringPolicy',
|
||||
'ch.qos.logback.core.pattern.ReplacingCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.ConverterUtil',
|
||||
'ch.qos.logback.core.pattern.parser.Compiler',
|
||||
'ch.qos.logback.core.pattern.parser.Node',
|
||||
'ch.qos.logback.core.pattern.parser.Parser',
|
||||
'ch.qos.logback.core.pattern.parser.Token',
|
||||
'ch.qos.logback.core.pattern.parser.OptionTokenizer',
|
||||
'ch.qos.logback.core.pattern.parser.TokenStream',
|
||||
'ch.qos.logback.core.pattern.parser.CompositeNode',
|
||||
'ch.qos.logback.core.pattern.parser.FormattingNode',
|
||||
'ch.qos.logback.core.pattern.parser.SimpleKeywordNode',
|
||||
'ch.qos.logback.core.pattern.Converter',
|
||||
'ch.qos.logback.core.pattern.PatternLayoutEncoderBase',
|
||||
'ch.qos.logback.core.pattern.LiteralConverter',
|
||||
'ch.qos.logback.core.pattern.PostCompileProcessor',
|
||||
'ch.qos.logback.core.pattern.util.RegularEscapeUtil',
|
||||
'ch.qos.logback.core.pattern.util.AsIsEscapeUtil',
|
||||
'ch.qos.logback.core.pattern.util.AlmostAsIsEscapeUtil',
|
||||
'ch.qos.logback.core.pattern.util.IEscapeUtil',
|
||||
'ch.qos.logback.core.pattern.util.RestrictedEscapeUtil',
|
||||
'ch.qos.logback.core.pattern.SpacePadder',
|
||||
'ch.qos.logback.core.pattern.CompositeConverter',
|
||||
'ch.qos.logback.core.pattern.PatternLayoutBase',
|
||||
'ch.qos.logback.core.pattern.DynamicConverter',
|
||||
'ch.qos.logback.core.pattern.color.YellowCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.ANSIConstants',
|
||||
'ch.qos.logback.core.pattern.color.BoldYellowCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.BoldBlueCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.BoldWhiteCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.CyanCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.MagentaCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.BlueCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.BlackCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.ForegroundCompositeConverterBase',
|
||||
'ch.qos.logback.core.pattern.color.GrayCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.BoldMagentaCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.BoldCyanCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.RedCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.BoldGreenCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.BoldRedCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.GreenCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.color.WhiteCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.FormattingConverter',
|
||||
'ch.qos.logback.core.pattern.IdentityCompositeConverter',
|
||||
'ch.qos.logback.core.pattern.FormatInfo',
|
||||
'ch.qos.logback.core.OutputStreamAppender',
|
||||
'ch.qos.logback.core.boolex.JaninoEventEvaluatorBase',
|
||||
'ch.qos.logback.core.boolex.Matcher',
|
||||
'ch.qos.logback.core.boolex.EventEvaluatorBase',
|
||||
'ch.qos.logback.core.boolex.EvaluationException',
|
||||
'ch.qos.logback.core.boolex.EventEvaluator',
|
||||
'ch.qos.logback.core.read.CyclicBufferAppender',
|
||||
'ch.qos.logback.core.read.ListAppender',
|
||||
'ch.qos.logback.core.Context',
|
||||
'ch.qos.logback.core.ContextBase',
|
||||
'ch.qos.logback.core.status.StatusListenerAsList',
|
||||
'ch.qos.logback.core.status.StatusBase',
|
||||
'ch.qos.logback.core.status.NopStatusListener',
|
||||
'ch.qos.logback.core.status.StatusUtil',
|
||||
'ch.qos.logback.core.status.OnPrintStreamStatusListenerBase',
|
||||
'ch.qos.logback.core.status.StatusManager',
|
||||
'ch.qos.logback.core.status.ViewStatusMessagesServletBase',
|
||||
'ch.qos.logback.core.status.ErrorStatus',
|
||||
'ch.qos.logback.core.status.Status',
|
||||
'ch.qos.logback.core.status.StatusListener',
|
||||
'ch.qos.logback.core.status.InfoStatus',
|
||||
'ch.qos.logback.core.status.OnConsoleStatusListener',
|
||||
'ch.qos.logback.core.status.WarnStatus',
|
||||
'ch.qos.logback.core.status.OnErrorConsoleStatusListener',
|
||||
'ch.qos.logback.core.filter.EvaluatorFilter',
|
||||
'ch.qos.logback.core.filter.Filter',
|
||||
'ch.qos.logback.core.filter.AbstractMatcherFilter',
|
||||
'ch.qos.logback.core.Layout',
|
||||
'ch.qos.logback.classic.ViewStatusMessagesServlet',
|
||||
'ch.qos.logback.classic.ClassicConstants',
|
||||
'ch.qos.logback.classic.layout.TTLLLayout',
|
||||
'ch.qos.logback.classic.helpers.MDCInsertingServletFilter',
|
||||
'ch.qos.logback.classic.Level',
|
||||
'ch.qos.logback.classic.Level.off',
|
||||
'ch.qos.logback.classic.Level.error',
|
||||
'ch.qos.logback.classic.Level.warn',
|
||||
'ch.qos.logback.classic.Level.info',
|
||||
'ch.qos.logback.classic.Level.debug',
|
||||
'ch.qos.logback.classic.Level.trace',
|
||||
'ch.qos.logback.classic.Level.all,',
|
||||
'ch.qos.logback.classic.net.SSLSocketReceiver',
|
||||
'ch.qos.logback.classic.net.ReceiverBase',
|
||||
'ch.qos.logback.classic.net.SimpleSocketServer',
|
||||
'ch.qos.logback.classic.net.SimpleSSLSocketServer',
|
||||
'ch.qos.logback.classic.net.SocketNode',
|
||||
'ch.qos.logback.classic.net.SMTPAppender',
|
||||
'ch.qos.logback.classic.net.SocketReceiver',
|
||||
'ch.qos.logback.classic.net.SocketAcceptor',
|
||||
'ch.qos.logback.classic.net.SSLSocketAppender',
|
||||
'ch.qos.logback.classic.net.LoggingEventPreSerializationTransformer',
|
||||
'ch.qos.logback.classic.net.server.RemoteAppenderStreamClient',
|
||||
'ch.qos.logback.classic.net.server.RemoteAppenderServerListener',
|
||||
'ch.qos.logback.classic.net.server.SSLServerSocketAppender',
|
||||
'ch.qos.logback.classic.net.server.RemoteAppenderClient',
|
||||
'ch.qos.logback.classic.net.server.HardenedLoggingEventInputStream',
|
||||
'ch.qos.logback.classic.net.server.ServerSocketAppender',
|
||||
'ch.qos.logback.classic.net.server.SSLServerSocketReceiver',
|
||||
'ch.qos.logback.classic.net.server.RemoteAppenderServerRunner',
|
||||
'ch.qos.logback.classic.net.server.ServerSocketReceiver',
|
||||
'ch.qos.logback.classic.net.SocketAppender',
|
||||
'ch.qos.logback.classic.net.SyslogAppender',
|
||||
'ch.qos.logback.classic.PatternLayout',
|
||||
'ch.qos.logback.classic.util.ContextSelectorStaticBinder',
|
||||
'ch.qos.logback.classic.util.StatusViaSLF4JLoggerFactory',
|
||||
'ch.qos.logback.classic.util.JNDIUtil',
|
||||
'ch.qos.logback.classic.util.LevelToSyslogSeverity',
|
||||
'ch.qos.logback.classic.util.LoggerNameUtil',
|
||||
'ch.qos.logback.classic.util.LogbackMDCAdapter',
|
||||
'ch.qos.logback.classic.util.CopyOnInheritThreadLocal',
|
||||
'ch.qos.logback.classic.util.ContextInitializer',
|
||||
'ch.qos.logback.classic.util.EnvUtil',
|
||||
'ch.qos.logback.classic.util.DefaultNestedComponentRules',
|
||||
'ch.qos.logback.classic.AsyncAppender',
|
||||
'ch.qos.logback.classic.jul.JULHelper',
|
||||
'ch.qos.logback.classic.jul.LevelChangePropagator',
|
||||
'ch.qos.logback.classic.encoder.PatternLayoutEncoder',
|
||||
'ch.qos.logback.classic.db.names.DBNameResolver',
|
||||
'ch.qos.logback.classic.db.names.ColumnName',
|
||||
'ch.qos.logback.classic.db.names.TableName',
|
||||
'ch.qos.logback.classic.db.names.DefaultDBNameResolver',
|
||||
'ch.qos.logback.classic.db.names.SimpleDBNameResolver',
|
||||
'ch.qos.logback.classic.log4j.XMLLayout',
|
||||
'ch.qos.logback.classic.LoggerContext',
|
||||
'ch.qos.logback.classic.turbo.TurboFilter',
|
||||
'ch.qos.logback.classic.turbo.MDCFilter',
|
||||
'ch.qos.logback.classic.turbo.ReconfigureOnChangeFilter',
|
||||
'ch.qos.logback.classic.turbo.DuplicateMessageFilter',
|
||||
'ch.qos.logback.classic.turbo.MarkerFilter',
|
||||
'ch.qos.logback.classic.turbo.MDCValueLevelPair',
|
||||
'ch.qos.logback.classic.turbo.DynamicThresholdFilter',
|
||||
'ch.qos.logback.classic.turbo.MatchingFilter',
|
||||
'ch.qos.logback.classic.turbo.LRUMessageCache',
|
||||
'ch.qos.logback.classic.selector.servlet.LoggerContextFilter',
|
||||
'ch.qos.logback.classic.selector.servlet.ContextDetachingSCL',
|
||||
'ch.qos.logback.classic.selector.ContextJNDISelector',
|
||||
'ch.qos.logback.classic.selector.DefaultContextSelector',
|
||||
'ch.qos.logback.classic.selector.ContextSelector',
|
||||
'ch.qos.logback.classic.sift.MDCBasedDiscriminator',
|
||||
'ch.qos.logback.classic.sift.SiftingJoranConfigurator',
|
||||
'ch.qos.logback.classic.sift.JNDIBasedContextDiscriminator',
|
||||
'ch.qos.logback.classic.sift.AppenderFactoryUsingJoran',
|
||||
'ch.qos.logback.classic.sift.ContextBasedDiscriminator',
|
||||
'ch.qos.logback.classic.sift.SiftingAppender',
|
||||
'ch.qos.logback.classic.sift.SiftAction',
|
||||
'ch.qos.logback.classic.html.UrlCssBuilder',
|
||||
'ch.qos.logback.classic.html.HTMLLayout',
|
||||
'ch.qos.logback.classic.html.DefaultCssBuilder',
|
||||
'ch.qos.logback.classic.html.DefaultThrowableRenderer',
|
||||
'ch.qos.logback.classic.Logger',
|
||||
'ch.qos.logback.classic.pattern.ThrowableHandlingConverter',
|
||||
'ch.qos.logback.classic.pattern.ContextNameConverter',
|
||||
'ch.qos.logback.classic.pattern.LocalSequenceNumberConverter',
|
||||
'ch.qos.logback.classic.pattern.ClassOfCallerConverter',
|
||||
'ch.qos.logback.classic.pattern.PrefixCompositeConverter',
|
||||
'ch.qos.logback.classic.pattern.LineOfCallerConverter',
|
||||
'ch.qos.logback.classic.pattern.EnsureExceptionHandling',
|
||||
'ch.qos.logback.classic.pattern.TargetLengthBasedClassNameAbbreviator',
|
||||
'ch.qos.logback.classic.pattern.FileOfCallerConverter',
|
||||
'ch.qos.logback.classic.pattern.LevelConverter',
|
||||
'ch.qos.logback.classic.pattern.ExtendedThrowableProxyConverter',
|
||||
'ch.qos.logback.classic.pattern.NamedConverter',
|
||||
'ch.qos.logback.classic.pattern.ClassicConverter',
|
||||
'ch.qos.logback.classic.pattern.NopThrowableInformationConverter',
|
||||
'ch.qos.logback.classic.pattern.RootCauseFirstThrowableProxyConverter',
|
||||
'ch.qos.logback.classic.pattern.MethodOfCallerConverter',
|
||||
'ch.qos.logback.classic.pattern.CallerDataConverter',
|
||||
'ch.qos.logback.classic.pattern.ClassNameOnlyAbbreviator',
|
||||
'ch.qos.logback.classic.pattern.MarkerConverter',
|
||||
'ch.qos.logback.classic.pattern.RelativeTimeConverter',
|
||||
'ch.qos.logback.classic.pattern.DateConverter',
|
||||
'ch.qos.logback.classic.pattern.PropertyConverter',
|
||||
'ch.qos.logback.classic.pattern.ThreadConverter',
|
||||
'ch.qos.logback.classic.pattern.LineSeparatorConverter',
|
||||
'ch.qos.logback.classic.pattern.MDCConverter',
|
||||
'ch.qos.logback.classic.pattern.color.HighlightingCompositeConverter',
|
||||
'ch.qos.logback.classic.pattern.ThrowableProxyConverter',
|
||||
'ch.qos.logback.classic.pattern.Abbreviator',
|
||||
'ch.qos.logback.classic.pattern.Util',
|
||||
'ch.qos.logback.classic.pattern.LoggerConverter',
|
||||
'ch.qos.logback.classic.pattern.SyslogStartConverter',
|
||||
'ch.qos.logback.classic.pattern.MessageConverter',
|
||||
'ch.qos.logback.classic.gaffer.GafferUtil',
|
||||
'ch.qos.logback.classic.boolex.OnMarkerEvaluator',
|
||||
'ch.qos.logback.classic.boolex.JaninoEventEvaluator',
|
||||
'ch.qos.logback.classic.boolex.OnErrorEvaluator',
|
||||
'ch.qos.logback.classic.boolex.GEventEvaluator',
|
||||
'ch.qos.logback.classic.boolex.IEvaluator',
|
||||
'ch.qos.logback.classic.filter.ThresholdFilter',
|
||||
'ch.qos.logback.classic.filter.LevelFilter',
|
||||
'java.lang.System',
|
||||
'java.lang.System.getenv',
|
||||
'java.lang.System.getProperty',
|
||||
'java.lang.System.getenv',
|
||||
'java.util.Map.getOrDefault',
|
||||
'com.kotlindiscord.kord.extensions.utils._EnvironmentKt.envOrNull',
|
||||
]
|
7
src/main/resources/static/index.html
Normal file
7
src/main/resources/static/index.html
Normal file
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hello Ktor!</h1>
|
||||
</body>
|
||||
</html>
|
28
src/main/resources/static/style.css
Normal file
28
src/main/resources/static/style.css
Normal file
|
@ -0,0 +1,28 @@
|
|||
@import url("https://unpkg.com/@catppuccin/palette/css/catppuccin.css");
|
||||
|
||||
:root {
|
||||
background-color: var(--ctp-mocha-base);
|
||||
color: var(--ctp-mocha-text);
|
||||
font-family: sans-serif;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
body {
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
div.routes {
|
||||
justify-content: center;
|
||||
margin-top: 1em;
|
||||
padding: 1em;
|
||||
background-color: var(--ctp-mocha-surface0);
|
||||
max-width: 400px;
|
||||
margin-left: 38.5%;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
div.route {
|
||||
background-color: var(--ctp-mocha-surface1);
|
||||
padding: 5px;
|
||||
border-radius: 10px;
|
||||
}
|
21
src/test/kotlin/dev/frogmc/ApplicationTest.kt
Normal file
21
src/test/kotlin/dev/frogmc/ApplicationTest.kt
Normal file
|
@ -0,0 +1,21 @@
|
|||
package dev.frogmc
|
||||
|
||||
import dev.frogmc.plugins.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.statement.*
|
||||
import io.ktor.http.*
|
||||
import io.ktor.server.testing.*
|
||||
import kotlin.test.*
|
||||
|
||||
class ApplicationTest {
|
||||
@Test
|
||||
fun testRoot() = testApplication {
|
||||
application {
|
||||
configureRouting()
|
||||
}
|
||||
client.get("/").apply {
|
||||
assertEquals(HttpStatusCode.OK, status)
|
||||
assertEquals("Hello World!", bodyAsText())
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue