Firebase and Play Framework (Scala) is it possible? - scala

Hey I love Play Framework Scala and I also am falling in love with Firebase. I was wondering though, I'm planning on building an app using AngularFire and I'm going to need to do some server-side logic/computation and make some server-side queries to Firebase. Is this possible to do with a Play Framework Scala setup? If so what is the recommended approach? If not, is it coming? If so when? I think it's so cool that the Firebase guys used Scala to build Firebase, but I'm bummed there is no Scala API to work with (that I can see). Maybe I could use the Java API somehow, but write still write the app in Scala? Any help would be great. Thanks!

Scala is highly interoperable with Java (compiles to the same bytecode) so you should be able to use the Java API straight-up without any issues.
While some libraries add Scala-specific wrappers to make an API more idiomatic and pleasant for a functional programming style and to smooth some rough edges, it's often not strictly necessary.
If for some reason you didn't want to use the Java client libs, you could also interface with the Firebase REST API via Play 2's very convenience and succinct web services library.

Should be no problem with either their Java SDK (when using Firebase on the backend) or the JavaScript SDK (when using it on the client). But you won't have native support for Scala or Play, especially no support for Iteratee/Enumeratee in Play.
The Java API looks quite good and seems to be event driven. So it should be no problem to integrate it in Play in a scalable way.

Related

Angular2 + Scala Play2?

I am somewhat new to the domain of web development. I am investigating Play2 and am trying to understand, do you need some kind of JS frontend framework to go with Play2 and Scala?
I notice that Play2 has a template engine, but it seems that it generates the HTML on the server and sends it to the browser. Does this mean that the need for a JS frontend like Angular2 is made irrelevant? Or is there still a reason to use Angular2 in a Play2 application? What instances would it make sense and why?
I have some experience of using Play 2 with AngularJS (currently rewriting frontend to Angular2).
I use Play 2 (scala) only for RESTful JSON backend, which is just great for this purpose and I use Angular for single page application frontend. I find this combination brilliant.
My project is hosted on GitHub, you can check it out here
There are three directories in the root:
restful with all backend stuff, written in scala, using Slick for DB,
taking advantage of Play evolutions and all other stuff.
angularjs-client-deprecated with AngularJS code. I used angular-resource for making calls to backend.
client with Angular2 code. There is nothing there so far except for my experiments, however I've written a simple service for authentication with security token.
To summarise, I've been developing my project for almost 2 months so far, mainly to learn both Scala and AngularJS (now Angular2).
If you're planning to use JS framework for frontend, I would recommend you to use Play2 only for RESTFul Json backend. I don't see a reason to use Play2 html template engine in this case.
Play is more about Server Side templating, which isn't all that useful if you're using Angular. It can be done, but it comes with some overhead. I've worked with Scalatra in the past and it worked really well for me.
http://scalatra.org/
Other options include Spray, which is very similar from the outside, but uses Akka internally and uses non-blocking I/O, similar to Play!
http://spray.io/
With angular it is better to go with simple rest/http api like Akka-IO or spray for data and other stuff. Play will be less relevant with Angular.
As others have pointed out Play2 isn't really the best option for building responsive websites. I have a seed project which can help you get started with Akka Http and Angular 5...already configured to deploy to Heroku in a single web dyno.
https://github.com/jdschmitt/akka-angular-heroku
Check it out. I hope it helps anyone landing here looking for a way to manage back-end and front-end in a single repo for simple projects.

Use AWS SQS in Scala Play 2.4 reactive project

I want to use AWS SQS in my Play 2.4 project.
There are two options at moment:
There is a SQS wrapper called https://github.com/kifi/franz which supports reactive way of using that. But it seems not quite popular on Github not sure how mature it is? Whether the developers will continue to maintain it.
There is Java SQS SDK, but it doesn't support Scala Future (reactive way). If I want to make it non-blocking, could I use Akka or?
I haven't used SQS yet but I did have a similar need for DynamoDB. I tried using a third party Scala specific library -- bad idea (buggy, bad api, missing features). In the end I wrapped the AWS Java SDK. Making it 'reactive' is pretty easy and is similar to most things you would do in Scala. Call the AWS functions within a Future body (Future {}) and use functional constructs to process the result (map, reduce etc..).

play framework atmosphere

There is a list of usable frameworks in the creators blog of Atmosphere. I want to use scala and the Play Framework included with Atmosphere. In the blog he writes that Atmosphere works with "every" framework. Could it be that easy to integrate Atmosphere, and how?
I understand that this isn't necessarily the answer you were looking for, but I would suggest you look at Play's native comet support.
http://www.playframework.org/documentation/2.0/ScalaComet
http://www.playframework.org/documentation/api/2.0/scala/play/api/libs/Comet$.html
Do you have a particular use case that Atmosphere can solve more elegantly? If so, here's a thread that might help.
https://groups.google.com/forum/m/?fromgroups#!topic/atmosphere-framework/GM6fC6-eSLE
Yes, take a look at this project - it's a native implementation of Atmosphere running on top of Play!
I'm looking for this too. The benefits it would give are graceful degradation from websocket to long polling and a common api for these both client and server side.

Is it technically possible, and does it even make sense to use Dart with Lift?

I like what I read about Lift, and I like the concept of Dart, but have little experience in both to be able to decide if thinking about using them in the same project is even making sense.
I want both writing structured client side code, and not having to worry about the OWASP top 10 as much
Can they work together? Does it make sense at all? Did anyone try?
I have integrated Dart with Lift using REST services together with Dart's XmlHTTPRequest and liked the result. I would say that any web framework that makes making RESTful services as easy as Lift does is a perfect match for Dart. On the other hand web frameworks such as JSF which requires components to take part of a advanced life cycle are probably not a good fit.
That being said, having the same language on the client and the server side is definitely a win, so when the Dart VM matures a bit more and starts to include RESTful functionality similar to what Express does for NodeJS then I would probably use that instead.
Already now baby steps are being taken for including HTTP support in Dart semilar to what Node provides on V8. Another important point for Dart is that it allows the browser and server to share rich objects, like what GWT does for Java, and this should further ease building advanced web applications with Dart.

OAuth 2.0 provider implementation for Scala/Lift

Does anyone know of a OAuth 2.0 provider (server side) implementation for Scala/Lift? I see Scala 2.0 client, but no provider.
It doesn't look like there is one readily available. So I think you have two options:
Implement one yourself.
Use a Java library in Scala. However this is probably not the optimal root due to the obvious impedance mismatch. But, I don't see much other choice. The project has both an OAuth client/server library and an example on how to use it.
Check this question:
OAuth2 provider for Scalatra or Play framework in Scala
So far, I have found https://github.com/nulab/scala-oauth2-provider and it works good for me. However, I have used it with Play Framework https://github.com/tuxdna/play-oauth2-server.
this library may help Scala-OAuth