mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-13 08:13:49 +10:00
solving bugs reported in GH issues
This commit is contained in:
@ -1,12 +1,49 @@
|
||||
const admin = require('firebase-admin');
|
||||
const functions = require('firebase-functions');
|
||||
const puppeteer = require('puppeteer');
|
||||
|
||||
admin.initializeApp();
|
||||
|
||||
const BASE_URL = 'https://rxresu.me/r/';
|
||||
|
||||
function timeout(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
async function asyncForEach(array, callback) {
|
||||
for (let index = 0; index < array.length; index++) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await callback(array[index], index, array);
|
||||
}
|
||||
}
|
||||
|
||||
exports.deleteUser = functions.https.onCall((_, { auth }) => {
|
||||
if (!auth) {
|
||||
throw new functions.https.HttpsError(
|
||||
'failed-precondition',
|
||||
'The function must be called while authenticated.',
|
||||
);
|
||||
}
|
||||
|
||||
return new Promise((resolve) => {
|
||||
const resumesRef = admin.database().ref('resumes');
|
||||
|
||||
resumesRef.once('value', async (snapshot) => {
|
||||
const data = snapshot.val();
|
||||
|
||||
const resumes = Object.keys(data).filter(
|
||||
(x) => data[x].user === auth.uid,
|
||||
);
|
||||
|
||||
await asyncForEach(resumes, async (id) => {
|
||||
await admin.database().ref(`resumes/${id}`).remove();
|
||||
});
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
exports.printResume = functions.https.onCall(async ({ id, type }, { auth }) => {
|
||||
if (!id) {
|
||||
throw new functions.https.HttpsError(
|
||||
|
||||
1065
functions/package-lock.json
generated
1065
functions/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -12,9 +12,9 @@
|
||||
"node": "10"
|
||||
},
|
||||
"dependencies": {
|
||||
"firebase-admin": "^8.13.0",
|
||||
"firebase-functions": "^3.7.0",
|
||||
"puppeteer": "2.1.1"
|
||||
"firebase-admin": "^9.0.0",
|
||||
"firebase-functions": "^3.8.0",
|
||||
"puppeteer": "5.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"firebase-functions-test": "^0.2.1"
|
||||
|
||||
Reference in New Issue
Block a user