Skip to content

Instantly share code, notes, and snippets.

@katowulf
Created May 15, 2020 16:41
Show Gist options
  • Save katowulf/d50c26dbbb69fbfe3869cf0b4b41fda1 to your computer and use it in GitHub Desktop.
Save katowulf/d50c26dbbb69fbfe3869cf0b4b41fda1 to your computer and use it in GitHub Desktop.

Revisions

  1. Kato Richardson created this gist May 15, 2020.
    16 changes: 16 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    function callMeAnywhere(uid, foo) {
    if( !uid ) throw new Error("Must authenticate");
    return foo + 'bar';
    }

    functions.https.onCall((data, context) => {
    const data = callMeAnywhere(context.auth.uid, data.foo);
    return {data: data};
    })

    // Use this with https://github.com/firebase/functions-samples/tree/master/authorized-https-endpoint
    app.get('/foo', (req, res) => {
    const data = callMeAnywhere(req.user.id, req.params.foo);
    res.send(data);
    });
    functions.https.onRequest(app);