diff --git a/src/app.js b/src/app.js index 359db89c2..817017108 100644 --- a/src/app.js +++ b/src/app.js @@ -3,7 +3,7 @@ const Sentry = require('@sentry/node'); const app = express(); const logger = require('./startup/logger'); -const globalErrorHandler = require('./utilities/errorHandling/globalErrorHandler').default; +const globalErrorHandler = require('./utilities/errorHandling/globalErrorHandler'); logger.init(); diff --git a/src/controllers/mapLocationsController.js b/src/controllers/mapLocationsController.js index bb85fe9f3..9ba230e21 100644 --- a/src/controllers/mapLocationsController.js +++ b/src/controllers/mapLocationsController.js @@ -1,25 +1,29 @@ const UserProfile = require('../models/userProfile'); -const cache = require('../utilities/nodeCache')(); +const cacheClosure = require('../utilities/nodeCache'); const mapLocationsController = function (MapLocation) { + const cache = cacheClosure(); const getAllLocations = async function (req, res) { try { const users = []; const results = await UserProfile.find( -{}, - '_id firstName lastName isActive location jobTitle totalTangibleHrs hoursByCategory homeCountry', -); + {}, + '_id firstName lastName isActive location jobTitle totalTangibleHrs hoursByCategory', + ); results.forEach((item) => { if ( - (item.location?.coords.lat && item.location?.coords.lng && item.totalTangibleHrs >= 10) - || (item.location?.coords.lat && item.location?.coords.lng && calculateTotalHours(item.hoursByCategory) >= 10) + (item.location?.coords.lat && item.location?.coords.lng && item.totalTangibleHrs >= 10) || + (item.location?.coords.lat && + item.location?.coords.lng && + // eslint-disable-next-line no-use-before-define + calculateTotalHours(item.hoursByCategory) >= 10) ) { users.push(item); } }); - const modifiedUsers = users.map(item => ({ - location: item.homeCountry || item.location, + const modifiedUsers = users.map((item) => ({ + location: item.location, isActive: item.isActive, jobTitle: item.jobTitle[0], _id: item._id, @@ -34,7 +38,7 @@ const mapLocationsController = function (MapLocation) { } }; const deleteLocation = async function (req, res) { - if (!req.body.requestor.role === 'Administrator' || !req.body.requestor.role === 'Owner') { + if (req.body.requestor.role !== 'Administrator' && req.body.requestor.role !== 'Owner') { res.status(403).send('You are not authorized to make changes in the teams.'); return; } @@ -42,13 +46,14 @@ const mapLocationsController = function (MapLocation) { MapLocation.findOneAndDelete({ _id: locationId }) .then(() => res.status(200).send({ message: 'The location was successfully removed!' })) - .catch(error => res.status(500).send({ message: error || "Couldn't remove the location" })); + .catch((error) => res.status(500).send({ message: error || "Couldn't remove the location" })); }; const putUserLocation = async function (req, res) { - if (!req.body.requestor.role === 'Owner') { + if (req.body.requestor.role !== 'Owner') { res.status(403).send('You are not authorized to make changes in the teams.'); return; } + const locationData = { firstName: req.body.firstName, lastName: req.body.lastName, @@ -65,11 +70,11 @@ const mapLocationsController = function (MapLocation) { res.status(200).send(response); } catch (err) { console.log(err.message); - res.status(500).json({ message: err.message || 'Something went wrong...' }); + res.status(500).send({ message: err.message || 'Something went wrong...' }); } }; const updateUserLocation = async function (req, res) { - if (!req.body.requestor.role === 'Owner') { + if (req.body.requestor.role !== 'Owner') { res.status(403).send('You are not authorized to make changes in the teams.'); return; } @@ -89,13 +94,21 @@ const mapLocationsController = function (MapLocation) { try { let response; if (userType === 'user') { - response = await UserProfile.findOneAndUpdate({ _id: userId }, { $set: { ...updateData, jobTitle: [updateData.jobTitle] } }, { new: true }); + response = await UserProfile.findOneAndUpdate( + { _id: userId }, + { $set: { ...updateData, jobTitle: [updateData.jobTitle] } }, + { new: true }, + ); cache.removeCache('allusers'); cache.removeCache(`user-${userId}`); cache.setCache(`user-${userId}`, JSON.stringify(response)); } else { - response = await MapLocation.findOneAndUpdate({ _id: userId }, { $set: updateData }, { new: true }); + response = await MapLocation.findOneAndUpdate( + { _id: userId }, + { $set: updateData }, + { new: true }, + ); } if (!response) { @@ -113,7 +126,7 @@ const mapLocationsController = function (MapLocation) { res.status(200).send(newData); } catch (err) { console.log(err.message); - res.status(500).json({ message: err.message || 'Something went wrong...' }); + res.status(500).send({ message: err.message || 'Something went wrong...' }); } }; diff --git a/src/controllers/mapLocationsController.spec.js b/src/controllers/mapLocationsController.spec.js new file mode 100644 index 000000000..facb9cba2 --- /dev/null +++ b/src/controllers/mapLocationsController.spec.js @@ -0,0 +1,367 @@ +/// mock the cache function before importing so we can manipulate the implementation + +jest.mock('../utilities/nodeCache'); +const cache = require('../utilities/nodeCache'); +const MapLocation = require('../models/mapLocation'); +const UserProfile = require('../models/userProfile'); +const { mockReq, mockRes, assertResMock } = require('../test'); +const mapLocationsController = require('./mapLocationsController'); + +const makeSut = () => { + const { getAllLocations, deleteLocation, putUserLocation, updateUserLocation } = + mapLocationsController(MapLocation); + + return { getAllLocations, deleteLocation, putUserLocation, updateUserLocation }; +}; + +const flushPromises = () => new Promise(setImmediate); + +const makeMockCache = (method, value) => { + const cacheObject = { + getCache: jest.fn(), + removeCache: jest.fn(), + hasCache: jest.fn(), + setCache: jest.fn(), + }; + + const mockCache = jest.spyOn(cacheObject, method).mockImplementationOnce(() => value); + + cache.mockImplementationOnce(() => cacheObject); + + return { mockCache, cacheObject }; +}; + +describe('Map Locations Controller', () => { + beforeEach(() => { + mockReq.params.locationId = 'randomId'; + mockReq.body.firstName = 'Bob'; + mockReq.body.lastName = 'Bobberson'; + mockReq.body.jobTitle = 'Software Engineer'; + mockReq.body.location = { + userProvided: 'New York', + coords: { + lat: 12, + lng: 12, + }, + country: 'USA', + city: 'New York City', + }; + }); + + afterEach(() => { + jest.clearAllMocks(); + }); + + describe('getAllLocations method', () => { + test('Returns 404 if an error occurs when finding all users.', async () => { + const { getAllLocations } = makeSut(); + + const errMsg = 'Failed to find users!'; + const findSpy = jest.spyOn(UserProfile, 'find').mockRejectedValueOnce(new Error(errMsg)); + + const res = await getAllLocations(mockReq, mockRes); + + assertResMock(404, new Error(errMsg), res, mockRes); + expect(findSpy).toHaveBeenCalledWith( + {}, + '_id firstName lastName isActive location jobTitle totalTangibleHrs hoursByCategory', + ); + }); + + test('Returns 404 if an error occurs when finding all map locations.', async () => { + const { getAllLocations } = makeSut(); + + const errMsg = 'Failed to find locations!'; + const findSpy = jest.spyOn(UserProfile, 'find').mockResolvedValueOnce([]); + const findLocationSpy = jest + .spyOn(MapLocation, 'find') + .mockRejectedValueOnce(new Error(errMsg)); + + const res = await getAllLocations(mockReq, mockRes); + + assertResMock(404, new Error(errMsg), res, mockRes); + expect(findSpy).toHaveBeenCalledWith( + {}, + '_id firstName lastName isActive location jobTitle totalTangibleHrs hoursByCategory', + ); + expect(findLocationSpy).toHaveBeenCalledWith({}); + }); + + test('Returns 200 if all is successful', async () => { + const { getAllLocations } = makeSut(); + + const findRes = [ + { + _id: 1, + firstName: 'bob', + lastName: 'marley', + isActive: true, + location: { + coords: { + lat: 12, + lng: 12, + }, + country: 'USA', + city: 'NYC', + }, + jobTitle: ['software engineer'], + totalTangibleHrs: 11, + }, + ]; + const findSpy = jest.spyOn(UserProfile, 'find').mockResolvedValueOnce(findRes); + const findLocationSpy = jest.spyOn(MapLocation, 'find').mockResolvedValueOnce([]); + + const modifiedUsers = { + location: findRes[0].location, + isActive: findRes[0].isActive, + jobTitle: findRes[0].jobTitle[0], + _id: findRes[0]._id, + firstName: findRes[0].firstName, + lastName: findRes[0].lastName, + }; + const res = await getAllLocations(mockReq, mockRes); + + assertResMock(200, { users: [modifiedUsers], mUsers: [] }, res, mockRes); + expect(findSpy).toHaveBeenCalledWith( + {}, + '_id firstName lastName isActive location jobTitle totalTangibleHrs hoursByCategory', + ); + expect(findLocationSpy).toHaveBeenCalledWith({}); + }); + }); + + describe('deleteLocation method', () => { + test('Returns 403 if user is not authorized.', async () => { + mockReq.body.requestor.role = 'Volunteer'; + const { deleteLocation } = makeSut(); + const res = await deleteLocation(mockReq, mockRes); + assertResMock(403, 'You are not authorized to make changes in the teams.', res, mockRes); + }); + + test('Returns 500 if an error occurs when deleting the map location.', async () => { + mockReq.body.requestor.role = 'Owner'; + + const { deleteLocation } = makeSut(); + + const err = new Error('Failed to delete!'); + const deleteSpy = jest.spyOn(MapLocation, 'findOneAndDelete').mockRejectedValueOnce(err); + + const res = await deleteLocation(mockReq, mockRes); + await flushPromises(); + + assertResMock(500, { message: err }, res, mockRes); + expect(deleteSpy).toHaveBeenCalledWith({ _id: mockReq.params.locationId }); + }); + + test('Returns 200 if all is successful', async () => { + mockReq.body.requestor.role = 'Owner'; + const { deleteLocation } = makeSut(); + + const deleteSpy = jest.spyOn(MapLocation, 'findOneAndDelete').mockResolvedValueOnce(true); + + const res = await deleteLocation(mockReq, mockRes); + await flushPromises(); + + assertResMock(200, { message: 'The location was successfully removed!' }, res, mockRes); + expect(deleteSpy).toHaveBeenCalledWith({ _id: mockReq.params.locationId }); + }); + }); + + describe('putUserLocation method', () => { + test('Returns 403 if user is not authorized.', async () => { + mockReq.body.requestor.role = 'Volunteer'; + const { putUserLocation } = makeSut(); + + const res = await putUserLocation(mockReq, mockRes); + assertResMock(403, 'You are not authorized to make changes in the teams.', res, mockRes); + }); + + test('Returns 500 if an error occurs when saving the map location.', async () => { + const { putUserLocation } = makeSut(); + + mockReq.body.requestor.role = 'Owner'; + + const err = new Error('Saving failed!'); + + jest.spyOn(MapLocation.prototype, 'save').mockImplementationOnce(() => Promise.reject(err)); + + const res = await putUserLocation(mockReq, mockRes); + + assertResMock(500, { message: err.message }, res, mockRes); + }); + + test('Returns 200 if all is successful.', async () => { + const { putUserLocation } = makeSut(); + + mockReq.body.requestor.role = 'Owner'; + + const savedLocationData = { + _id: 1, + firstName: mockReq.body.firstName, + lastName: mockReq.body.lastName, + jobTitle: mockReq.body.jobTitle, + location: mockReq.body.location, + }; + + jest + .spyOn(MapLocation.prototype, 'save') + .mockImplementationOnce(() => Promise.resolve(savedLocationData)); + + const res = await putUserLocation(mockReq, mockRes); + + assertResMock(200, savedLocationData, res, mockRes); + }); + }); + + describe('updateUserLocation method', () => { + test('Returns 403 if user is not authorized.', async () => { + const { updateUserLocation } = makeSut(); + + mockReq.body.requestor.role = 'Volunteer'; + + const res = await updateUserLocation(mockReq, mockRes); + + assertResMock(403, 'You are not authorized to make changes in the teams.', res, mockRes); + }); + + // Returns 500 if an error occurs when updating the user location. + test('Returns 500 if an error occurs when updating the user location', async () => { + const { updateUserLocation } = makeSut(); + mockReq.body.requestor.role = 'Owner'; + mockReq.body.type = 'user'; + mockReq.body._id = '60d5f60c2f9b9c3b8a1e4a2f'; + const updateData = { + firstName: mockReq.body.firstName, + lastName: mockReq.body.lastName, + jobTitle: mockReq.body.jobTitle, + location: mockReq.body.location, + }; + + const errMsg = 'Failed to update user profile!'; + const findAndUpdateSpy = jest + .spyOn(UserProfile, 'findOneAndUpdate') + .mockImplementationOnce(() => Promise.reject(new Error(errMsg))); + + const res = await updateUserLocation(mockReq, mockRes); + + assertResMock(500, { message: new Error(errMsg).message }, res, mockRes); + expect(findAndUpdateSpy).toHaveBeenCalledWith( + { _id: mockReq.body._id }, + { $set: { ...updateData, jobTitle: [updateData.jobTitle] } }, + { new: true }, + ); + }); + + test('returns 500 if an error occurs when updating map location', async () => { + const { updateUserLocation } = makeSut(); + mockReq.body.requestor.role = 'Owner'; + mockReq.body.type = 'non-user'; + mockReq.body._id = '60d5f60c2f9b9c3b8a1e4a2f'; + const updateData = { + firstName: mockReq.body.firstName, + lastName: mockReq.body.lastName, + jobTitle: mockReq.body.jobTitle, + location: mockReq.body.location, + }; + + const errMsg = 'failed to update map locations!'; + const findAndUpdateSpy = jest + .spyOn(MapLocation, 'findOneAndUpdate') + .mockImplementationOnce(() => Promise.reject(new Error(errMsg))); + + const res = await updateUserLocation(mockReq, mockRes); + assertResMock(500, { message: new Error(errMsg).message }, res, mockRes); + expect(findAndUpdateSpy).toHaveBeenCalledWith( + { _id: mockReq.body._id }, + { $set: updateData }, + { new: true }, + ); + }); + + test('Returns 200 if all is successful when userType is user and clears and resets cache.', async () => { + mockReq.body.requestor.role = 'Owner'; + mockReq.body.type = 'user'; + mockReq.body._id = '60d5f60c2f9b9c3b8a1e4a2f'; + + const { mockCache: removeAllUsersMock, cacheObject } = makeMockCache('removeCache', true); + const removeUserCacheSpy = jest + .spyOn(cacheObject, 'removeCache') + .mockImplementationOnce(() => true); + + const setCacheSpy = jest.spyOn(cacheObject, 'setCache').mockImplementationOnce(() => true); + + const { updateUserLocation } = makeSut(); + + const updateData = { + firstName: mockReq.body.firstName, + lastName: mockReq.body.lastName, + jobTitle: mockReq.body.jobTitle, + location: mockReq.body.location, + }; + + const queryResponse = { + firstName: mockReq.body.firstName, + lastName: mockReq.body.lastName, + jobTitle: mockReq.body.jobTitle, + location: mockReq.body.location, + _id: mockReq.body._id, + }; + + const findOneAndUpdateSpy = jest + .spyOn(UserProfile, 'findOneAndUpdate') + .mockImplementationOnce(() => Promise.resolve(queryResponse)); + + const res = await updateUserLocation(mockReq, mockRes); + + assertResMock(200, { ...queryResponse, type: mockReq.body.type }, res, mockRes); + expect(findOneAndUpdateSpy).toHaveBeenCalledWith( + { _id: mockReq.body._id }, + { $set: { ...updateData, jobTitle: [updateData.jobTitle] } }, + { new: true }, + ); + + expect(removeAllUsersMock).toHaveBeenCalledWith('allusers'); + expect(removeUserCacheSpy).toHaveBeenCalledWith(`user-${mockReq.body._id}`); + expect(setCacheSpy).toHaveBeenCalledWith( + `user-${mockReq.body._id}`, + JSON.stringify(queryResponse), + ); + }); + + test('Returns 200 if all is succesful when userType is not user', async () => { + mockReq.body.requestor.role = 'Owner'; + mockReq.body.type = 'not-user'; + mockReq.body._id = '60d5f60c2f9b9c3b8a1e4a2f'; + + const { updateUserLocation } = makeSut(); + + const updateData = { + firstName: mockReq.body.firstName, + lastName: mockReq.body.lastName, + jobTitle: mockReq.body.jobTitle, + location: mockReq.body.location, + }; + + const queryResponse = { + firstName: mockReq.body.firstName, + lastName: mockReq.body.lastName, + jobTitle: mockReq.body.jobTitle, + location: mockReq.body.location, + _id: mockReq.body._id, + }; + + const findOneAndUpdateSpy = jest + .spyOn(MapLocation, 'findOneAndUpdate') + .mockImplementationOnce(() => Promise.resolve(queryResponse)); + + const res = await updateUserLocation(mockReq, mockRes); + + assertResMock(200, { ...queryResponse, type: mockReq.body.type }, res, mockRes); + expect(findOneAndUpdateSpy).toHaveBeenCalledWith( + { _id: mockReq.body._id }, + { $set: updateData }, + { new: true }, + ); + }); + }); +}); diff --git a/src/controllers/timeEntryController.js b/src/controllers/timeEntryController.js index 5a9b8e973..94ff0061f 100644 --- a/src/controllers/timeEntryController.js +++ b/src/controllers/timeEntryController.js @@ -704,8 +704,8 @@ const timeEntrycontroller = function (TimeEntry) { const canEditTimeEntryDescription = await hasPermission(req.body.requestor, 'editTimeEntryDescription'); const canEditTimeEntryDate = await hasPermission(req.body.requestor, 'editTimeEntryDate'); const canEditTimeEntryIsTangible = (isForAuthUser - ? (await hasPermission(req.body.requestor, 'toggleTangibleTime')) - : (await hasPermission(req.body.requestor, 'editTimeEntryToggleTangible'))); + ? !(await hasPermission(req.body.requestor, 'toggleTangibleTime')) + : !(await hasPermission(req.body.requestor, 'editTimeEntryToggleTangible'))); const isNotUsingAPermission = (!canEditTimeEntryTime && isTimeModified) || diff --git a/src/routes/mapLocationsRouter.test.js b/src/routes/mapLocationsRouter.test.js new file mode 100644 index 000000000..5eb9a87d1 --- /dev/null +++ b/src/routes/mapLocationsRouter.test.js @@ -0,0 +1,200 @@ +const request = require('supertest'); +const { jwtPayload } = require('../test'); +const { app } = require('../app'); +const { + mockReq, + createUser, + mongoHelper: { dbConnect, dbDisconnect, dbClearAll }, +} = require('../test'); +const MapLocation = require('../models/mapLocation'); + +const agent = request.agent(app); + +describe('mapLocations routes', () => { + let ownerUser; + let volunteerUser; + let ownerToken; + let volunteerToken; + let reqBody = { + ...mockReq.body, + }; + + beforeAll(async () => { + await dbConnect(); + ownerUser = await createUser(); + volunteerUser = await createUser(); + ownerUser.role = 'Owner'; + volunteerUser.role = 'Volunteer'; + ownerToken = jwtPayload(ownerUser); + volunteerToken = jwtPayload(volunteerUser); + reqBody = { + ...reqBody, + firstName: volunteerUser.firstName, + lastName: volunteerUser.lastName, + jobTitle: 'Software Engineer', + location: { + userProvided: 'A', + coords: { + lat: '51', + lng: '110', + }, + country: 'Test', + city: 'Usa', + }, + _id: volunteerUser._id, + type: 'user', + }; + }); + + afterAll(async () => { + await dbClearAll(); + await dbDisconnect(); + }); + + describe('mapLocationRoutes', () => { + it('should return 401 if authorization header is not present', async () => { + await agent.get('/api/mapLocations').send(reqBody).expect(401); + await agent.put('/api/mapLocations').send(reqBody).expect(401); + await agent.patch('/api/mapLocations').send(reqBody).expect(401); + await agent.delete('/api/mapLocations/123').send(reqBody).expect(401); + }); + + it('should return 404 if the route does not exist', async () => { + await agent + .get('/api/mapLocation') + .set('Authorization', volunteerToken) + .send(reqBody) + .expect(404); + await agent + .put('/api/mapLocation') + .set('Authorization', volunteerToken) + .send(reqBody) + .expect(404); + await agent + .patch('/api/mapLocation') + .set('Authorization', volunteerToken) + .send(reqBody) + .expect(404); + await agent + .delete('/api/mapLocation/123') + .set('Authorization', volunteerToken) + .send(reqBody) + .expect(404); + }); + }); + + describe('getMapLocation routes', () => { + it('Should return 200 and the users on success', async () => { + const expected = { + mUsers: [], + users: [ + { + location: { + city: '', + coords: { + lat: 51, + lng: 110, + }, + country: '', + userProvided: '', + }, + isActive: ownerUser.isActive, + jobTitle: ownerUser.jobTitle[0], + _id: ownerUser._id.toString(), + firstName: ownerUser.firstName, + lastName: ownerUser.lastName, + }, + { + location: { + city: '', + coords: { + lat: 51, + lng: 110, + }, + country: '', + userProvided: '', + }, + isActive: volunteerUser.isActive, + jobTitle: volunteerUser.jobTitle[0], + _id: volunteerUser._id.toString(), + firstName: volunteerUser.firstName, + lastName: volunteerUser.lastName, + }, + ], + }; + + const response = await agent + .get('/api/mapLocations') + .set('Authorization', ownerToken) + .send(reqBody) + .expect(200); + + expect(response.body).toEqual(expected); + }); + }); + + describe('putMapLocation route', () => { + it('Should return 200 on success', async () => { + const response = await agent + .put('/api/mapLocations') + .set('Authorization', ownerToken) + .send(reqBody) + .expect(200); + + const expected = { + _id: expect.anything(), + __v: expect.anything(), + firstName: reqBody.firstName, + lastName: reqBody.lastName, + jobTitle: reqBody.jobTitle, + location: reqBody.location, + isActive: false, + title: 'Prior to HGN Data Collection', + }; + + expect(response.body).toEqual(expected); + }); + }); + + describe('patchMapLocation route', () => { + it('Should return 200 on success', async () => { + reqBody.location.coords.lat = 51; + reqBody.location.coords.lng = 110; + const res = await agent + .patch('/api/mapLocations') + .set('Authorization', ownerToken) + .send(reqBody) + .expect(200); + + const expected = { + firstName: reqBody.firstName, + lastName: reqBody.lastName, + jobTitle: [reqBody.jobTitle], + location: reqBody.location, + _id: reqBody._id.toString(), + type: reqBody.type, + }; + + expect(res.body).toEqual(expected); + }); + }); + + describe('Delete map locations route', () => { + it('Should return 200 on success', async () => { + const _map = new MapLocation(); + _map.firstName = reqBody.firstName; + _map.lastName = reqBody.lastName; + _map.location = reqBody.location; + _map.jobTitle = reqBody.jobTitle; + + const map = await _map.save(); + + const res = await agent + .delete(`/api/mapLocations/${map._id}`) + .set('Authorization', ownerToken) + .send(reqBody); + + expect(res.body).toEqual({ message: 'The location was successfully removed!' }); + }); + }); +}); diff --git a/src/test/db/createUser.js b/src/test/db/createUser.js index ce487ccd6..e7c06aebc 100644 --- a/src/test/db/createUser.js +++ b/src/test/db/createUser.js @@ -5,9 +5,9 @@ const createUser = async () => { up.password = 'SuperSecretPassword@'; up.role = 'Administrator'; - up.firstName = 'requestor_first_name'; - up.lastName = 'requestor_last_name'; - up.jobTitle = ['any_job_title']; + up.firstName = 'Requestor_first_name'; + up.lastName = 'Requestor_last_name'; + up.jobTitle = ['Any_job_title']; up.phoneNumber = ['123456789']; up.bio = 'any_bio'; up.weeklycommittedHours = 21; @@ -32,8 +32,8 @@ const createUser = async () => { up.location = { userProvided: '', coords: { - lat: null, - lng: null, + lat: 51, + lng: 110, }, country: '', city: '', @@ -46,11 +46,12 @@ const createUser = async () => { up.isFirstTimelog = true; up.actualEmail = ''; up.isVisible = true; + up.totalTangibleHrs = 10; - /* - remove hard coded _id field to allow MongoDB to + /* + remove hard coded _id field to allow MongoDB to automatically create a unique id for us. - Now this function is more reusable if we + Now this function is more reusable if we need to create more than 1 user. */ diff --git a/src/utilities/errorHandling/globalErrorHandler.js b/src/utilities/errorHandling/globalErrorHandler.js index 90d3774f8..741704fb1 100644 --- a/src/utilities/errorHandling/globalErrorHandler.js +++ b/src/utilities/errorHandling/globalErrorHandler.js @@ -1,4 +1,5 @@ /* eslint-disable no-console */ +/* eslint-disable no-unused-vars */ const { v4: uuidv4 } = require('uuid'); const { CustomError } = require('./customError'); const Logger = require('../../startup/logger'); @@ -52,4 +53,4 @@ function globalErrorHandler(err, req, res, next) { }); } -export default globalErrorHandler; +module.exports = globalErrorHandler;