SimCoderYoutube / InstagramClone

Instagram Clone React Native Tutorial 2021 👨‍💻 I'll show you how you can do this in the simplest way and terms possible. By the end of this series you'll have learned how the big companies do it and will be able to do the same, you not only will be able to do this app, but you'll be able to put what you learn into your very own projects! In this series, we use React Native with Expo to quickly deploy the project. We use firebase for all our microservice needs like the auth system, database, storage, amongst others. firebase, redux, react native, javascript, expo. In this series, we'll use all of them and you'll learn them by doing an iconic app. Welcome to this Simcoder project and make an Instagram Clone!
Apache License 2.0
745 stars 294 forks source link

Eslint fixes for backend deployment (Fixed) #36

Open QasidLabeed opened 2 years ago

QasidLabeed commented 2 years ago

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),
          });
    });
SimCoderYoutube commented 2 years ago

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 :)