KtorAPI is a project which demonstrates the power of Kotlin's Ktor in developing powerful REST APIs with all basic as well as advanced features.
Ktor version -: 2.1.3
Ktor Controller (http) -> Service (business) -> Repository (data)
- Create Notes
- Update Notes
- Fetch Notes
- Delete Notes
- JWT Authentication
- Ktorm ORM for DB
- Dependency Injection using Koin
- Pagination
- Sorting results using query parameters
- Middlewares/Plugins for Logging
- Unit Testing
- Searching
- Exporting data in excel format
- Exporting data in csv format
Use IntelliJ IDEA, community or enterprise edition to open the project and follow these steps to run the Application.
Notes -: Customise the application.conf file which is not included with the project for security reasons. Specify the ktor object in the application.conf file and fill your own secret, audience, issuer, realm to configure the JWT authenticaton settings. Similarly,specify your port and host inside the application.conf file in which you want to run the server.
Start the MySQL server to use the notes API.
POST http://0.0.0.0:3536/notes
Content-Type: application/json
{
"note": "your-note",
}
GET http://0.0.0.0:3536/notes
GET http://0.0.0.0:3536/notes/{id}
DELETE http://0.0.0.0:3536/notes/{id}
PUT http://0.0.0.0:3536/notes/{id}
GET http://0.0.0.0:3536/paginatedNotes?size=5&page=1
GET http://0.0.0.0:3536/notes?sort=asc
POST http://0.0.0.0:3536/generate-token
Content-Type: application/json
{
"username": "username",
"password": "password"
}
GET http://0.0.0.0:3536/test
Authorization: Bearer {{auth_token}}