ktor-api
                                
                                 ktor-api copied to clipboard
                                
                                    ktor-api copied to clipboard
                            
                            
                            
                        Rest APIs performing CRUD Operations using Ktor
KtorAPI
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
Architecture
Ktor Controller (http) -> Service (business) -> Repository (data)
Features
- 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
Coming soon -:
- Unit Testing
- Searching
- Exporting data in excel format
- Exporting data in csv format
Installation
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.
Usage
Notes API
- 
Create a new note
POST http://0.0.0.0:3536/notes
Content-Type: application/json
{
  "note": "your-note",
}
- 
Fetch all notes
GET http://0.0.0.0:3536/notes
- 
Fetch a particular note
GET http://0.0.0.0:3536/notes/{id}
- 
Delete a particular note
DELETE http://0.0.0.0:3536/notes/{id}
- 
Update a particular note
PUT http://0.0.0.0:3536/notes/{id}
- 
Fetch paginated notes
GET http://0.0.0.0:3536/paginatedNotes?size=5&page=1
- 
Fetch sorted notes
GET http://0.0.0.0:3536/notes?sort=asc
JWT Authentication
- 
Generate an Auth Token
POST http://0.0.0.0:3536/generate-token
Content-Type: application/json
{
  "username": "username",
  "password": "password"
}
- 
Test the Auth token
GET http://0.0.0.0:3536/test
Authorization: Bearer {{auth_token}}