All Projects → raharrison → Kotlin Ktor Exposed Starter

raharrison / Kotlin Ktor Exposed Starter

Starter RESTful service with websocket notifications using Kotlin, Ktor and Exposed with H2, HikariCP and FlyWay

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Kotlin Ktor Exposed Starter

Discord4j
Discord4J is a fast, powerful, unopinionated, reactive library to enable quick and easy development of Discord bots for Java, Kotlin, and other JVM languages using the official Discord Bot API.
Stars: ✭ 973 (+183.67%)
Mutual labels:  rest-api, websocket
Jersey Jwt
Example of REST API with JWT authentication using Jersey, Jackson, Undertow, Weld, Hibernate and Arquillian.
Stars: ✭ 131 (-61.81%)
Mutual labels:  rest-api, jackson
Async Gamequery Lib
A high-performance java game query library designed for steam/source based games and others
Stars: ✭ 88 (-74.34%)
Mutual labels:  rest-api, netty
Glass Isc Dhcp
Glass - ISC DHCP Server Interface
Stars: ✭ 486 (+41.69%)
Mutual labels:  rest-api, websocket
Spring Petclinic Rest
REST version of the Spring Petclinic sample application
Stars: ✭ 257 (-25.07%)
Mutual labels:  rest-api, jackson
Alpaca Trade Api Python
Python client for Alpaca's trade API
Stars: ✭ 912 (+165.89%)
Mutual labels:  rest-api, websocket
Netty Rest
Yet another high performance REST server based on Netty
Stars: ✭ 107 (-68.8%)
Mutual labels:  rest-api, netty
Him Netty
开源的H5即时聊天系统 spring-boot + netty + protobuf + vue ~
Stars: ✭ 194 (-43.44%)
Mutual labels:  websocket, netty
Blynk Server
Blynk is an Internet of Things Platform aimed to simplify building mobile and web applications for the Internet of Things. Easily connect 400+ hardware models like Arduino, ESP8266, ESP32, Raspberry Pi and similar MCUs and drag-n-drop IOT mobile apps for iOS and Android in 5 minutes
Stars: ✭ 8 (-97.67%)
Mutual labels:  rest-api, netty
Jda
Java wrapper for the popular chat & VOIP service: Discord https://discord.com
Stars: ✭ 2,598 (+657.43%)
Mutual labels:  rest-api, websocket
Easychatandroidclient
EasyChat是一个开源的社交类的App。主要包含消息、好友、群组等相关的IM核心功能。部分界面参照了QQ、微信等相关社交APP。EasyChat APP整体采用MVVM模式,基于JetPack(Lifecycle,LiveData,ViewModel,Room)构建
Stars: ✭ 64 (-81.34%)
Mutual labels:  kotlin-coroutines, netty
Mmorpg
springboot编写的轻量级高性能mmorpg手游服务端框架,基本功能逐渐完善中。
Stars: ✭ 309 (-9.91%)
Mutual labels:  websocket, netty
Spring Dubbo Service
微服务 spring dubbo项目:dubbo rpc;druid数据源连接池;mybatis配置集成,多数据源;jmx监控MBean;定时任务;aop;ftp;测试;Metrics监控;参数验证;跨域处理;shiro权限控制;consul服务注册,发现;redis分布式锁;SPI服务机制;cat监控;netty服务代理;websocket;disconf;mongodb集成;rest;docker;fescar
Stars: ✭ 224 (-34.69%)
Mutual labels:  websocket, netty
Hoppscotch
👽 Open source API development ecosystem https://hoppscotch.io
Stars: ✭ 34,569 (+9978.43%)
Mutual labels:  rest-api, websocket
Netty Websocket
a fully-functioning websocket server built on netty.
Stars: ✭ 201 (-41.4%)
Mutual labels:  websocket, netty
Airdcpp Webclient
Communal peer-to-peer file sharing application for file servers/NAS devices
Stars: ✭ 106 (-69.1%)
Mutual labels:  rest-api, websocket
Jetlinks Community
JetLinks 基于Java8,Spring Boot 2.x ,WebFlux,Netty,Vert.x,Reactor等开发, 是一个全响应式的企业级物联网平台。支持统一物模型管理,多种设备,多种厂家,统一管理。统一设备连接管理,多协议适配(TCP,MQTT,UDP,CoAP,HTTP等),屏蔽网络编程复杂性,灵活接入不同厂家不同协议等设备。实时数据处理,设备告警,消息通知,数据转发。地理位置,数据可视化等。能帮助你快速建立物联网相关业务系统。
Stars: ✭ 2,405 (+601.17%)
Mutual labels:  websocket, netty
Him Vue
开源的H5即时聊天系统 spring-boot + netty + protobuf + vue ~
Stars: ✭ 142 (-58.6%)
Mutual labels:  websocket, netty
Poloniex Api Node
Poloniex API client for REST and WebSocket API
Stars: ✭ 138 (-59.77%)
Mutual labels:  rest-api, websocket
Jaguar
Jaguar, a server framework built for speed, simplicity and extensible. ORM, Session, Authentication & Authorization, OAuth
Stars: ✭ 286 (-16.62%)
Mutual labels:  rest-api, websocket

Build

Starter project to create a simple RESTful web service in Kotlin

Updated for Kotlin 1.4.30 and Ktor 1.5.0

Companion article: https://ryanharrison.co.uk/2018/04/14/kotlin-ktor-exposed-starter.html

Getting Started

  1. Clone the repo.
  2. In the root directory execute ./gradlew run
  3. By default the server will start on port 8080. See below Routes section for more information.

Libraries used:

The starter project creates a new in-memory H2 database with one table for Widget instances.

As ktor is async and based on coroutines, standard blocking JDBC may cause performance issues when used directly on the main thread pool (as threads must be reused for other requests). Therefore, another dedicated thread pool is created for all database queries, alongside connection pooling with HikariCP.

Routes:

GET /widget --> get all widgets in the database

GET /widget/{id} --> get one widget instance by id (integer)

POST /widget --> add a new widget to the database by providing a JSON object (converted to a NewWidget instance). e.g -

{
    "name": "new widget",
    "quantity": 64
}

returns

{
    "id": 4,
    "name": "new widget",
    "quantity": 64,
    "dateCreated": 1519926898
}

PUT /widget --> update an existing widgets name or quantity. Pass in the id in the JSON request to determine which record to update

DELETE /widget/{id} --> delete the widget with the specified id

Notifications (WebSocket)

All updates (creates, updates and deletes) to Widget instances are served as notifications through a WebSocket endpoint:

WS /updates --> returns Notification instances containing the change type, id and entity (if applicable) e.g:

{ 
    "type": "CREATE", 
    "id": 12, 
    "entity": { 
      "id": 12, 
      "name": "widget1", 
      "quantity": 5, 
      "dateUpdated": 1533583858169 
    }
}

Testing

The sample Widget service and corresponding endpoints are also tested with 100% coverage. Upon startup of the main JUnit suite (via the test source folder), the server is started ready for testing and is torn down after all tests are run.

  • Unit testing of services with AssertJ - DAO and business logic
  • Integration testing of endpoints using running server with Rest Assured - routing tests/status codes/response structure
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].