Skip to content

HarukaYamamoto0/study-ktor-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task Management API

A simple and efficient Task Management API built as a study project to explore the Ktor framework and Exposed ORM.

🚀 Technologies

  • Kotlin: Programming language.
  • Ktor: Framework for building asynchronous servers and clients.
  • Exposed: Kotlin SQL framework (ORM).
  • H2 Database: Lightweight in-memory/file-based database.
  • kotlinx.serialization: For JSON handling.
  • Logback: For logging.

✨ Features

  • List Tasks: Retrieve all tasks stored in the database.
  • Create Task: Add new tasks with a title and description.
  • Delete Task: Remove tasks using their unique ID.
  • Database Persistence: Uses an H2 database with file storage.

🛠️ API Endpoints

Method Endpoint Description
GET / Health check / Welcome message
GET /tasks List all tasks
POST /tasks Create a new task
DELETE /tasks/{id} Delete a task by ID

Example Payloads

Create Task (POST /tasks)

{
  "title": "Learn Ktor",
  "description": "Study how to build APIs with Kotlin and Ktor"
}

Task Response

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "title": "Learn Ktor",
  "description": "Study how to build APIs with Kotlin and Ktor",
  "isDone": false
}

📂 Project Structure

  • src/main/kotlin:
    • models/: Domain models (e.g., Task).
    • database/: Database configuration, tables (TaskTable), and DAOs.
    • repositories/: Business logic and data access abstraction.
    • Routing.kt: API route definitions.
    • Application.kt: Application entry point and module configuration.
  • src/main/resources:
    • application.yaml: Server and application configuration.
    • logback.xml: Logging configuration.

🏃 How to Run

  1. Clone the repository:

    git clone https://github.com/HarukaYamamoto0/study-ktor-server.git
    cd test
  2. Run the application: Use the Gradle wrapper to run the server:

    ./gradlew run
  3. Access the API: The server will start by default at http://0.0.0.0:8080.

🧪 Testing

To run the tests, execute:

./gradlew test

This project was developed for study purposes.

About

A simple and efficient Task Management API built as a study project to explore the Ktor framework and Exposed ORM.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages