Skip to content

scala-steward/bootstrap-play2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Play2-Bootstrap

Status

codecov Run Tests

Cats Friendly Badge

Scala, Akka, Play2, Slick, Flyway, Insomnia

Bootstrap a rest service with Play2, isolated Slick and isolated Flyway

This project is built with:

  • Play Framework 2.8.1
  • Slick 3.3.2
  • Flyway-sbt & Flyway-Core 6.2.3

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

Swagger.json is available at /v1/swagger.json

Table of Contents:

Getting Started

Insomnia:

  • Download Insomnia | Docs

  • Download and import Swagger.json 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"

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:

About

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

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Scala 96.9%
  • Shell 3.1%