Coder Social home page Coder Social logo

innfactory / bootstrap-akka-http Goto Github PK

View Code? Open in Web Editor NEW
14.0 4.0 1.0 1.01 MB

bootstrap template for akka-http services

Home Page: https://innfactory.de

License: Apache License 2.0

Scala 100.00%
akka akka-http scala jdk8 microservice swagger slick docker hikaricp log4j

bootstrap-akka-http's Introduction

Akka Http Bootstrap

travis-ci.org codecov.io shields.io jonato.de

Info

This is a boilerplate template for a akka http service with slick and flyway database migration. You can use it to create your own REST Services on top of the lightbend stack.

Requirements

Implemented Features

  • Integration of swagger-ui localhost:8080/v1/swagger/index.html
  • Autogenerated swagger doc from routes as yaml / json localhost:8080/v1/api-docs/swagger.yaml or localhost:8080/v1/api-docs/swagger.json
  • CRUD Repositorys via slick-repo
  • CORS Support via akka-http-cors
  • Implemented Authentication with AWS Cognito (JWK) and JWT Token via akka-jwt
  • Test coverage with ScalaTest and scoverage code coverage report
  • Ready for Docker deployment and CloudFormation deployment
  • Config file with optional runtime parameters
  • In-Memory Postgres SQL database for tests
  • Flyway database migration
  • HikariCP as connection pool
  • Logging via Log4j with a xml template

Configuration

  • Start a PostgreSQL Database via RDS, Docker or locally
  • Create a Userpool with AWS Cognito if you need AWS Authentication.
  • Configure your application.conf and the docker.conf (src/main/resources/) (application.conf in test has to stay as it is, for running in a in-memory postgresql instance)

Environment variables

  • SQL_URL - database url by scheme jdbc:postgresql://host:port/database-name
  • SQL_USER - database user
  • SQL_PASSWORD - database password
  • NIC_IP - IP Address bounded to the http service default is 0.0.0.0
  • NIC_PORT - TCP Port used for the http service default is 8080
  • USER_POOL - Define an other cognito user pool than the preconfigured userpool

Run application

To run application, call:

sbt run

If you wanna restart your application without reloading of sbt, use (revolver sbt plugin):

sbt re-start

Run in Docker

For launching application in Docker, you must configure database docker instance and run docker image, generated by sbt.

Generating application docker image and publishing on localhost:

sbt docker:publishLocal

Example of running, generated docker image:

docker run --name akkaHttp -e SQL_USER=dbuser -e SQL_PASSWORD=dbpass -e SQL_URL=jdbcURL -d -p 9090:9000 APPLICATION_IMAGE
  • APPLICATION_IMAGE - id or name of application docker image

look at --link parameter if the database is also a docker container

Test

To run tests, call:

sbt test

To run all tests, with codecoverage, call:

sbt clean coverage test

To generate a coverage report afterwars the testrun, call:

sbt coverageReport

More Info

We will write a blog post soon on innFactory about microservice development.

Changes

1.1

  • Auth now via akka-jwt
  • Persistence will be injected to the services

1.0

  • First stable release

Copyright & Contributers

Tobias Jonas

Copyright (C) 2017 innFactory Cloud- & DataEngineering

Published under the Apache 2 License.

bootstrap-akka-http's People

Contributors

jona7o avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

k3lyan

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.