This project is a sample Ktor application built with the Amper build system. It demonstrates how to create a RESTful API with Ktor, using PostgreSQL for data storage.
This project uses Amper as its build system. Amper is a new build system from JetBrains that aims to simplify project configuration.
To build the project, run:
./amper build
To run the application, use:
docker-compose up -d
./amper run
If the server starts successfully, you'll see output indicating it's running at http://0.0.0.0:8080.
To run the tests, use:
./amper test
This is a sample Ktor application that provides a RESTful API for managing users, posts, and comments. It uses:
- Ktor for the web framework
- Exposed for database access
- PostgreSQL for data storage
- HikariCP for connection pooling
- JWT for authentication
- Amper as the build system
.
├── amper / amper.bat # Amper build system executables
├── module.yaml # Amper module configuration
├── docker-compose.yml # Docker configuration for PostgreSQL
├── resources/ # Application resources
│ ├── application.yaml # Application configuration
│ └── logback.xml # Logging configuration
├── src/ # Source code
│ └── com/example/ # Application code
│ ├── Application.kt # Main application entry point
│ ├── comments/ # Comments API
│ ├── config/ # Application configuration
│ ├── posts/ # Posts API
│ └── users/ # Users API
└── test/ # Test code
└── com/example/ # Test classes
The application uses PostgreSQL as its database. You can start it using Docker Compose:
docker-compose up -d
This will start a PostgreSQL instance with the following configuration:
- Database:
ktor_sample
- Username:
ktor_user
- Password:
ktor_password
- Port:
5432
The application is configured using the resources/application.yaml
file, which includes:
- Ktor application settings
- JWT authentication configuration
- Database connection settings
The application provides RESTful API endpoints for:
- Users:
/users
- Posts:
/posts
- Comments:
/comments
Note that this project may require additional dependencies to be added to the module.yaml
file. If you encounter compilation errors, check the build logs and add the missing dependencies.