7 | @title
8 |
9 |
10 |
11 |
12 | @content
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | logs
2 | project/project
3 | project/target
4 | target
5 | tmp
6 | .history
7 | dist
8 | .idea
9 | *.iml
10 | /out
11 | .idea_modules
12 | .classpath
13 | .project
14 | /RUNNING_PID
15 | .settings
16 | .DS_Store
17 |
18 | # hidden cross project folders
19 | shared/.js
20 | shared/.jvm
21 |
22 | # temp files
23 | .~*
24 | *~
25 | *.orig
26 |
27 | # eclipse
28 | .scala_dependencies
29 | .buildpath
30 | .cache
31 | .target
32 | bin/
33 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: scala
2 | jdk: oraclejdk8
3 |
4 | scala:
5 | - 2.11.8
6 |
7 | cache:
8 | directories:
9 | - $HOME/.ivy2/cache
10 | - $HOME/.sbt
11 |
12 | before_cache:
13 | - find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete
14 | - find $HOME/.sbt -name "*.lock" -print -delete
15 |
16 | script:
17 | - ci/checksourcemaps.sh
18 |
19 | notifications:
20 | email:
21 | on_success: never
22 |
--------------------------------------------------------------------------------
/server/conf/routes:
--------------------------------------------------------------------------------
1 | # Routes
2 | # This file defines all application routes (Higher priority routes first)
3 | # ~~~~
4 |
5 | # Home page
6 | GET / controllers.Application.index
7 |
8 | # Count Controller
9 | GET /count controllers.CountController.count
10 | # Map static resources from the /public folder to the /assets URL path
11 | GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
12 |
--------------------------------------------------------------------------------
/server/test/IntegrationSpec.scala:
--------------------------------------------------------------------------------
1 | import org.junit.runner._
2 | import org.specs2.mutable._
3 | import org.specs2.runner._
4 |
5 | /**
6 | * add your integration spec here.
7 | * An integration test will fire up a whole play application in a real (or headless) browser
8 | */
9 | @RunWith(classOf[JUnitRunner])
10 | class IntegrationSpec extends Specification {
11 |
12 | "Application" should {
13 | "work from within a browser" in new WithDepsBrowser {
14 |
15 | browser.goTo("http://localhost:" + port)
16 |
17 | browser.pageSource must contain("shouts out")
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/server/conf/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | %date{ISO8601} %-16coloredLevel %logger{36} - %msg%n
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | // Comment to get more information during initialization
2 | logLevel := Level.Warn
3 |
4 | // Resolvers
5 | resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"
6 |
7 | resolvers += Resolver.url("heroku-sbt-plugin-releases",
8 | url("https://dl.bintray.com/heroku/sbt-plugins/"))(Resolver.ivyStylePatterns)
9 |
10 | // Sbt plugins
11 | addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.3")
12 |
13 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.3")
14 |
15 | addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.17")
16 |
17 | addSbtPlugin("com.vmunier" % "sbt-web-scalajs" % "1.0.1")
18 |
19 | addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")
20 |
21 | addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.1")
22 |
23 | addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
24 |
--------------------------------------------------------------------------------
/server/test/ApplicationSpec.scala:
--------------------------------------------------------------------------------
1 | import org.junit.runner._
2 | import org.specs2.runner._
3 | import play.api.test._
4 |
5 | /**
6 | * Add your spec here.
7 | * You can mock out a whole application including requests, plugins etc.
8 | * For more information, consult the wiki.
9 | */
10 | @RunWith(classOf[JUnitRunner])
11 | class ApplicationSpec() extends PlaySpecification {
12 |
13 | "Application" should {
14 |
15 | "send 404 on a bad request" in new WithDepsApplication {
16 | route(app, FakeRequest(GET, "/boum")) must beSome.which (status(_) == NOT_FOUND)
17 | }
18 |
19 | "render the index page" in new WithDepsApplication {
20 | val home = route(app, FakeRequest(GET, "/")).get
21 |
22 | status(home) must equalTo(OK)
23 | contentType(home) must beSome.which(_ == "text/html")
24 | contentAsString(home) must contain ("shouts out")
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/server/app/services/Counter.scala:
--------------------------------------------------------------------------------
1 | package services
2 |
3 | import java.util.concurrent.atomic.AtomicInteger
4 | import javax.inject._
5 |
6 | /**
7 | * This trait demonstrates how to create a component that is injected
8 | * into a controller. The trait represents a counter that returns a
9 | * incremented number each time it is called.
10 | */
11 | trait Counter {
12 | def nextCount(): Int
13 | }
14 |
15 | /**
16 | * This class is a concrete implementation of the [[Counter]] trait.
17 | * It is configured for Guice dependency injection in the [[Module]]
18 | * class.
19 | *
20 | * This class has a `Singleton` annotation because we need to make
21 | * sure we only use one counter per application. Without this
22 | * annotation we would get a new instance every time a [[Counter]] is
23 | * injected.
24 | */
25 | @Singleton
26 | class AtomicCounter extends Counter {
27 | private val atomicCounter = new AtomicInteger()
28 | override def nextCount(): Int = 1 + atomicCounter.getAndIncrement()
29 | }
--------------------------------------------------------------------------------
/server/app/controllers/CountController.scala:
--------------------------------------------------------------------------------
1 | package controllers
2 |
3 | import javax.inject._
4 |
5 | import play.api._
6 | import play.api.libs.json.Json
7 | import play.api.mvc._
8 | import services.Counter
9 |
10 | /**
11 | * This controller demonstrates how to use dependency injection to
12 | * bind a component into a controller class. The class creates an
13 | * `Action` that shows an incrementing count to users. The [[Counter]]
14 | * object is injected by the Guice dependency injection system.
15 | */
16 | @Singleton
17 | class CountController @Inject()(counter: Counter, components: ControllerComponents)
18 | extends AbstractController(components) {
19 |
20 | /**
21 | * Create an action that responds with the [[Counter]]'s current
22 | * count. The result is plain text. This `Action` is mapped to
23 | * `GET /count` requests by an entry in the `routes` config file.
24 | */
25 | def count = Action {
26 | val count = counter.nextCount().toString
27 | Ok(Json.obj("count" -> count))
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/ci/checksourcemaps.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | baseDir="$( cd "$( dirname "$0" )"/.. && pwd )"
4 |
5 | countScalaFiles() {
6 | archive="$baseDir/server/target/universal/server-0.1-SNAPSHOT.zip"
7 | unzip -o $archive
8 | nbScalaFiles=$(unzip -l "server-0.1-SNAPSHOT/lib/*server*.jar" | grep ".*\.scala$" | wc -l)
9 | return "$nbScalaFiles"
10 | }
11 |
12 | cd $baseDir
13 |
14 | # produce archive with no source maps
15 | sbt universal:packageBin
16 | countScalaFiles
17 | nbScalaFilesNoSourceMaps=$?
18 |
19 | # produce archive with source maps
20 | sbt universal:packageBin "set emitSourceMaps in (client, fullOptJS) := true" "set emitSourceMaps in (sharedJs, fullOptJS) := true" universal:packageBin
21 | countScalaFiles
22 | nbScalaFilesWithSourceMaps=$?
23 |
24 | echo "-- RESULTS --"
25 | echo "Number of Scala files with source maps disabled: $nbScalaFilesNoSourceMaps (0 expected)"
26 | echo "Number of Scala files with source maps enabled: $nbScalaFilesWithSourceMaps (>0 expected)"
27 |
28 | [ "$nbScalaFilesNoSourceMaps" -eq "0" ] && [ "$nbScalaFilesWithSourceMaps" -gt "0" ]
29 |
--------------------------------------------------------------------------------
/server/app/Module.scala:
--------------------------------------------------------------------------------
1 | import com.google.inject.AbstractModule
2 | import java.time.Clock
3 |
4 | import services.{ApplicationTimer, AtomicCounter, Counter}
5 |
6 | /**
7 | * This class is a Guice module that tells Guice how to bind several
8 | * different types. This Guice module is created when the Play
9 | * application starts.
10 | * Play will automatically use any class called `Module` that is in
11 | * the root package. You can create modules in other locations by
12 | * adding `play.modules.enabled` settings to the `application.conf`
13 | * configuration file.
14 | */
15 | class Module extends AbstractModule {
16 |
17 | override def configure() = {
18 | // Use the system clock as the default implementation of Clock
19 | bind(classOf[Clock]).toInstance(Clock.systemDefaultZone)
20 | // Ask Guice to create an instance of ApplicationTimer when the
21 | // application starts.
22 | bind(classOf[ApplicationTimer]).asEagerSingleton()
23 | // Set AtomicCounter as the implementation for Counter.
24 | bind(classOf[Counter]).to(classOf[AtomicCounter])
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/server/app/filters/ExampleFilter.scala:
--------------------------------------------------------------------------------
1 | package filters
2 |
3 |
4 | import akka.stream.Materializer
5 | import javax.inject._
6 | import play.api.mvc._
7 | import scala.concurrent.{ExecutionContext, Future}
8 |
9 | /**
10 | * This is a simple filter that adds a header to all requests. It's
11 | * added to the application's list of filters by the
12 | * [[Filters]] class.
13 | *
14 | * @param mat This object is needed to handle streaming of requests
15 | * and responses.
16 | * @param exec This class is needed to execute code asynchronously.
17 | * It is used below by the `map` method.
18 | */
19 | @Singleton
20 | class ExampleFilter @Inject()(
21 | implicit override val mat: Materializer,
22 | exec: ExecutionContext) extends Filter {
23 |
24 | override def apply(nextFilter: RequestHeader => Future[Result])
25 | (requestHeader: RequestHeader): Future[Result] = {
26 | // Run the next filter in the chain. This will call other filters
27 | // and eventually call the action. Take the result and modify it
28 | // by adding a new header.
29 | nextFilter(requestHeader).map { result =>
30 | result.withHeaders("X-ExampleFilter" -> "foo")
31 | }
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/client/src/main/scala/example/ScalaJSExample.scala:
--------------------------------------------------------------------------------
1 | package example
2 |
3 | import com.thoughtworks.binding.Binding.Var
4 | import com.thoughtworks.binding.{Binding, dom}
5 | import org.scalajs.dom.document
6 | import org.scalajs.dom.ext.Ajax
7 | import org.scalajs.dom.raw.{Event, HTMLElement}
8 |
9 | import scala.scalajs.concurrent.JSExecutionContext.Implicits.queue
10 | import scala.scalajs.js
11 | import scala.scalajs.js.JSON
12 |
13 |
14 |
15 | object ScalaJSExample extends js.JSApp {
16 |
17 | implicit def makeIntellijHappy(x: scala.xml.Elem): Binding[HTMLElement] = ???
18 |
19 | /**
20 | * Ajax Request to server, updates data state with number
21 | * of requests to count.
22 | * @param data
23 | */
24 | def countRequest(data: Var[String]) = {
25 | val url = "http://localhost:9000/count"
26 | Ajax.get(url).foreach { case xhr =>
27 | data.value = JSON.parse(xhr.responseText).count.toString
28 | }
29 | }
30 |
31 | @dom
32 | def render = {
33 | val data = Var("")
34 | countRequest(data) // initial population
35 |
36 |
39 | From Play: The server has been booped { data.bind } times. Shared Message: {shared.SharedMessages.itWorks}.
40 |
41 | }
42 |
43 | def main(): Unit = {
44 | dom.render(document.body, render)
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/server/app/services/ApplicationTimer.scala:
--------------------------------------------------------------------------------
1 | package services
2 |
3 | import java.time.{Clock, Instant}
4 | import javax.inject._
5 | import play.api.Logger
6 | import play.api.inject.ApplicationLifecycle
7 | import scala.concurrent.Future
8 |
9 | /**
10 | * This class demonstrates how to run code when the
11 | * application starts and stops. It starts a timer when the
12 | * application starts. When the application stops it prints out how
13 | * long the application was running for.
14 | *
15 | * This class is registered for Guice dependency injection in the
16 | * [[Module]] class. We want the class to start when the application
17 | * starts, so it is registered as an "eager singleton". See the code
18 | * in the [[Module]] class to see how this happens.
19 | *
20 | * This class needs to run code when the server stops. It uses the
21 | * application's [[ApplicationLifecycle]] to register a stop hook.
22 | */
23 | @Singleton
24 | class ApplicationTimer @Inject() (clock: Clock, appLifecycle: ApplicationLifecycle) {
25 |
26 | // This code is called when the application starts.
27 | private val start: Instant = clock.instant
28 | Logger.info(s"ApplicationTimer demo: Starting application at $start.")
29 |
30 | // When the application starts, register a stop hook with the
31 | // ApplicationLifecycle object. The code inside the stop hook will
32 | // be run when the application stops.
33 | appLifecycle.addStopHook { () =>
34 | val stop: Instant = clock.instant
35 | val runningTime: Long = stop.getEpochSecond - start.getEpochSecond
36 | Logger.info(s"ApplicationTimer demo: Stopping application at ${clock.instant} after ${runningTime}s.")
37 | Future.successful(())
38 | }
39 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Play Framework with Scala.js, Binding.scala
2 |
3 | [](https://gitter.im/Full-Stack-Scala-Starter/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4 |
5 | This is a simple example application showing how you can integrate a Play project with a Scala.js, Binding.scala project.
6 |
7 | Frontend communicates with backend via JSON. Project aims to be a simple modern starting point.
8 |
9 | The application contains three directories:
10 | * `server` Play application (server side)
11 | * `client` Scala.js, Binding.scala application (client side)
12 | * `shared` Scala code that you want to share between the server and the client
13 |
14 | ## Run the application
15 | ```shell
16 | $ sbt
17 | > run
18 | $ open http://localhost:9000
19 | ```
20 |
21 | ## Features
22 |
23 | The application uses the [sbt-web-scalajs](https://github.com/vmunier/sbt-web-scalajs) sbt plugin and the [scalajs-scripts](https://github.com/vmunier/scalajs-scripts) library.
24 |
25 | - Run your application like a regular Play app
26 | - `compile` triggers the Scala.js fastOptJS command
27 | - `run` triggers the Scala.js fastOptJS command on page refresh
28 | - `~compile`, `~run`, continuous compilation is also available
29 | - Compilation errors from the Scala.js projects are also displayed in the browser
30 | - Production archives (e.g. using `stage`, `dist`) contain the optimised javascript
31 | - Source maps
32 | - Open your browser dev tool to set breakpoints or to see the guilty line of code when an exception is thrown
33 | - Source Maps is _disabled in production_ by default to prevent your users from seeing the source files. But it can easily be enabled in production too by setting `emitSourceMaps in fullOptJS := true` in the Scala.js projects.
34 |
35 |
36 | ## IDE integration
37 |
38 | ### Eclipse
39 |
40 | 1. `$ sbt "eclipse with-source=true"`
41 | 2. Inside Eclipse, `File/Import/General/Existing project...`, choose the root folder. Uncheck the second and the last checkboxes to only import client, server and one shared, click `Finish`. 
42 |
43 | ### IntelliJ
44 |
45 | In IntelliJ, open Project wizard, select `Import Project`, choose the root folder and click `OK`.
46 | Select `Import project from external model` option, choose `SBT project` and click `Next`. Select additional import options and click `Finish`.
47 | Make sure you use the IntelliJ Scala Plugin v1.3.3 or higher. There are known issues with prior versions of the plugin.
48 |
49 | Many thanks to [vmunier](https://github.com/vmunier/) for the initial starting point.
50 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
10 |
11 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12 |
13 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14 |
15 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16 |
17 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18 |
19 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20 |
21 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22 |
23 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24 |
25 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26 |
27 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28 |
29 | 2. Grant of Copyright License.
30 |
31 | Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32 |
33 | 3. Grant of Patent License.
34 |
35 | Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
36 |
37 | 4. Redistribution.
38 |
39 | You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
40 |
41 | You must give any other recipients of the Work or Derivative Works a copy of this License; and
42 | You must cause any modified files to carry prominent notices stating that You changed the files; and
43 | You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
44 | If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
45 | You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
46 |
47 | 5. Submission of Contributions.
48 |
49 | Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
50 |
51 | 6. Trademarks.
52 |
53 | This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
54 |
55 | 7. Disclaimer of Warranty.
56 |
57 | Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
58 |
59 | 8. Limitation of Liability.
60 |
61 | In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
62 |
63 | 9. Accepting Warranty or Additional Liability.
64 |
65 | While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
66 |
67 | END OF TERMS AND CONDITIONS
--------------------------------------------------------------------------------
/server/conf/application.conf:
--------------------------------------------------------------------------------
1 | # This is the main configuration file for the application.
2 | # https://www.playframework.com/documentation/latest/ConfigFile
3 | # ~~~~~
4 | # Play uses HOCON as its configuration file format. HOCON has a number
5 | # of advantages over other config formats, but there are two things that
6 | # can be used when modifying settings.
7 | #
8 | # You can include other configuration files in this main application.conf file:
9 | #include "extra-config.conf"
10 | #
11 | # You can declare variables and substitute for them:
12 | #mykey = ${some.value}
13 | #
14 | # And if an environment variable exists when there is no other subsitution, then
15 | # HOCON will fall back to substituting environment variable:
16 | #mykey = ${JAVA_HOME}
17 |
18 | ## Akka
19 | # https://www.playframework.com/documentation/latest/ScalaAkka#Configuration
20 | # https://www.playframework.com/documentation/latest/JavaAkka#Configuration
21 | # ~~~~~
22 | # Play uses Akka internally and exposes Akka Streams and actors in Websockets and
23 | # other streaming HTTP responses.
24 | akka {
25 | # "akka.log-config-on-start" is extraordinarly useful because it log the complete
26 | # configuration at INFO level, including defaults and overrides, so it s worth
27 | # putting at the very top.
28 | #
29 | # Put the following in your conf/logback.xml file:
30 | #
31 | #
32 | #
33 | # And then uncomment this line to debug the configuration.
34 | #
35 | #log-config-on-start = true
36 | }
37 |
38 | ## Secret key
39 | # http://www.playframework.com/documentation/latest/ApplicationSecret
40 | # ~~~~~
41 | # The secret key is used to sign Play's session cookie.
42 | # This must be changed for production, but we don't recommend you change it in this file.
43 | play.http.crypto.secret = "changeme"
44 |
45 | ## Modules
46 | # https://www.playframework.com/documentation/latest/Modules
47 | # ~~~~~
48 | # Control which modules are loaded when Play starts. Note that modules are
49 | # the replacement for "GlobalSettings", which are deprecated in 2.5.x.
50 | # Please see https://www.playframework.com/documentation/latest/GlobalSettings
51 | # for more information.
52 | #
53 | # You can also extend Play functionality by using one of the publically available
54 | # Play modules: https://playframework.com/documentation/latest/ModuleDirectory
55 | play.modules {
56 | # By default, Play will load any class called Module that is defined
57 | # in the root package (the "app" directory), or you can define them
58 | # explicitly below.
59 | # If there are any built-in modules that you want to disable, you can list them here.
60 | #enabled += my.application.Module
61 |
62 | # If there are any built-in modules that you want to disable, you can list them here.
63 | #disabled += ""
64 | }
65 |
66 | ## Internationalisation
67 | # https://www.playframework.com/documentation/latest/JavaI18N
68 | # https://www.playframework.com/documentation/latest/ScalaI18N
69 | # ~~~~~
70 | # Play comes with its own i18n settings, which allow the user's preferred language
71 | # to map through to internal messages, or allow the language to be stored in a cookie.
72 | play.i18n {
73 | # The application languages
74 | langs = [ "en" ]
75 |
76 | # Whether the language cookie should be secure or not
77 | #langCookieSecure = true
78 |
79 | # Whether the HTTP only attribute of the cookie should be set to true
80 | #langCookieHttpOnly = true
81 | }
82 |
83 | ## Play HTTP settings
84 | # ~~~~~
85 | play.http {
86 | ## Router
87 | # https://www.playframework.com/documentation/latest/JavaRouting
88 | # https://www.playframework.com/documentation/latest/ScalaRouting
89 | # ~~~~~
90 | # Define the Router object to use for this application.
91 | # This router will be looked up first when the application is starting up,
92 | # so make sure this is the entry point.
93 | # Furthermore, it's assumed your route file is named properly.
94 | # So for an application router like `my.application.Router`,
95 | # you may need to define a router file `conf/my.application.routes`.
96 | # Default to Routes in the root package (aka "apps" folder) (and conf/routes)
97 | #router = my.application.Router
98 |
99 | ## Action Creator
100 | # https://www.playframework.com/documentation/latest/JavaActionCreator
101 | # ~~~~~
102 | #actionCreator = null
103 |
104 | ## ErrorHandler
105 | # https://www.playframework.com/documentation/latest/JavaRouting
106 | # https://www.playframework.com/documentation/latest/ScalaRouting
107 | # ~~~~~
108 | # If null, will attempt to load a class called ErrorHandler in the root package,
109 | #errorHandler = null
110 |
111 | ## Filters
112 | # https://www.playframework.com/documentation/latest/ScalaHttpFilters
113 | # https://www.playframework.com/documentation/latest/JavaHttpFilters
114 | # ~~~~~
115 | # Filters run code on every request. They can be used to perform
116 | # common logic for all your actions, e.g. adding common headers.
117 | # Defaults to "Filters" in the root package (aka "apps" folder)
118 | # Alternatively you can explicitly register a class here.
119 | #filters += my.application.Filters
120 |
121 | ## Session & Flash
122 | # https://www.playframework.com/documentation/latest/JavaSessionFlash
123 | # https://www.playframework.com/documentation/latest/ScalaSessionFlash
124 | # ~~~~~
125 | session {
126 | # Sets the cookie to be sent only over HTTPS.
127 | #secure = true
128 |
129 | # Sets the cookie to be accessed only by the server.
130 | #httpOnly = true
131 |
132 | # Sets the max-age field of the cookie to 5 minutes.
133 | # NOTE: this only sets when the browser will discard the cookie. Play will consider any
134 | # cookie value with a valid signature to be a valid session forever. To implement a server side session timeout,
135 | # you need to put a timestamp in the session and check it at regular intervals to possibly expire it.
136 | #maxAge = 300
137 |
138 | # Sets the domain on the session cookie.
139 | #domain = "example.com"
140 | }
141 |
142 | flash {
143 | # Sets the cookie to be sent only over HTTPS.
144 | #secure = true
145 |
146 | # Sets the cookie to be accessed only by the server.
147 | #httpOnly = true
148 | }
149 | }
150 |
151 | ## Netty Provider
152 | # https://www.playframework.com/documentation/latest/SettingsNetty
153 | # ~~~~~
154 | play.server.netty {
155 | # Whether the Netty wire should be logged
156 | #log.wire = true
157 |
158 | # If you run Play on Linux, you can use Netty's native socket transport
159 | # for higher performance with less garbage.
160 | #transport = "native"
161 | }
162 |
163 | ## WS (HTTP Client)
164 | # https://www.playframework.com/documentation/latest/ScalaWS#Configuring-WS
165 | # ~~~~~
166 | # The HTTP client primarily used for REST APIs. The default client can be
167 | # configured directly, but you can also create different client instances
168 | # with customized settings. You must enable this by adding to build.sbt:
169 | #
170 | # libraryDependencies += ws // or javaWs if using java
171 | #
172 | play.ws {
173 | # Sets HTTP requests not to follow 302 requests
174 | #followRedirects = false
175 |
176 | # Sets the maximum number of open HTTP connections for the client.
177 | #ahc.maxConnectionsTotal = 50
178 |
179 | ## WS SSL
180 | # https://www.playframework.com/documentation/latest/WsSSL
181 | # ~~~~~
182 | ssl {
183 | # Configuring HTTPS with Play WS does not require programming. You can
184 | # set up both trustManager and keyManager for mutual authentication, and
185 | # turn on JSSE debugging in development with a reload.
186 | #debug.handshake = true
187 | #trustManager = {
188 | # stores = [
189 | # { type = "JKS", path = "exampletrust.jks" }
190 | # ]
191 | #}
192 | }
193 | }
194 |
195 | ## Cache
196 | # https://www.playframework.com/documentation/latest/JavaCache
197 | # https://www.playframework.com/documentation/latest/ScalaCache
198 | # ~~~~~
199 | # Play comes with an integrated cache API that can reduce the operational
200 | # overhead of repeated requests. You must enable this by adding to build.sbt:
201 | #
202 | # libraryDependencies += cache
203 | #
204 | play.cache {
205 | # If you want to bind several caches, you can bind the individually
206 | #bindCaches = ["db-cache", "user-cache", "session-cache"]
207 | }
208 |
209 | ## Filters
210 | # https://www.playframework.com/documentation/latest/Filters
211 | # ~~~~~
212 | # There are a number of built-in filters that can be enabled and configured
213 | # to give Play greater security. You must enable this by adding to build.sbt:
214 | #
215 | # libraryDependencies += filters
216 | #
217 | play.filters {
218 | ## CORS filter configuration
219 | # https://www.playframework.com/documentation/latest/CorsFilter
220 | # ~~~~~
221 | # CORS is a protocol that allows web applications to make requests from the browser
222 | # across different domains.
223 | # NOTE: You MUST apply the CORS configuration before the CSRF filter, as CSRF has
224 | # dependencies on CORS settings.
225 | cors {
226 | # Filter paths by a whitelist of path prefixes
227 | #pathPrefixes = ["/some/path", ...]
228 |
229 | # The allowed origins. If null, all origins are allowed.
230 | #allowedOrigins = ["http://www.example.com"]
231 | allowedOrigins = null
232 | allowedHttpMethods = ["GET", "POST"]
233 |
234 | # The allowed HTTP methods. If null, all methods are allowed
235 | #allowedHttpMethods = ["GET", "POST"]
236 | }
237 |
238 | ## CSRF Filter
239 | # https://www.playframework.com/documentation/latest/ScalaCsrf#Applying-a-global-CSRF-filter
240 | # https://www.playframework.com/documentation/latest/JavaCsrf#Applying-a-global-CSRF-filter
241 | # ~~~~~
242 | # Play supports multiple methods for verifying that a request is not a CSRF request.
243 | # The primary mechanism is a CSRF token. This token gets placed either in the query string
244 | # or body of every form submitted, and also gets placed in the users session.
245 | # Play then verifies that both tokens are present and match.
246 | csrf {
247 | # Sets the cookie to be sent only over HTTPS
248 | #cookie.secure = true
249 |
250 | # Defaults to CSRFErrorHandler in the root package.
251 | #errorHandler = MyCSRFErrorHandler
252 | }
253 |
254 | ## Security headers filter configuration
255 | # https://www.playframework.com/documentation/latest/SecurityHeaders
256 | # ~~~~~
257 | # Defines security headers that prevent XSS attacks.
258 | # If enabled, then all options are set to the below configuration by default:
259 | headers {
260 | # The X-Frame-Options header. If null, the header is not set.
261 | #frameOptions = "DENY"
262 |
263 | # The X-XSS-Protection header. If null, the header is not set.
264 | #xssProtection = "1; mode=block"
265 |
266 | # The X-Content-Type-Options header. If null, the header is not set.
267 | #contentTypeOptions = "nosniff"
268 |
269 | # The X-Permitted-Cross-Domain-Policies header. If null, the header is not set.
270 | #permittedCrossDomainPolicies = "master-only"
271 |
272 | # The Content-Security-Policy header. If null, the header is not set.
273 | #contentSecurityPolicy = "default-src 'self'"
274 | }
275 |
276 | ## Allowed hosts filter configuration
277 | # https://www.playframework.com/documentation/latest/AllowedHostsFilter
278 | # ~~~~~
279 | # Play provides a filter that lets you configure which hosts can access your application.
280 | # This is useful to prevent cache poisoning attacks.
281 | hosts {
282 | # Allow requests to example.com, its subdomains, and localhost:9000.
283 | #allowed = [".example.com", "localhost:9000"]
284 | }
285 | }
286 |
287 | ## Evolutions
288 | # https://www.playframework.com/documentation/latest/Evolutions
289 | # ~~~~~
290 | # Evolutions allows database scripts to be automatically run on startup in dev mode
291 | # for database migrations. You must enable this by adding to build.sbt:
292 | #
293 | # libraryDependencies += evolutions
294 | #
295 | play.evolutions {
296 | # You can disable evolutions for a specific datasource if necessary
297 | db.default.enabled = true
298 | }
299 |
300 | ## Database Connection Pool
301 | # https://www.playframework.com/documentation/latest/SettingsJDBC
302 | # ~~~~~
303 | # Play doesn't require a JDBC database to run, but you can easily enable one.
304 | #
305 | # libraryDependencies += jdbc
306 | #
307 | play.db {
308 | # The combination of these two settings results in "db.default" as the
309 | # default JDBC pool:
310 | #config = "db"
311 | #default = "default"
312 |
313 | # Play uses HikariCP as the default connection pool. You can override
314 | # settings by changing the prototype:
315 | prototype {
316 | # Sets a fixed JDBC connection pool size of 50
317 | #hikaricp.minimumIdle = 50
318 | #hikaricp.maximumPoolSize = 50
319 | }
320 | }
321 |
322 | ## JDBC Datasource
323 | # https://www.playframework.com/documentation/latest/JavaDatabase
324 | # https://www.playframework.com/documentation/latest/ScalaDatabase
325 | # ~~~~~
326 | # Once JDBC datasource is set up, you can work with several different
327 | # database options:
328 | #
329 | # Slick (Scala preferred option): https://www.playframework.com/documentation/latest/PlaySlick
330 | # JPA (Java preferred option): https://playframework.com/documentation/latest/JavaJPA
331 | # EBean: https://playframework.com/documentation/latest/JavaEbean
332 | # Anorm: https://www.playframework.com/documentation/latest/ScalaAnorm
333 | #
334 | db {
335 | # You can declare as many datasources as you want.
336 | # By convention, the default datasource is named `default`
337 |
338 | # https://www.playframework.com/documentation/latest/Developing-with-the-H2-Database
339 | #default.driver = org.h2.Driver
340 | #default.url = "jdbc:h2:mem:play"
341 | #default.username = sa
342 | #default.password = ""
343 |
344 | # You can turn on SQL logging for any datasource
345 | # https://www.playframework.com/documentation/latest/Highlights25#Logging-SQL-statements
346 | #default.logSql=true
347 | }
348 |
--------------------------------------------------------------------------------