Kotlin Serverless (API) Framework helps to rapidly build and deploy a serverless API Make minor changes in order to simply add your new endpoint Easily deploy locally or to production via a simple script Deploy process also runs all tests
- Serverless, Kotlin, Spek. Todo:
- postgres (auroraserverless), circleci
- Install it using npm:
git clone git@github.com:thejnaut1/ncnt.git
cd ncnt/kotlin/kotlin-serverless
npm install serverless -g
npm init -f
npm install
-
Create your project in serverless.com
-
To configure your AWS credentials execute serverless config credentials --provider aws --key EXAMPLE --secret EXAMPLEKEY
-
mvn clean install
-
./start.sh
Since this is a template/framework, you are expected to fork. In order to add new api endpoint (To non existing object class)
- Add a folder under /src/main/{object_name} and add under it (models, services)
- Add your appropriate model under models, similar to User.kt
- Update the RequestDispatcher.locate (when statement) if you are adding a new service/model
- Add {object_name}Service.kt (This will have your new functionality)
- If you are adding a new non standard CRUD endpoint, simply add it as a method {method_name}
- Edit serverless.yml
functions:
{object_name}:
handler: kotlinserverless.framework.Handler
events:
- http:
path: /{object_name}/{method_name}
method: get #get/post/etc
- Edit /src/main/resources/routes.yml
# =========================
# {object_name} Microservice
# =========================
- regex: '^/{object_name}(/*[a-zA-Z0-9]*)?'
cls: kotlinserverless.main.{object_name}s.controllers.{Object_name}Controller
func: execute
- Add appropriate Unit test to /main/test/unit
- test via
mvn clean test
- add new function to the appropriate service
- add new unit test
- update the serverless.yml
- Locally
./start.sh local
- Production
./start.sh production
Feel free to create merge requests