This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const confirmationResult = yield firebase_app | |
.auth() | |
.createUserWithEmailAndPassword(email, password); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as admin from "firebase-admin"; | |
require('dotenv').config(); | |
admin.initializeApp({ | |
credential: admin.credential.cert({ | |
projectId: process.env.PROJECT_ID, | |
privateKey: process.env.PRIVATE_KEY?.replace(/\\n/g, '\n'), | |
clientEmail: process.env.CLIENT_EMAIL, | |
}), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as functions from 'firebase-functions'; | |
import * as admin from "firebase-admin"; | |
export const createNewDocument = functions.https | |
.onRequest(async (request, response) => { | |
const result = await admin | |
.firestore() | |
.collection('admin') | |
.doc('users') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Request, Response } from 'firebase-functions' | |
import * as admin from "firebase-admin"; | |
enum AuthErrorCodes { | |
TOKEN_NULL, | |
DECODE_TOKEN_ERROR, | |
NO_DECODED_UID, | |
NO_DECODED_EMAIL, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Request, Response } from 'firebase-functions' | |
import * as admin from "firebase-admin"; | |
enum AuthErrorCodes { | |
TOKEN_NULL, | |
DECODE_TOKEN_ERROR, | |
NO_DECODED_UID, | |
NO_DECODED_EMAIL, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. Get token using firebase auth() function | |
const tokenContext = firebase_initializedApp.auth().currentUser; | |
const token = yield call([tokenContext, tokenContext.getIdToken], true); | |
// 2. Set token to 'Authorization' header axios instance | |
axios_instance.defaults.headers.common.authorization = `Bearer ${token}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as functions from 'firebase-functions'; | |
import { Request, Response, RuntimeOptions } from 'firebase-functions' | |
import * as admin from "firebase-admin"; | |
const runtimeOpts: RuntimeOptions = { | |
timeoutSeconds: 60, // Timeout for the function in seconds, possible values are 0 to 540. | |
memory: '128MB' // VALID_MEMORY_OPTIONS: ["128MB", "256MB", "512MB", "1GB", "2GB"]; | |
} | |
export const getUserByEmail = functions.runWith(runtimeOpts).https |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as functions from 'firebase-functions'; | |
import * as admin from "firebase-admin"; | |
import { verifyAndDecodeToken } from "./verifyAndDecodeToken"; | |
export const deleteDocument = functions.https | |
.onRequest(async (request, response) => { | |
const uidAndEmail = await verifyAndDecodeToken(request, response); | |
const result = await admin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as functions from 'firebase-functions'; | |
import * as admin from "firebase-admin"; | |
import { verifyAndDecodeToken } from "./verifyAndDecodeToken"; | |
export const deleteDocument = functions.https | |
.onRequest(async (request, response) => { | |
const uidAndEmail = await verifyAndDecodeToken(request, response); | |
const result = await admin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as functions from 'firebase-functions'; | |
import { Request, Response, RuntimeOptions } from 'firebase-functions' | |
import * as admin from "firebase-admin"; | |
const runtimeOpts: RuntimeOptions = { | |
timeoutSeconds: 60, // Timeout for the function in seconds, possible values are 0 to 540. | |
memory: '128MB' // VALID_MEMORY_OPTIONS: ["128MB", "256MB", "512MB", "1GB", "2GB"]; | |
} | |
export const getUserByEmail = functions.runWith(runtimeOpts).https |