It is a simple REST Api using Kotlin and Docker.
-
Download kobweb
https://github.com/varabyte/kobweb-cli/releases/download/v0.9.13/kobweb-0.9.13.zip
-
Set
path variable
of kobweb. ie. ..kobweb/bin folder path -
Open Command prompt, set your project directory location and Run
kobweb create
-
Open IntelliJ IDE and open kobweb project from your project location
-
Build project and If getting error then open
settings.gradle.kts
and change root project name toPascal Case
ie. DemoApi then re-build.
- Write your code in
/api
package - If you need serializaton plugin then checkout this repo https://github.com/Kotlin/kotlinx.serialization and put in the
libs.version.toml
file and use in yourbuild.gradle.kts
. - To Run server
-
Goto terminal in the IntelliJ
-
Write
cd site
-
Write
kobweb run
If you get nodejs error then download it from the error link. ie. 'https://nodejs.org/dist/v18.12.1/node-v18.12.1-win-x64.zip'.
-
Open browser and run localserver, ie. http://localhost:8080/api/people?count=2
-
Push code on Github
-
- Goto https://render.com/
- Create account
- Connect your github
- Create new webservice from render dashboard
- Select your github repo and connect
- Give name and choose free plan
- Click on Create webservice, It will take few minutes to deploy, so be patience
- After successfully deploy, you can check your API from given link.
- Kotlin
- Docker
- Gradle
- IntelliJ IDE
Reference https://youtu.be/o7OXfMRSIH4
Author: Kaushal Vasava