Skip to content

A scala bootstrap template for the play 2 framework to build real world applications.

License

Notifications You must be signed in to change notification settings

innFactory/bootstrap-play2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Play2-Bootstrap

Status

codecov Run Tests Mergify Status

Scala, Akka, Play2, Slick, Flyway, Insomnia, Sangria, GraphQL, Firebase

Bootstrap a REST and/or GraphQL(Sangria) service with Play2, isolated Slick and isolated Flyway

This project is built with:

  • Play Framework 2.8.X
  • Slick 3.3.X
  • Flyway-sbt & Flyway-Core 7.1.X
  • Akka 2.6.X
  • Sangria 2.0 for GraphQL
  • Scala 2.13.X

A PostgreSQL Database with activated postgis extensions is needed (for geolocation queries)

Table of Contents:

Getting Started

IMPORTANT:

To load innFactory-scala-utils a Github-Personal-Access-Token with package:read has to be exported as GITHUB_TOKEN. This is necessary to load the packages from Github-Package-Registry.

Insomnia:

  • Download Insomnia | Docs

  • Download and import to Insomnia:
    Run in Insomnia

  • Configure Environment in Insomnia to match with local or prod/staging services

MacOS/Linux/Unix:

Prerequisites:
  • Install Docker
  • Install sbt
  • Install openJDK 11
  • firebase.json (Firebase Service-Account-Access json with firebase-admin-sdk rights) in ./conf/
Run locally:

If prerequisites are met, the service can be started with:

cd ./local-runner

./runFor.sh
  • Name mentioned in logs:
./local-runner/runFor.sh -n Name
  • Remove docker container volume mounted at ./local-runner/postigs:
./local-runner/runFor.sh -r

Service is then locally available at: http://localhost:9000

RunForScriptDocs

Windows:

  • Sorry, no out of the box solution

Dependencies:

Service Accounts:

./conf/firebase.json

Service Account from Google Cloud for the Firebase Admin Sdk. Needs Editor role.

Databases:

  • PostgresQl Database with Password and User set. Needs Postgis Plugin fully installed.

Documentation

request-flow

Request Flow

Deployment and Environment

See here for Deployment and Environment Documentation

Authentication

  • Some requests will require a Firebase JWT Token in the Authorization Header
  • The Firebase.json file has to be present and filled at ./conf/firebase.json

Miscellaneous

Database Migration

This has to be run first

sbt flyway/flywayMigrate

Slick Code Generation

You will need to run the flywayMigrate task first, and then you will be able to generate tables using slickGen.

sbt slickGen

after that you will have to mark the folder target/scala-x.xx/scr_managed as "generated sources root"

Setup

You can find a setup script in .bin/setup. Run it from your projects root with

.bin/setup/setup.sh

It supports bootstrapping your project to rename the project and domain with

.bin/setup/setup.sh bootstrap

As well as creating new packages with

.bin/setup/setup.sh package

You need to repackage the setup application, located in .bin/setup, if you made some changes to it

# Assuming you are located in your applications root
cd .bin/setup
sbt assembly
cd ../..

Testing

You can run functional tests against an in memory database and Slick easily with Play from a clean slate:

For local Testing:

./deployment/runtest.sh

For CI:

A Postgis Database has to be available to run:

sbt ciTests

Running

Before Running this you have to run: slickGen and ciTest

To run the project, start up Play:

sbt run

And that's it!

The service locally aviable at: http://localhost:9000

Licenses:

Liceses Markdown: Last updated (18.06.2020)

Changes:

Changes Markdown: Changes

Contributors: