This is a template for the development of backend applications using Ktor framework powered by Kotlin programming language.
Exposed ORM framework is used to wrap the PostgreSQL database connected by HikariCP JDBC pool.
Firebase Auth helps to authenticate users for each request by passing the bearer token generated on the client side by one of Firebase client SDKs.
Sentry is used for logging crashes.
Find more details on this template in our Medium blog.
Once cloned do the following to adapt template to your needs.
- Change project name in
settings.gradle
. - Change
group
inbuild.gradle
- Change
name
anddescription
inapp.json
. - Generate
testToken
(http://jwtbuilder.jamiekurtz.com/) andtestUserId
(https://www.uuidgenerator.net/) and set them inFirebaseAuth.kt
. These variables are needed to simplify testing endpoints using Postman or similar tools. - Create new Firebase project. Put firebase admin key file to resources and name it
firebase-adminsdk.json
. SetADMIN_KEY
environment variable at your server. - Set
defaultJdbcUrl
inDatabaseFactory.kt
. Here is an example used with PostgreSQLjdbc:postgresql://localhost:5432/<dbName>?user=<userName>&password=<password>&reWriteBatchedInserts=true
- When ready to deploy to Heroku, set GitHub secrets which are used in
github/workflows
YAML files (CI):HEROKU_APP_NAME_PROD
,HEROKU_APP_NAME_STAGING
,HEROKU_EMAIL
, andHEROKU_API_KEY
. SetGRADLE_TASK
environment variable toshadowJar
at your server. - Set
SENTRY_DSN
environment variable at your server to send crashes to Sentry.