CLI
Usage
Create a project and generate code with the kest command line tool.
The kest tool saves you from writing boilerplate: it creates a whole project, and generates controllers, services, modules and more, wiring each into your application the way nest g does.
Get it
./gradlew :cli:installDist # in the Kest checkout
packages/cli/build/install/kest/bin/kest listInside any generated project the same tool runs as a Gradle task, so nothing needs installing:
./gradlew kest --args="g controller users"Create a project
kest new shop --package com.acme.shop --orm postgres| Option | Meaning |
|---|---|
--package | Base package (default app.<name>) |
--template | api (HTTP, the default), worker (no HTTP: queues, schedules, events) or microservice |
--orm | postgres, mysql or mongo: adds the ORM, a database connection in Main.kt, and for SQL a migrations entry point |
--kest-version | Version of the framework to depend on |
--local <path> | Build against a checkout of Kest instead of a published version (a composite build) |
What it writes:
shop/
settings.gradle.kts the Gradle settings
build.gradle.kts Kotlin + KSP + the Kest BOM, the `kest` task (and migration tasks with --orm)
kest.json the project's settings for the tool
.env configuration for local runs
README.md how to run it
src/main/kotlin/com/acme/shop/
AppModule.kt the root module
Main.kt starts the application
HealthController.kt a first endpoint (template api)
src/test/kotlin/com/acme/shop/
AppTest.kt a first testcd shop && gradle wrapper && ./gradlew run # `gradle wrapper` once, if there is no ./gradlew yet
curl localhost:8080/ # {"app":"shop","status":"ok"}--orm postgres or mysql also adds the Gradle tasks migrationGenerate, migrationRun and migrationRevert (Migrations).
Everyday commands
| Command | Does |
|---|---|
kest new <name> | create a project |
kest g <schematic> <name> | generate code (Generating code) |
kest list | list the schematics |
kest build, start, dev, test, run <task> | short names for Gradle tasks (Scripts) |
kest version | the tool's version |
A typical first hour
kest new shop --package com.acme.shop --orm postgres
cd shop && gradle wrapper
./gradlew kest --args="g resource orders" # a CRUD API: module, controller, service, model, DTOs
./gradlew kest --args="g guard auth"
./gradlew run # try it