Skip to content

Commit

Permalink
chore: Updating everything
Browse files Browse the repository at this point in the history
  • Loading branch information
LichtHund committed Oct 1, 2023
1 parent 89b534f commit 45be65c
Show file tree
Hide file tree
Showing 24 changed files with 315 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("docsly.base-conventions")
id("docsly.base")
}

dependencies {
Expand Down
31 changes: 29 additions & 2 deletions app/src/main/kotlin/Application.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,42 @@
/**
* MIT License
*
* Copyright (c) 2019-2022 TriumphTeam and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.triumphteam.docsly

import com.zaxxer.hikari.HikariDataSource
import dev.triumphteam.docsly.config.createOrGetConfig
import dev.triumphteam.docsly.meilisearch.Meili
import dev.triumphteam.docsly.meilisearch.search
import dev.triumphteam.docsly.resource.Api
import io.ktor.server.application.Application
import io.ktor.server.application.install
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
import io.ktor.server.resources.Resources
import io.ktor.server.resources.get
import io.ktor.server.routing.get
import io.ktor.server.routing.routing
import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.transactions.transaction

private val config = createOrGetConfig()

Expand All @@ -31,7 +55,10 @@ public fun Application.module() {
// Here you handle the "api/{index}/search" endpoint

// Getting the index passed
search<String>(it.parent.index, "")
// search<String>(it.parent.index, "")
transaction {
// DocDao.find { DocsTable.name eq "Ass" }.firstOrNull()
}
}
}
}
23 changes: 23 additions & 0 deletions app/src/main/kotlin/config/Configuration.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/**
* MIT License
*
* Copyright (c) 2019-2022 TriumphTeam and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.triumphteam.docsly.config

import com.typesafe.config.ConfigFactory
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/kotlin/config/serializer/ProtocolSerializer.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/**
* MIT License
*
* Copyright (c) 2019-2022 TriumphTeam and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.triumphteam.docsly.config.serializer

import io.ktor.http.URLProtocol
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/kotlin/database/Tables.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/**
* MIT License
*
* Copyright (c) 2019-2022 TriumphTeam and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.triumphteam.docsly.database

import org.jetbrains.exposed.dao.id.IntIdTable
Expand Down
25 changes: 24 additions & 1 deletion app/src/main/kotlin/database/exposed/EnumSetColumn.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/**
* MIT License
*
* Copyright (c) 2019-2022 TriumphTeam and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.triumphteam.docsly.database.exposed

import com.impossibl.postgres.jdbc.PGArray
Expand All @@ -10,7 +33,7 @@ import org.jetbrains.exposed.sql.vendors.currentDialect
import kotlin.reflect.KClass

public inline fun <reified T : Enum<T>> Table.enumerationSet(name: String): Column<Set<T>> =
registerColumn<Set<T>>(name, EnumSetColumnType(T::class))
registerColumn(name, EnumSetColumnType(T::class))

public class EnumSetColumnType<T : Enum<T>>(private val klass: KClass<T>) : ColumnType() {

Expand Down
25 changes: 24 additions & 1 deletion app/src/main/kotlin/database/exposed/SerializableColumn.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/**
* MIT License
*
* Copyright (c) 2019-2022 TriumphTeam and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.triumphteam.docsly.database.exposed

import com.impossibl.postgres.jdbc.PGArray
Expand Down Expand Up @@ -37,7 +60,7 @@ public class SerializableColumnType<T : Any>(
}

public inline fun <reified T : Any> Table.serializableList(name: String, serializer: KSerializer<T>): Column<List<T>> =
registerColumn<List<T>>(name, SerializableListColumnType(T::class, ListSerializer(serializer)))
registerColumn(name, SerializableListColumnType(T::class, ListSerializer(serializer)))

@Suppress("UNCHECKED_CAST")
public class SerializableListColumnType<T : Any>(
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/kotlin/meilisearch/ApiAuthProvider.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/**
* MIT License
*
* Copyright (c) 2019-2022 TriumphTeam and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.triumphteam.docsly.meilisearch

import io.ktor.client.plugins.auth.Auth
Expand Down
25 changes: 24 additions & 1 deletion app/src/main/kotlin/meilisearch/MeiliClient.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/**
* MIT License
*
* Copyright (c) 2019-2022 TriumphTeam and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.triumphteam.docsly.meilisearch

import dev.triumphteam.docsly.meilisearch.annotation.PrimaryKey
Expand Down Expand Up @@ -72,7 +95,7 @@ public class MeiliClient(

/** [search] but returns all the data ([SearchResult]) provided by the search. */
public suspend inline fun <reified T> searchFull(query: String, filter: Map<String, String>): SearchResult<T> {
// TODO: Handle errors
// TODO: Handle errors.
return client.post(Indexes.Uid.Search(Indexes.Uid(uid = uid))) {
setBody(SearchRequest(query, filter))
}.body()
Expand Down
31 changes: 27 additions & 4 deletions app/src/main/kotlin/meilisearch/MeiliPlugin.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/**
* MIT License
*
* Copyright (c) 2019-2022 TriumphTeam and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.triumphteam.docsly.meilisearch

import dev.triumphteam.docsly.config.MeiliConfig
Expand All @@ -15,10 +38,10 @@ public class Meili(config: Configuration) {
public val client: MeiliClient = config.createClient()

public class Configuration {
public var host: String = "0.0.0.0"
public var port: Int = 7700
public var apiKey: String = "masterKey"
public var protocol: URLProtocol = URLProtocol.HTTP
private var host: String = "0.0.0.0"
private var port: Int = 7700
private var apiKey: String = "masterKey"
private var protocol: URLProtocol = URLProtocol.HTTP

public fun config(config: MeiliConfig) {
host = config.host
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/kotlin/meilisearch/annotation/PrimaryKey.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/**
* MIT License
*
* Copyright (c) 2019-2022 TriumphTeam and Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package dev.triumphteam.docsly.meilisearch.annotation

@Retention(AnnotationRetention.RUNTIME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repositories {
}

dependencies {
implementation(kotlin("stdlib"))
api(kotlin("stdlib"))
api(libs.kotlinx.serialization.json)
api(libs.kotlinx.coroutines)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
signing
}

val dokkaOutputDir = "$buildDir/dokka"
val dokkaOutputDir = "${layout.buildDirectory}/dokka"

tasks {
dokkaHtml {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
plugins {
id("docsly.parent-conventions")
id("docsly.parent")
}
2 changes: 1 addition & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("docsly.base-conventions")
id("docsly.base")
}

dependencies {
Expand Down
Loading

0 comments on commit 45be65c

Please sign in to comment.