Recipes
REPL
Try your services from a console.
Repl is an interactive console on the running container: call a service method without writing a request or a test.
fun main(args: Array<String>) {
val app = Kest.create<AppModule>()
Repl(app).run()
}Kest REPL. Type help.
> providers
OrderService
UserService
> call UserService.find ["42"]
User(id=42, name=Ann)
> call OrderService.total [42, "EUR"]
129
> get UserService
UserService@3b9a45b3
> exit| Command | |
|---|---|
providers | the providers in the container |
get <Type> | the instance |
call <Type>.<method> [json arguments] | calls a method; arguments are a JSON array, converted to the parameter types (numbers, strings, enums) |
A method that throws prints threw ... and the console carries on. suspend functions are not called, and methods are found by name and number of arguments. For anything more, jshell or a Kotlin script with Kest.create<AppModule>() still works.