classsed-react-firebase-functions's People
Forkers
mixa63rus rohanpal sumonst21 codingfeverforever salman9000 deepak4735 ujjalkar kaeyz tiagox9 kwaku-frimpong instillhubdev fixmylifedesigns eldrgeek mdabdulkhaliq psstory albertahn abelmiraval 12ew alexanderg15 ramyxiii elangosketchbrahma mohanhustler37 tomgutz plkmohanta soly2014 bigbak sadeqzafar20 alkafaiz koreacodingking slee1130 teamage avinashtammineni johnny1500 juliosampaio luttfioz eduardrodideal fabricourt amar9312 samdsg bilalm354 sani071 maflooty alfanjuni pumin-3901 captweiss abbiscuit didarulcseiubat17 khoa1232123 didi9002009 bonekyaw zagallai suresh44t dev2ser nandolinhares manhph43k14 cyrusonline haxmax rk-forfuns ljpedroso theoccultcorner joachim-junior thejaswia vincentmuriuki ongomobile jeffandra32 me-arvind jxu126 gjgit richardwhitney abhii1410 cmarshman rne1223 udgarpiya lastrycoding lalittolani lisabrwn19 aashiqahmed98 ravisingh2091 tenondecrpc daadaadaah conanjohn001 prafullch developerslearnit dileepamrani 3dv1n shiv2209 banobepascal vannamnguyen sethips myriankatto raphaelmans iiiok flirtman jingbanz bejkebeshiri percytuncar rachadawan duangruthaiphiknun talha-rafique jutarmassclasssed-react-firebase-functions's Issues
FBAuth function not working
I am trying to make this app. I am working on FBAuth function, but it doesn't work. Postman shows me {}
as a response, and firebase logs shows:
Error while verifying token TypeError: Cannot read property 'data' of undefined
at FBAuth.admin.auth.verifyIdToken.then.then (/srv/index.js:71:46)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
My code looks like this:
const FBAuth = (req, res, next) => {
let idToken;
if (
req.headers.authorization &&
req.headers.authorization.startsWith('Bearer ')
) {
idToken = req.headers.authorization.split('Bearer ')[1];
} else {
console.error('No token found');
return res.status(403).json({ error: 'Unauthorized' });
}
admin.auth().verifyIdToken(idToken)
.then((decodedToken) => {
req.user = decodedToken;
return db
.collection('users')
.where('userId', '==', req.user.uid)
.limit(1)
.get();
}).then((data) => {
req.user.username = data.docs[0].data().username;
return next();
}).catch((err) => {
console.error('Error while verifying token ', err);
return res.status(403).json(err);
});
};
Can anybody help me?
user/image Internal Server Error
Receiving a 500 internal server error when trying to upload a new image to a user. Added .bucket(${config.storageBucket}
) to admin to specify the bucket, but no luck. Anyone else solve this issue?
why you should use google application credentials?
TypeError: data.forEach is not a function
at exports.getScream:
exports.getScream = (req, res) => {
let screamData = {};
db.doc(/screams/${req.params.screamId}
)
.get()
.then((doc) => {
if (!doc.exists) {
return res.status(404).json({ error: 'Scream not found' });
}
screamData = doc.data();
screamData.screamId = doc.id;
return db
.collection('comments')
.orderBy('createdAt', 'desc')
.where('screamId', '==', req.params.screamId)
.get();
})
.then((data) => {
screamData.comments = [];
data.forEach((doc) => {
screamData.comments.push(doc.data());
});
return res.json(screamData);
})
.catch((err) => {
console.error(err);
res.status(500).json({ error: err.code });
});
};
it says that TypeError: data.forEach is not a function. Is there a solution to solve it. Thank you in advance
TypeError: Cannot read property 'trim' of undefined > at isEmpty
Hi, I am following the YouTube tutorial (amazing job ๐)
I am at the stage of building the signup and login validation functions.
When I POST a signup request with an empty value I've got an TypeError due to the trim function used in the 'isEmtpy' helper.
Any idea how to fix it?
Thanks
> TypeError: Cannot read property 'trim' of undefined
> at isEmpty (/Users/***/***/***/***/functions/index.js:69:14)
> at /Users/***/***/***/***/functions/index.js:93:7
const isEmpty = (string) => {
if (string.trim() === '') return true;
else return false;
};
Unexpected End of multipart data
I am trying to upload image file using postman, as told in tutorial uploading an image, I am getting following error, replaced my image upload function with your code, still getting same issue
here is a link to js file: util/users.js
Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field userId).
Following along with your YouTube tutorial (which is great btw!), and I keep hitting this error when I try to create a new user.
The error happens when I try to use createUserWithEmailAndPassword()
. In the .then()
right after that, something in that callback is not valid according to Firestore, and data.user.userId
shows up as undefined
. In Postman, I get a 500 error with an empty object as an error. In the console, here's what I get:
Error: Value for argument "data" is not a valid Firestore document. Cannot use "undefined" as a Firestore value (found in field userId).
at Object.validateUserInput (C:\Users\alanro\Projects\PlayPlay2\functions\node_modules\@google-cloud\firestore\build\src\serializer.js:277:15)
at validateDocumentData (C:\Users\alanro\Projects\PlayPlay2\functions\node_modules\@google-cloud\firestore\build\src\write-batch.js:612:26)
at WriteBatch.set (C:\Users\alanro\Projects\PlayPlay2\functions\node_modules\@google-cloud\firestore\build\src\write-batch.js:232:9)
at DocumentReference.set (C:\Users\alanro\Projects\PlayPlay2\functions\node_modules\@google-cloud\firestore\build\src\reference.js:330:14)
at db.doc.get.then.then.then (C:\Users\alanro\Projects\PlayPlay2\functions\index.js:131:48)
at process._tickCallback (internal/process/next_tick.js:68:7)
Here's where I currently am with the tutorial:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const firebase = require('firebase');
const app = require('express')();
admin.initializeApp();
const firebaseConfig = {
...
};
firebase.initializeApp(firebaseConfig);
const db = admin.firestore();
const isEmpty = (string) => {
if (string.trim() == '') {
return true;
} else {
return false;
}
}
const isEmail = (email) => {
const regEx = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (email.match(regEx)) {
return true;
} else {
return false;
}
}
// SIGNUP ROUTE
app.post('/signup', (req, res) => {
const newUser = {
email: req.body.email,
username: req.body.username,
password: req.body.password,
confirmPassword: req.body.confirmPassword
}
let errors = {};
// check if email is not empty and is valid
if (isEmpty(newUser.email)) { errors.email = 'Email field must not be empty'}
else if (!isEmail(newUser.email)) { errors.email = 'Email must be valid' }
// check if other fields are empty
if (isEmpty(newUser.password)) { errors.password = 'Password must not be empty' }
if (newUser.password !== newUser.confirmPassword) { errors.confirmPassword = 'Passwords must match' }
if (isEmpty(newUser.username)) { errors.username = 'Username must not be empty'}
if (Object.keys(errors).length > 0) {
return res.status(400).json(errors)
}
let token, userId;
// TODO: validate data
db.doc(`/users/${newUser.username}`).get()
.then(doc => {
console.log(newUser)
if (doc.exists) {
return res.status(400).json({ username: 'this username is already taken'})
} else {
return firebase
.auth()
.createUserWithEmailAndPassword(newUser.email, newUser.password)
}
})
.then((data) => {
console.log('data:', data)
userId = data.user.userId
console.log('userId:', userId)
return data.user.getIdToken();
})
.then((idToken) => {
token = idToken;
const userCredentials = {
username: newUser.username,
email: newUser.email,
createdAt: new Date().toISOString(),
userId
}
return db.doc(`/users/${newUser.username}`).set(userCredentials)
})
.then(() => {
return res.status(201).json({ token });
})
.catch((err) => {
console.error(err);
if(err.code === 'auth/email-already-in-use') {
return res.status(400).json({ email: 'email is already in use'})
} else {
return res.status(500).json({ error: err.code });
}
})
})
exports.api = functions.https.onRequest(app);
Any suggestions to fix this would be a big help. Thanks!
No "exports" main defined
Error: Failed to load function definition from source: Failed to generate manifest from function source: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in C:\Users\op23238\PepmateFinal\pepmate-functions\functions\node_modules\firebase\package.json
Getting error 9 with GET "api/user" ?
comments collection not querying with .where(), returning blank
When I remove the .where() from the below it get all the comments returned, but when I restore it and have the where() query, I get a blank comments response. Followed the tut exactly.
exports.getScream = (req, res) => {
let screamData = {};
db.doc(`/screams/${req.params.screamId}`)
.get()
.then((doc) => {
if (!doc.exists) {
return res.status(404).json({ error: 'Scream not found' });
}
screamData = doc.data();
screamData.screamId = doc.id;
return db
.collection('comments')
.orderBy('createdAt', 'desc')
.where('screamId', '==', req.params.screamId) //if i remove this, the functionality works
.get();
})
.then((data) => {
screamData.comments = [];
data.forEach((doc) => {
screamData.comments.push(doc.data());
});
return res.json(screamData);
})
.catch((err) => {
console.error(err);
res.status(500).json({ error: err.code });
});
"Your reequested "node" versioin "8" doesn't match your global version "10"
When running firebase serve I get the below return
=== Serving from '/Users/vincenttern/reactApps/socialapp-functions'...
โ Your requested "node" version "8" doesn't match your global version "10"
Error: An unexpected error has occurred.
user/image upload not working. Shows bad request while trying to upload
The code shows console log until busboy.on('file') but not in busboy.on('finish'). Help needed !!
Busboy or firebase error
Hi. When I am trying to upload an image to Firestore I get an error in cloud firestore's dashboard:
Error: Failed to import the Cloud Storage client library for Node.js. Make sure to install the "@google-cloud/storage" npm package. Original error: Error: Cannot find module 'ent'
at new FirebaseError (/srv/node_modules/firebase-admin/lib/utils/error.js:42:28)
at new Storage (/srv/node_modules/firebase-admin/lib/storage/storage.js:60:19)
at /srv/node_modules/firebase-admin/lib/firebase-app.js:254:20
at FirebaseApp.ensureService_ (/srv/node_modules/firebase-admin/lib/firebase-app.js:339:23)
at FirebaseApp.storage (/srv/node_modules/firebase-admin/lib/firebase-app.js:252:21)
at FirebaseNamespace.fn (/srv/node_modules/firebase-admin/lib/firebase-namespace.js:311:45)
at Busboy.busboy.on (/srv/handlers/users.js:226:8)
at emitNone (events.js:106:13)
at Busboy.emit (events.js:208:7)
at Busboy.emit (/srv/node_modules/busboy/lib/main.js:37:33)
I have the same code."npm i -g @google-cloud/storage" didn't help.
What's wrong?
Cannot set headers after they are sent to the client
I have a problem with some of the functions , specifically the ones that query the database for some validation and then updates the documents.
The exports.commentOnScream for example. If I run it with an inexistent screamId I get the 404 response, but the code continues to the function on the next 'then()' and tries to return a json with the comment ( If I console.log something before res.json(newComment); it get printed ).
So I get the following error:
(node:27910) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:485:11) at ServerResponse.header (/home//Desenvolvimento/socialape-functions/functions/node_modules/express/lib/response.js:771:10) at ServerResponse.send (/home//Desenvolvimento/socialape-functions/functions/node_modules/express/lib/response.js:170:12) at ServerResponse.json (/home//Desenvolvimento/socialape-functions/functions/node_modules/express/lib/response.js:267:15) at /home//Desenvolvimento/socialape-functions/functions/handlers/screams.js:95:23 at processTicksAndRejections (internal/process/task_queues.js:94:5)
My code is exactly the same as the sreams.js in the repository. Any ideas of how to solve this ??
Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
#9 add user details issue
When I tried to post user bio, website and location into Firebase, it shows "400 Bad Request"
And terminal shows the error:
Error: Update() requires either a single JavaScript object or an alternating list of field/value pairs that can be followed by an optional precondition. At least one field must be updated.
So the new user details can not be added into database
Project Report
Hello guys i have learned a lot from this project it gave me experience in React.
I have just one question is there a Report for this Project ?
Error: Bucket name not specified or invalid. Specify a valid bucket name via the storageBucket option when initializing the app, or specify the bucket name explicitly when calling the getBucket() method.
Solution, do this ...
const serviceAccount = require('/your/service/account/key/path');
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
storageBucket: "your-storage-bucket-name.appspot.com",
});
#12 Create and Get Notifications
Not receiving notifications when creating comments. Like and unlike notifications work just fine
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.