InstagramClone
InstagramClone copied to clipboard
Eslint fixes for backend deployment (Fixed)
Before firebase deploy there are Eslint checks for backend/functions/index.js
Here is the updated file with suggested eslint fixes
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp();
const db = admin.firestore();
exports.addLike = functions.firestore
.document("/posts/{creatorId}/userPosts/{postId}/likes/{userId}")
.onCreate((snap, context) => {
return db
.collection("posts")
.doc(context.params.creatorId)
.collection("userPosts")
.doc(context.params.postId)
.update({
likesCount: admin.firestore.FieldValue.increment(1),
});
});
exports.removeLike = functions.firestore
.document("/posts/{creatorId}/userPosts/{postId}/likes/{userId}")
.onDelete((snap, context) => {
return db
.collection("posts")
.doc(context.params.creatorId)
.collection("userPosts")
.doc(context.params.postId)
.update({
likesCount: admin.firestore.FieldValue.increment(-1),
});
});
exports.addFollower = functions.firestore
.document("/following/{userId}/userFollowing/{FollowingId}")
.onCreate((snap, context) => {
return db
.collection("users")
.doc(context.params.FollowingId)
.update({
followersCount: admin.firestore.FieldValue.increment(1),
}).then(() => {
return db
.collection("users")
.doc(context.params.userId)
.update({
followingCount: admin.firestore.FieldValue.increment(1),
});
});
});
exports.removeFollower = functions.firestore
.document("/following/{userId}/userFollowing/{FollowingId}")
.onDelete((snap, context) => {
return db
.collection("users")
.doc(context.params.FollowingId)
.update({
followersCount: admin.firestore.FieldValue.increment(-1),
}).then(() => {
return db
.collection("users")
.doc(context.params.userId)
.update({
followingCount: admin.firestore.FieldValue.increment(-1),
});
});
});
exports.addComment = functions.firestore.
document("/posts/{creatorId}/userPosts/{postId}/comments/{userId}")
.onCreate((snap, context) => {
return db
.collection("posts")
.doc(context.params.creatorId)
.collection("userPosts")
.doc(context.params.postId)
.update({
commentsCount: admin.firestore.FieldValue.increment(1),
});
});
Hi @QasidLabeed !
Thank you for the work! If you are able to create a PR with this I will accept it ASAP! Thank you for your contribution :)