This is a small example of how to implement Angular and Google Endpoints with Scala JS.
https://master-dot-io-cenet-scalajs-concept.appspot.com
Build ScalaJS including Google Endpoints and Angular:
-
$ sbt
-
fastOptJS
-
Build ScalaJS (above)
-
Run with (no hot deploy) $ mvn appengine:devserver
Publish to Google Appengine with maven
-
Build ScalaJS (above)
-
$ mvn -Dapp.id=your-app-id -Dapp.version=your-app-version appengine:update
Run locally with Appengine SDK.
-
Build ScalaJS (above)
-
Optional: Download Appengine SDK or look for it in Maven repostiory
-
Build webapp folder. Compile into webapp/WEB-INF/classes and copy dependency libs to webapp/WEB-INF/lib
-
Start with address and port as parameters $ %APPENGINE_SDK_HOME%/bin/dev_appserver -a localhost -p 8080 target/.../webapp
-
Optional: Add flag to start Java remote debugger
--jvm_flag=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
Check the API by starting it locally and go to (activate "insecure" scripts):
http://localhost:8080/_ah/api/explorer
Either use
1 Google Oauth2 with Google Endpoints. See https://cloud.google.com/appengine/docs/java/endpoints/consume_js
2 Use another provider and send the token in either with Google Endpoints generated Javascript See https://developers.google.com/api-client-library/javascript/reference/referencedocs#gapiauthsettokentoken
gapi.auth.setToken({access_token: token});
3 Activate sessions in Google Endpoints backend and use a authenticator (below). Remember that Endpoints may not use a custom domain and authorization is per domain! See http://stackoverflow.com/a/28745414/671188
auth = @ApiAuth(allowCookieAuth = AnnotationBoolean.TRUE)
Example of Scala Authenticator:
Foundation frontend framework by Zurb.
- Install Scala IDE plugin
http://scala-ide.org/download/current.html
- Import as Maven projects
- Angulate https://github.com/jokade/scalajs-angulate
- Endpoints client Javascript https://developers.google.com/eclipse/docs/endpoints-jspoints/consume_js
- Endpoints tutorial https://cloud.google.com/appengine/docs/java/endpoints
- Scala JS scala-js.org
- Scala http://www.artima.com/pins1ed/a-scalable-language.html
- App Engine https://cloud.google.com/appengine/docs/java/
- Zurb Foundation http://foundation.zurb.com/sites/docs/kitchen-sink.html