Kest

Search

Search the documentation

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 list

Inside 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
OptionMeaning
--packageBase package (default app.<name>)
--templateapi (HTTP, the default), worker (no HTTP: queues, schedules, events) or microservice
--ormpostgres, mysql or mongo: adds the ORM, a database connection in Main.kt, and for SQL a migrations entry point
--kest-versionVersion 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 test
cd 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

CommandDoes
kest new <name>create a project
kest g <schematic> <name>generate code (Generating code)
kest listlist the schematics
kest build, start, dev, test, run <task>short names for Gradle tasks (Scripts)
kest versionthe 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

Read more