Skip to content

Commit

Permalink
create dummy routes via extension
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin67 committed Feb 25, 2024
1 parent 7e08df0 commit 08a99d1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 2 additions & 0 deletions inngest-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ dependencies {
implementation("com.fasterxml.jackson.core:jackson-databind:2.16.1")
implementation("com.squareup.okhttp3:okhttp:4.12.0")

implementation("io.ktor:ktor-server-core:2.3.5")

testImplementation(kotlin("test"))
}

Expand Down
21 changes: 21 additions & 0 deletions inngest-core/src/main/kotlin/com/inngest/routing/Ktor.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.inngest.routing

import io.ktor.server.application.*
import io.ktor.server.response.*
import io.ktor.server.routing.*

fun Route.inngest(path: String) {
route(path) {
get("") {
call.respondText("Get server status")
}

post("") {
call.respondText("Invoke functions")
}

put("") {
call.respondText("Register app")
}
}
}
12 changes: 11 additions & 1 deletion inngest-test-server/src/main/kotlin/com/inngest/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import com.fasterxml.jackson.annotation.JsonProperty
import com.inngest.CommHandler
import com.inngest.FunctionOptions
import com.inngest.FunctionTrigger
import com.inngest.Inngest
import com.inngest.InngestEvent
import com.inngest.InngestFunction
import com.inngest.routing.inngest
import io.ktor.http.*
import io.ktor.server.application.*
import io.ktor.server.engine.*
Expand Down Expand Up @@ -49,6 +51,8 @@ fun Application.module() {
val response = comm.introspect()
call.respond(HttpStatusCode.OK, response)
}

inngest("/test")
}
}

Expand Down Expand Up @@ -118,7 +122,13 @@ val comm = CommHandler(functions = hashMapOf("fn-id-slug" to fn, "fn-follow-up"
fun main() {
var port = 8080

var inngest = Inngest(app_id = "ktor-dev")

println("Test server running on port " + port)

embeddedServer(Netty, port, module = Application::module).start(wait = true)
embeddedServer(
Netty,
port,
module = Application::module,
).start(wait = true)
}

0 comments on commit 08a99d1

Please sign in to comment.