Alper Tekin
12/26/2022, 1:50 PMAlexander Girke
12/26/2022, 3:53 PMFred Bowker
12/27/2022, 4:22 PMFred Bowker
12/27/2022, 4:24 PMKeval Kanpariya
12/30/2022, 4:55 AMSaher Al-Sous
12/30/2022, 7:40 AMPOST
function, i get the 403 error, why this is happening?v79
12/31/2022, 3:11 PMSam Gammon
01/01/2023, 2:50 AMnative-image
is supported out of the box.
• 🚀 Trying it out
curl -sSL --tlsv1.2 dl.elide.dev/cli/install.sh | bash -s -
👆 the one liner works on Darwin (amd64/arm64), and Linux (amd64) so far.If you prefer NPX:
npx @elide-dev/elide@alpha shell
K Building Kotlin apps with it
•
Elide can be used as a plain library with a regular Micronaut server, and Ktor support is on the way. There are Maven artifacts in a custom repository which is easy to use during the alpha; you can see a sample here.
• G Gradle plugin
You can easily install the Gradle plugin to build your frontend assets and your Kotlin/JS, and package it into your server binary. It will handle building for SSR and CSR both, so you can easily switch between browser rendering modes. Check it out here. Maven and Bazel support are planned.
• 🖥️ Using the shell
elide shell
drops you into a shell just like Node (see attached screenshot), the difference being the URL
class we're using here is implemented in Kotlin, backed by the road-tested power of Micronaut, KotlinX, Netty, and the Java standard library. It has simply been adapted for use in JavaScript, according to the WhatWG URL Spec.
• js Use Kotlin/JS or regular Node stack
Elide packages and consumes your JS/TS with built-in support for esbuild
, so you can use a standard Node toolchain or the Kotlin/JS stack.
• 💨 Super fast React SSR
Because Elide is basically Kotlin with a super-fast JS runtime attached, it can do JS SSR without leaving the JVM. This can soon be drop-in compatible with many React apps. You can see a live sample here to confirm it is fast and server-rendered. The code for that sample is pasted below to show how simple it is to call back and forth between Kotlin and your React app:
@Page class Index : PageWithProps<YourProps>(YourProps.serializer()) {
// Serve React SSR.
@Get("/") suspend fun indexPage(request: HttpRequest<*>) = ssr(request) { // 1: tell the server we're going to do SSR for this request
head {
title { +"Hello, Elide!" }
stylesheet("/styles/base.css")
stylesheet("/styles/main.css")
script("/scripts/ui.js", defer = true) // <-- 2: serve the CSR bundle so it can hydrate the react SSR response
}
body {
injectSSR(this@Index, request) // <-- 3: execute the JS VM to produce the SSR response, and splice it into the server response
}
}
}
• 🐙 Contributors needed
The future of software is much more polyglot than today's paradigm: developers love to fight about frameworks, but at the end of the day, we're all writing code, and eliminating barriers between languages means easier collaboration and more value for all of us. It shouldn't be a Node vs. The World or a Rust vs. The World argument; we should get to pick and pull the best code we want from anywhere and use it to build our apps, especially from a multi-platform language like Kotlin.
This runtime and framework are designed for that future. *If you agree, join us and make a dent in the universe*; you'll have a chance to be impactful and shape a brave new idea from the ground up.
• 🙏 Thank you
We chose Kotlin because of the fantastic community. 2023 will be a massive year for Kotlin, and we think that betting the farm on it is reasonable and smart. We are super excited about what JetBrains and Kotlin have in store for us with K2, context receivers, value classes... just so much to look forward to.
Cheers and happy new year, Kotlin devs,
K sam
Slack ConversationSlackbot
01/02/2023, 12:55 PMadryan_ip
01/03/2023, 4:28 PMNavkrishna
01/04/2023, 12:15 PMCanaan Etai
01/06/2023, 11:20 PM2023-01-07 00:12:00.230 [qtp1706939736-20] WARN o.eclipse.jetty.server.HttpChannel MDC= - handleException /reference/api/swagger.json com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Joda date/time type org.joda.time.DateTime not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-joda" to enable handling
Http4k & Open apiAleksandar Ilic
01/07/2023, 7:09 PMrouting
, but when working with request validation I can’t separate the validations in multiple files. I’m thinking to make that every server feature is isolated module and I’m not sure how to break the validations apart per module. Any ideas how to proceed? ThanksSaher Al-Sous
01/08/2023, 1:21 PMorg.springframework.security.core.context.DeferredSecurityContext
Tony Thomas
01/08/2023, 4:56 PMauthenticate
with. Do you people see any potential issues with it ?
class ServiceException(message: String?, var statusCode: Int) : RuntimeException(message) {
init {
statusCode = statusCode
}
}
fun doAsyncAuthentication(
url: HttpUrl,
): Mono<Authentication> {
return webClient
.post()
.uri(url.toUri())
.body(BodyInserters.fromFormData("token", "tokenValue"))
.retrieve()
.onStatus(HttpStatus::is4xxClientError) { response ->
response
.createException()
.map { InvalidBearerTokenException(it) }
}
.onStatus(HttpStatus::is5xxServerError) { response ->
Mono.error(ServiceException("Server error", response.rawStatusCode()))
}
.bodyToMono<TokenInfoResponse>()
.retryWhen(Retry
.backoff(3, Duration.ofSeconds(1))
.filter { throwable -> throwable is ServiceException })
.map {
OurAuthenticationResponse(it.clientId, it.scopes)
}
}
stevenson
01/09/2023, 6:11 AMstevenson
01/09/2023, 6:14 AM@Configuration
@EnableWebSecurity
open class CorsConfig{
@Bean
open fun springSecurityFilterChain(http: HttpSecurity): SecurityFilterChain {
http
.cors()
.and()
.csrf().disable()
return http.build()
}
@Bean
open fun corsConfigurationSource(): CorsConfigurationSource {
val configuration = CorsConfiguration()
configuration.allowedOrigins = listOf("*")
configuration.allowedMethods = listOf("*")
configuration.allowedHeaders = listOf("*")
val source = UrlBasedCorsConfigurationSource()
source.registerCorsConfiguration("/**", configuration)
return source
}
}
but application starts properly but
when i call the base endpoint i get a 500 error and i dont know where to go to debug
please adviceVenkat
01/12/2023, 4:15 PMCarlos Valencia
01/12/2023, 5:11 PMCannot inline bytecode built with JVM target 11 into bytecode that is being built with JVM target 1.8. Please specify proper '-jvm-target' option
I am using kgraphql in ktor but I am seeing this problem. Not sure how to fix it.Avi Perl
01/16/2023, 2:29 PMBernhard
01/17/2023, 10:13 AMAleksey Blekot
01/17/2023, 5:58 PMstage
fails with error for full-stack-app tutorial
https://github.com/kotlin-hands-on/jvm-js-fullstack/blob/b4bebe15f848a028d2dac6a8faff0e0fe8473a13/build.gradle.kts#L111
Execution failed for task ':installDist'.
> Entry lib/shoppinglist-1.0-SNAPSHOT.jar is a duplicate but no duplicate handling strategy has been set.
adding this in build.gradle doesn’t help
tasks.withType<Copy> {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
Could somebody help me? 🙂Olufemi Adeojo
01/21/2023, 5:02 AMtavish pegram
01/22/2023, 10:19 PMMikael Ståldal
01/25/2023, 9:28 AMAndrés Romero
01/26/2023, 12:57 AMperformAction()
which is a unary RPC. I want to notify the other users with information about that action. I would expect those members to be subscribed to another long-living RPC that facilitates sending that information.
Do you have any examples of how can achieve that in Kotlin? I was looking into something like:
https://dev.bitolog.com/grpc-long-lived-streaming/
https://sultanov.dev/blog/grpc-long-lived-streaming-using-observer-pattern/
But those implementations are written in Go and Java, and I'm struggling to find examples in Kotlinrrva
01/27/2023, 4:28 PMJPilson Sumbo
01/31/2023, 11:23 AMauthenticate(AuthorizeFor.ManageCourse, AuthorizeFor.ManageSubject){
post("/enroll-student") {...}
}
Is this ok ?
authenticate(AuthorizeFor.ManageCourse, AuthorizeFor.ManageSubject,AuthorizeFor.ManagePauta,AuthorizeFor.ManageBatch,AuthorizeFor.ManageAdmin)
Sanjay Kasi
02/02/2023, 9:42 AMCallLogging
plugin to inject MDC values in the pipeline like so:
fun Application.module() {
install(CallLogging) {
mdc("clientIpAddress") { call ->
call.request.header("X-Forwarded-For") ?: "UNDEFINED"
}
}
}
We are generating a userId
within the route which needs to be added to MDC such that it is available outside the current co-routine context:
fun Application.myRoutes() {
routing {
get("/testMDC") {
MDC.putClosable("userId", "${UUID.randomUUID()}") // <-- This is thread local and does not carry onto other co-routines
}
}
}
The clientIpAddress
works fine and is logged throughout but userId
only logs in local context. Is there any work around for this?Goetz Markgraf
02/02/2023, 10:01 AMget("/some/uri") {
val data = call.receive<SomeType>()
val result = doBusinessStuffWith(data)
call.respond(result.doSomeFormatting()
}
And the business function is defined somewhere else:
fun doBusinessStuffWith(data: SomeType): SomeReturnType {
...
}
Is there a way to test the controller in isolation by mocking the business function doBusinessStuffWith
?
In Javascript, you can mock any function call with jest
. I assume, it is not that easy in kotlin, but is there a nice way?
Thank you for your ideas …