Coder Social home page Coder Social logo

kotlin-serverless's Introduction

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

kotlin-serverless's People

Contributors

lostcodingsomewhere avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.