Bootstrap a REST Service with Play 2 Framework
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci
app
conf
modules
project
public
test
.DS_Store
.gitignore
LICENSE
README.md
build.sbt
buildscript.sh
runtest.sh

README.md

Play2-Bootstrap

codecov CircleCI

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

This project is built with:

  • Play Framework 2.6
  • Slick 3.2.3
  • Flyway 5.1.1

It needs a PostgresQL database

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

EnvVars for Configuration

  • DATABASE_DB = Database Endpoint (for example play)
  • DATABASE_HOST = Database Host (for example localhost)
  • DATABASE_PORT = Database Port
  • DATABASE_USER = Database User
  • DATABASE_PASSWORD = Database Password
  • FIREBASE_JSON = Authentication Json from Google Firebase
  • FIREBASE_FILEPATH = Path to Firebase.json (Dont use in CI)

In the Terminal those can be set by:

export ENV_VAR=Variable

Thereafter the variable could be checked by:

echo $ENV_VAR

CircleCI

EnvVars:

  • HOME = HomePath
  • GOOGLE_PROJECT_ID
  • GOOGLE_COMPUTE_ZONE
  • GOOGLE_CLUSTER_NAME
  • GCLOUD_SERVICE_KEY

Authentication

  • Each request is checked for a Firebase JWT token in the request headers.
  • The Firebase.json file has to be present and filled at ./conf/firebase.json

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

Testing

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

If a database is present:

sbt ciTest

If no database is available:

./runtest.sh

Running

######Before Running this you have to run: slickGen and ciTest

To run the project, start up Play:

sbt run

Docker

To create a local docker Container with the Native Packager Plugin:

If a database is present:

docker:publishlocal

If no database is available:

./buildscript.sh

And that's it!

Its locally aviable at: http://localhost:9000