Skip to content

ncent-archive/kotlin-serverless

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kotlin Serverless (API) Framework

Overview

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

Tech stack:

  • Serverless, Kotlin, Spek. Todo:
  • postgres (auroraserverless), circleci

Install

  1. Install it using npm:
git clone [email protected]:thejnaut1/ncnt.git
cd ncnt/kotlin/kotlin-serverless
npm install serverless -g
npm init -f
npm install
  1. Create your project in serverless.com

  2. To configure your AWS credentials execute serverless config credentials --provider aws --key EXAMPLE --secret EXAMPLEKEY

  3. mvn clean install

  4. ./start.sh

Forking

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]*)?'
    model: main.{object_name}s.models.{Object_name}
    controller: main.{object_name}s.controllers.{Object_name}Controller
  • Add appropriate Unit test to /main/test/unit
  • test via
mvn clean test

if you wish to make changes to an existing object, simply:

  • add new function to the appropriate service
  • add new unit test
  • update the serverless.yml

Deploy

  • Locally
   ./start.sh local
  • Production
   ./start.sh production

Contributing

Feel free to create merge requests

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published