2.7 KiB
🖥 Development Setup
Follow these steps to set up NotyKT API project locally.
🗄️ Database Setup
-
Download and install the latest PostgreSQL package as per your system need.
-
After successful installation, create database for this project.
For e.g. create database namednotykt_dev_db
.
After setting up database, you can proceed to set up project.
⚙️ Project Setup
You will require latest stable version of JetBrains IntelliJ Idea IDE to build and run the server application. You can install the latest version from here.
-
Import project in IntelliJ IDE.
-
Use existing Gradle wrapper for syncing project.
-
Build 🔨 the project.
-
Set up environment variables for database credentials as following with valid values as per your setup.
SECRET_KEY=ANY_RANDOM_SECRET_VALUE
PGPORT=5432
PGHOST=localhost
PGDATABASE=notykt_dev_db
PGUSER=postgres
PGPASSWORD=postgres
DATABASE_DRIVER=org.postgresql.ds.PGSimpleDataSource
DATABASE_MAX_POOL_SIZE=10
?> These environment variables are used from application.conf
and then retrieved in Config.kt
.
- Finally, execute command
gradlew :application:run
or use IntelliJ's run configuration to run the API server application. You can see console output like...
-
Hit
http://localhost:8080
and API will be live🔥. -
You can find sample HTTP requests in
/http
directory and can directly send requests from IntelliJ itself.
For example, there's sample request for user registration in /http/auth
and we can execute and see response from IntelliJ itself as in below image.
🧪 Running Application Tests
Tests for the application are written in ApplicationTest.kt
which uses Ktor's test framework for server.
It uses Testcontainers to interact with test database which is only created temporarily for testing purpose and destroyed once tests are completed which reduces overhead of managing separate database for testing.
?> Testcontainers uses Docker internally so you'll need to install and setup Docker on your machine to be able to run the tests.