I don\'t know if this will work out, or is it the right thing to do.
I have created an angularjs application and used firebase to provide my application a \"backend\", o
Check out the queue pattern. Have the user write items to the queue, have the server respond to them.
The really great part of using Firebase as the API/middle-man is that the worker (i.e. server) does not need to worry about if the client has authenticated. Security rules take care of this.
Just write a rule to only allow logged-in users to write into the queue:
{
"rules": {
"queue": {
"in": {
// I can only write if logged in
".write": "auth !== null",
"user_id": {
// I can only write to the queue as myself, this tells the server which
// out/ queue the user will be listening on
".validate": "auth.uid === newData.val()"
}
},
"out": {
"$userid": {
// I can only listen to my out queue
".read": "auth.uid === $userid"
}
}
}
}
}
Now the user simply writes a record to in/ using push(), then listens on out/ until the server replies.
The server reads records out of the in/ queue, processes them, and writes them back to the out/user_id path.
No RESTful protocols, no express servers, no headaches.