Skip to content

Instantly share code, notes, and snippets.

@wcandillon
Created April 2, 2017 18:52
Show Gist options
  • Save wcandillon/5cbd987d706f7a3031526b8f9c113dad to your computer and use it in GitHub Desktop.
Save wcandillon/5cbd987d706f7a3031526b8f9c113dad to your computer and use it in GitHub Desktop.
module namespace fb = "http://wcandillon.io/modules/firebase";
import module namespace http = "http://zorba.io/modules/http-client";
declare namespace an = "http://zorba.io/annotations";
declare variable $admin:firebase-endpoint := "https://myapp.firebaseio.com/";
declare %an:nondeterministic function fb:get($document-uri as string, $token as string) {
http:get(
$admin:firebase-endpoint || $document-uri || "?auth=" || $token
).body.content ! parse-json($$)
};
declare %an:sequential function fb:delete($document-uri as string, $token as string) {
http:delete($admin:firebase-endpoint || $document-uri || "?auth=" || $token)
};
declare %an:sequential function fb:put($document-uri as string, $document as object, $token as string) {
http:put(
$admin:firebase-endpoint || $document-uri || "?auth=" || $token,
serialize($document),
"application/json"
)
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment