wbhill13
wbhill13

Reputation: 75

How do I use the firebase admin SDK using github as my server

I am using GitHub as my server to use the firebase admin SDK. I have written the code in a Node.js environment and pushed it to my GitHub repository. How do I call these functions in my frontend JS code? I ran the npm init command and the npm install firebase-admin --save command, and that created my package and package-lock files and the node-modules folder. I got a service account private key from the firebase console and added that to my directory. Then I created an index.js file and wrote my code. Where do I go from here?

    var admin = require("firebase-admin");
var serviceAccount = require("./troop-30-elections-web-app-firebase-adminsdk-obsmr-f9eb2b81ac.json");
admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://troop-30-elections-web-app.firebaseio.com"
});

function resetPassword (data) {
  admin.auth().updateUser(data.docId, { 
    password: data.newPass
   })
  .then(() => {
      console.log("User Password Sucessfully Updated");  // this is what gets sent back to the app
  });
};

function deleteUser (data) {
 admin.auth().deleteUser(data.docId).then(() => {
    console.log('User Successfully Deleted');
  });
};

Upvotes: 1

Views: 588

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317692

It's not possible to deploy Cloud Functions code to anywhere by Google Cloud Functions. This simply isn't going to work at all.

GitHub is not really a "server". It offers a way to trigger actions based on a activity in your repo, but it will not host API endpoints that you define.

Upvotes: 1

Related Questions