From 6f60bf82fa6dc986d5775f81fe0cc7a716f58780 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sun, 29 Sep 2024 01:44:24 +0530 Subject: [PATCH 1/2] linting applied --- graphql/resolvers.js | 18 +++++------------- parsing.js | 4 +++- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/graphql/resolvers.js b/graphql/resolvers.js index c9c95ae..036dee0 100644 --- a/graphql/resolvers.js +++ b/graphql/resolvers.js @@ -10,7 +10,6 @@ const Landmark = require("../models/landmark.js"); const { User } = require("../models/user.js"); const { MongoServerError } = require("mongodb"); const { parseBeaconObject, parseUserObject, parseLandmarkObject } = require("../parsing.js"); -const landmark = require("../models/landmark.js"); const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // even if we generate 10 IDs per hour, // ~10 days needed, in order to have a 1% probability of at least one collision. @@ -248,7 +247,7 @@ const resolvers = { ); }, - sendVerificationCode: async (_, {}, { user }) => { + sendVerificationCode: async (_, { user }) => { const min = 1000; const max = 9999; @@ -273,14 +272,14 @@ const resolvers = { return verificationCode; }, - completeVerification: async (_, {}, { user }) => { + completeVerification: async (_, { user }) => { let currentUser = await User.findById(user.id); currentUser.isVerified = true; await currentUser.save(); return currentUser; }, - removeMember: async (_, { groupId, memberId }, { user, pubsub }) => { + removeMember: async (_, { groupId, memberId }, { user }) => { const group = await Group.findById(groupId); if (!group) return new UserInputError("No group exists with this code!"); @@ -349,12 +348,8 @@ const resolvers = { await user.save(); return newGroup; } catch (e) { - //try again only if shortcode collides. - if (e instanceof MongoServerError && e.keyValue["shortcode"]) { - } else { - //else return the error; + return new Error(e); - } } } //if shortcode collides two times then return an error saying please try again. @@ -641,9 +636,6 @@ const resolvers = { return user; }, - changeLeader: async (_, { beaconID, newLeaderID }, { user }) => { - const beacon = await Beacon.findById(beaconID); - }, }, ...(process.env._HANDLER == null && { Subscription: { @@ -713,7 +705,7 @@ const resolvers = { (payload, variables, { user }) => { const { groupID, groupMembers, groupLeader, groupUpdate } = payload; - let { newBeacon, groupId, deletedBeacon, updatedBeacon, newUser } = groupUpdate; + let { newBeacon, groupId, deletedBeacon, updatedBeacon } = groupUpdate; if (newBeacon != null) { if (newBeacon.leader._id == user.id) { // stopping to listen to the creator of beacon diff --git a/parsing.js b/parsing.js index 3b250bf..bdd4a82 100644 --- a/parsing.js +++ b/parsing.js @@ -50,7 +50,9 @@ function parseUserObject(userObject) { updatedAt: convertToDate(userObject.updatedAt), __v: userObject.__v, }; - } catch (error) {} + } catch (error) { + console.log(error) + } return model; } From d706f60fea69a5bcdee3b1e6033a383872536c0d Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sun, 29 Sep 2024 01:49:43 +0530 Subject: [PATCH 2/2] Resolves linting issues --- graphql/resolvers.js | 4 +--- parsing.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/graphql/resolvers.js b/graphql/resolvers.js index 036dee0..10d5882 100644 --- a/graphql/resolvers.js +++ b/graphql/resolvers.js @@ -348,8 +348,7 @@ const resolvers = { await user.save(); return newGroup; } catch (e) { - - return new Error(e); + return new Error(e); } } //if shortcode collides two times then return an error saying please try again. @@ -635,7 +634,6 @@ const resolvers = { return user; }, - }, ...(process.env._HANDLER == null && { Subscription: { diff --git a/parsing.js b/parsing.js index bdd4a82..1834feb 100644 --- a/parsing.js +++ b/parsing.js @@ -51,7 +51,7 @@ function parseUserObject(userObject) { __v: userObject.__v, }; } catch (error) { - console.log(error) + console.log(error); } return model;