@devkong/cli-nx 0.0.44 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/generators/preset/files/kotlin/build.gradle.kts.template +6 -2
- package/src/generators/preset/files/kotlin/gradle.properties +8 -2
- package/src/generators/preset/files/kotlin/project.json.template +41 -1
- package/src/generators/preset/files/kotlin/src/main/kotlin/io/kong/extension/Main.kt +6 -4
- package/src/generators/preset/files/kotlin/src/main/resources/META-INF/resources/index.html +3 -3
- package/src/generators/preset/files/kotlin/src/main/resources/application.properties.template +1 -0
- package/src/generators/preset/files/kotlin/src/test/kotlin/io/kong/extension/Test.kt +32 -0
- package/src/generators/preset/files/kotlin/kong.json +0 -6
- package/src/generators/preset/files/kotlin/src/native-test/kotlin/io/kong/extension/.gitkeep +0 -0
- package/src/generators/preset/files/kotlin/src/test/kotlin/io/kong/extension/.gitkeep +0 -0
package/package.json
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
val javaVersion: String by project
|
|
2
|
+
val kongSdkVersion: String by project
|
|
3
|
+
val kongVersion: String by project
|
|
4
|
+
val kotlinxCoroutinesTestVersion: String by project
|
|
2
5
|
val quarkusVersion: String by project
|
|
3
6
|
|
|
4
7
|
plugins {
|
|
@@ -20,8 +23,8 @@ repositories {
|
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
dependencies {
|
|
23
|
-
implementation("io.kong:kong-common
|
|
24
|
-
implementation("io.kong:kong-sdk-kotlin
|
|
26
|
+
implementation("io.kong:kong-common:$kongVersion")
|
|
27
|
+
implementation("io.kong:kong-sdk-kotlin:$kongSdkVersion")
|
|
25
28
|
|
|
26
29
|
implementation(enforcedPlatform("io.quarkus.platform:quarkus-bom:$quarkusVersion"))
|
|
27
30
|
implementation("io.quarkus:quarkus-arc")
|
|
@@ -32,6 +35,7 @@ dependencies {
|
|
|
32
35
|
implementation("io.quarkus:quarkus-smallrye-health")
|
|
33
36
|
|
|
34
37
|
testImplementation("io.quarkus:quarkus-junit5")
|
|
38
|
+
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinxCoroutinesTestVersion")
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
group = "io.kong"
|
|
@@ -12,11 +12,17 @@ jsonSchemaValidatorVersion=1.5.8
|
|
|
12
12
|
# https://mvnrepository.com/artifact/io.github.khalilou88.jnxplus/jnxplus-gradle-plugin
|
|
13
13
|
jnxplusGradlePluginVersion=0.4.0
|
|
14
14
|
|
|
15
|
-
#
|
|
16
|
-
|
|
15
|
+
# Version of Kong SDK artifacts
|
|
16
|
+
kongSdkVersion=0.0.63-SNAPSHOT
|
|
17
|
+
|
|
18
|
+
# Version of Kong non-SDK artifacts
|
|
19
|
+
kongVersion=0.0.63-SNAPSHOT
|
|
17
20
|
|
|
18
21
|
# https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib
|
|
19
22
|
kotlinVersion=2.1.10
|
|
20
23
|
|
|
24
|
+
# https://mvnrepository.com/artifact/org.jetbrains.kotlinx/kotlinx-coroutines-test
|
|
25
|
+
kotlinxCoroutinesTestVersion=1.10.2
|
|
26
|
+
|
|
21
27
|
# https://mvnrepository.com/artifact/io.quarkus/quarkus-core
|
|
22
28
|
quarkusVersion=3.18.4
|
|
@@ -3,6 +3,46 @@
|
|
|
3
3
|
"$schema": "./node_modules/nx/schemas/project-schema.json",
|
|
4
4
|
"projectType": "application",
|
|
5
5
|
"sourceRoot": "./src",
|
|
6
|
-
"targets": {
|
|
6
|
+
"targets": {
|
|
7
|
+
"build": {
|
|
8
|
+
"executor": "@jnxplus/nx-gradle:run-task",
|
|
9
|
+
"outputs": [
|
|
10
|
+
"{projectRoot}/build"
|
|
11
|
+
],
|
|
12
|
+
"options": {
|
|
13
|
+
"task": "quarkusBuild"
|
|
14
|
+
},
|
|
15
|
+
"configurations": {
|
|
16
|
+
"production": {
|
|
17
|
+
"task": "quarkusBuild -Dquarkus.package.jar.enabled=false -Dquarkus.native.enabled=true -Dquarkus.profile=prod"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"build-image": {
|
|
22
|
+
"dependsOn": [
|
|
23
|
+
"build"
|
|
24
|
+
],
|
|
25
|
+
"executor": "@jnxplus/nx-gradle:quarkus-build-image"
|
|
26
|
+
},
|
|
27
|
+
"serve": {
|
|
28
|
+
"executor": "@jnxplus/nx-gradle:run-task",
|
|
29
|
+
"options": {
|
|
30
|
+
"task": "quarkusDev",
|
|
31
|
+
"keepItRunning": true
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"lint": {
|
|
35
|
+
"executor": "@jnxplus/nx-gradle:run-task",
|
|
36
|
+
"options": {
|
|
37
|
+
"task": "ktlintCheck"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"test": {
|
|
41
|
+
"executor": "@jnxplus/nx-gradle:run-task",
|
|
42
|
+
"options": {
|
|
43
|
+
"task": "test"
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
7
47
|
"tags": []
|
|
8
48
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
package io.kong.
|
|
1
|
+
package io.kong.extension
|
|
2
2
|
|
|
3
|
-
import com.fasterxml.jackson.databind.JsonNode
|
|
4
3
|
import com.fasterxml.jackson.databind.ObjectMapper
|
|
5
4
|
import io.kong.common.AppLogger
|
|
6
5
|
import io.kong.sdkkotlin.Field
|
|
7
6
|
import io.kong.sdkkotlin.KongFunction
|
|
7
|
+
import io.quarkus.runtime.annotations.RegisterForReflection
|
|
8
8
|
import jakarta.inject.Singleton
|
|
9
9
|
|
|
10
10
|
// This is the main entry point for developing an extension for Kong.
|
|
@@ -13,12 +13,14 @@ import jakarta.inject.Singleton
|
|
|
13
13
|
// Define the structure of the input data that your extension will accept.
|
|
14
14
|
// Be sure to include example values for each field. These examples help generate
|
|
15
15
|
// sample objects in the UI, making it easier to work with the models.
|
|
16
|
+
@RegisterForReflection
|
|
16
17
|
data class InputData(
|
|
17
18
|
// REPLACE BELLOW WITH YOUR FIELDS
|
|
18
19
|
@Field(description = "An integer number", examples = ["1"]) val a: Int,
|
|
19
20
|
@Field(description = "An integer number", examples = ["2"]) val b: Int,
|
|
20
21
|
)
|
|
21
22
|
|
|
23
|
+
@RegisterForReflection
|
|
22
24
|
data class OutputData(
|
|
23
25
|
// Define the structure of the output data that your extension will return.
|
|
24
26
|
// REPLACE BELLOW WITH YOUR FIELDS
|
|
@@ -37,6 +39,6 @@ val objectMapper = ObjectMapper()
|
|
|
37
39
|
class Main : KongFunction<InputData>(InputData::class.java) {
|
|
38
40
|
private val logger = AppLogger(Main::class.simpleName)
|
|
39
41
|
|
|
40
|
-
override suspend fun handle(data: InputData):
|
|
41
|
-
objectMapper.
|
|
42
|
+
override suspend fun handle(data: InputData): ByteArray? =
|
|
43
|
+
objectMapper.writeValueAsBytes(OutputData(sum_of = data.a + data.b))
|
|
42
44
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
|
-
<title>kong-extension-
|
|
5
|
+
<title>kong-extension-code-call - 0.0.1-SNAPSHOT</title>
|
|
6
6
|
<style>
|
|
7
7
|
body {
|
|
8
8
|
margin: 0;
|
|
@@ -290,8 +290,8 @@
|
|
|
290
290
|
<div class="app-details">
|
|
291
291
|
<h5>Application</h5>
|
|
292
292
|
<ul>
|
|
293
|
-
<li>GroupId: <code>io.kong
|
|
294
|
-
<li>ArtifactId: <code>kong-extension-
|
|
293
|
+
<li>GroupId: <code>io.kong</code></li>
|
|
294
|
+
<li>ArtifactId: <code>kong-extension-code-call</code></li>
|
|
295
295
|
<li>Version: <code>0.0.1-SNAPSHOT</code></li>
|
|
296
296
|
<li>Quarkus Version: <code>2.16.11.Final</code></li>
|
|
297
297
|
</ul>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package io.kong.extensionapicall
|
|
2
|
+
|
|
3
|
+
import com.fasterxml.jackson.databind.ObjectMapper
|
|
4
|
+
import io.kong.extension.InputData
|
|
5
|
+
import io.kong.extension.Main
|
|
6
|
+
import io.kong.extension.OutputData
|
|
7
|
+
import io.quarkus.test.junit.QuarkusTest
|
|
8
|
+
import jakarta.inject.Inject
|
|
9
|
+
import kotlinx.coroutines.test.runTest
|
|
10
|
+
import org.junit.jupiter.api.Assertions.assertEquals
|
|
11
|
+
import org.junit.jupiter.api.Test
|
|
12
|
+
|
|
13
|
+
@QuarkusTest
|
|
14
|
+
class Test {
|
|
15
|
+
@Inject
|
|
16
|
+
lateinit var extension: Main
|
|
17
|
+
|
|
18
|
+
@Inject
|
|
19
|
+
lateinit var objectMapper: ObjectMapper
|
|
20
|
+
|
|
21
|
+
@Test
|
|
22
|
+
fun `when provided valid input then returns expected result`() =
|
|
23
|
+
runTest {
|
|
24
|
+
val input = InputData(a = 1, b = 2)
|
|
25
|
+
|
|
26
|
+
val bytes = extension.handle(input)
|
|
27
|
+
val output = objectMapper.readValue(bytes, OutputData::class.java)
|
|
28
|
+
val sumOf = output.sum_of
|
|
29
|
+
|
|
30
|
+
assertEquals(3, sumOf)
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/generators/preset/files/kotlin/src/native-test/kotlin/io/kong/extension/.gitkeep
DELETED
|
File without changes
|
|
File without changes
|