Sample Employee API is written in Kotlin and uses Ktor async framework and uses Exposed Kotlin SQL Framework
Sample Employee API allows basic CRUD operations (immutable database) via REST API and JSON as data exchange format.
Sample Employee Api by default uses H2 database but can be changed to Postgres by passing DB_TYPE=postgres
environment variable. The connection settings can also be passed via environment variables (please check application.conf
to see what variables can be overridden).
Database tables are migrated at deployment via Flyway and scripts can be added in db/migrations
folder to add new tables or execute queries like inserting data etc on server startup.
EmployeeApiTest
runs end to end test to make sure all api endpoints perform as expected.
Logs are written to console and can be redirected using tee
process. Logging with MDC (UUID) for tracing purpose and
returning MDC UUID in case of error in API response.
docker-compose up
The Metrics feature allows you to configure the Metrics to get useful information about the server and the requests.
Run jconsole
on command line and choose EmployeeApiServerKt.
Click on metrics
folder to get server performance.