Skip to content

Commit 7e485f6

Browse files
committed
Merge branch 'develop' of https://github.com/Real-Dev-Squad/website-backend into feat/cpllapsed-task
2 parents a88776b + 1c45b33 commit 7e485f6

23 files changed

+103
-91
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ name: Tests
66
on:
77
pull_request:
88
branches:
9-
- '**'
9+
- "**"
1010

1111
jobs:
1212
build:
13-
1413
runs-on: ubuntu-latest
1514

1615
strategy:
1716
matrix:
18-
node-version: [14.x]
17+
node-version: [18.x]
1918

2019
steps:
2120
- uses: actions/checkout@v3

controllers/arts.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const artsQuery = require("../models/arts");
2-
2+
const { SOMETHING_WENT_WRONG, INTERNAL_SERVER_ERROR } = require("../constants/errorMessages");
33
/**
44
* Adds art
55
*
@@ -17,7 +17,7 @@ const addArt = async (req, res) => {
1717
});
1818
} catch (error) {
1919
logger.error(`Error adding art: ${error}`);
20-
return res.boom.serverUnavailable("Something went wrong please contact admin");
20+
return res.boom.serverUnavailable(SOMETHING_WENT_WRONG);
2121
}
2222
};
2323

@@ -36,7 +36,7 @@ const fetchArts = async (req, res) => {
3636
});
3737
} catch (err) {
3838
logger.error(`Error while fetching arts ${err}`);
39-
return res.boom.badImplementation("An internal server error occurred");
39+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
4040
}
4141
};
4242

@@ -56,7 +56,7 @@ const getSelfArts = async (req, res) => {
5656
});
5757
} catch (err) {
5858
logger.error(`Error while getting user arts ${err}`);
59-
return res.boom.badImplementation("An internal server error occurred");
59+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
6060
}
6161
};
6262

@@ -70,7 +70,7 @@ const getUserArts = async (req, res) => {
7070
});
7171
} catch (err) {
7272
logger.error(`Error while getting user arts ${err}`);
73-
return res.boom.badImplementation("An internal server error occurred");
73+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
7474
}
7575
};
7676

controllers/auction.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const auctions = require("../models/auctions");
22
const wallet = require("../models/wallets");
3+
const { INTERNAL_SERVER_ERROR } = require("../constants/errorMessages");
34

45
/**
56
* Fetches all the active (ongoing) auctions
@@ -16,7 +17,7 @@ const fetchAvailableAuctions = async (_req, res) => {
1617
});
1718
} catch (error) {
1819
logger.error(`Error fetching available auctions: ${error}`);
19-
return res.boom.badImplementation("An internal server error occured.");
20+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
2021
}
2122
};
2223

@@ -36,7 +37,7 @@ const fetchAuctionById = async (req, res) => {
3637
return res.json(auctionData);
3738
} catch (error) {
3839
logger.error(`Error fetching auction: ${error}`);
39-
return res.boom.badImplementation("An internal server error occured.");
40+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
4041
}
4142
};
4243

@@ -59,7 +60,7 @@ const createNewAuction = async (req, res) => {
5960
return res.status(201).json({ id: auctionId, message: "Auction created successfully!" });
6061
} catch (error) {
6162
logger.error(`Error creating new auctions: ${error}`);
62-
return res.boom.badImplementation("An internal server error occured.");
63+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
6364
}
6465
};
6566

@@ -84,7 +85,7 @@ const makeNewBid = async (req, res) => {
8485
return res.status(201).json({ message: "Successfully placed bid!" });
8586
} catch (error) {
8687
logger.error(`Error creating new auctions: ${error}`);
87-
return res.boom.badImplementation("An internal server error occured.");
88+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
8889
}
8990
};
9091

controllers/challenge.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const challengeQuery = require("../models/challenges");
2-
3-
const ERROR_MESSAGE = "Something went wrong. Please try again or contact admin";
2+
const { SOMETHING_WENT_WRONG } = require("../constants/errorMessages");
43

54
/**
65
* Get the challenges
@@ -19,7 +18,7 @@ const fetchChallenges = async (req, res) => {
1918
});
2019
} catch (err) {
2120
logger.error(`Error while retrieving challenges ${err}`);
22-
return res.boom.serverUnavailable(ERROR_MESSAGE);
21+
return res.boom.serverUnavailable(SOMETHING_WENT_WRONG);
2322
}
2423
};
2524

@@ -41,7 +40,7 @@ const createChallenge = async (req, res) => {
4140
}
4241
} catch (err) {
4342
logger.error(`Error while adding challenge ${err}`);
44-
return res.boom.serverUnavailable(ERROR_MESSAGE);
43+
return res.boom.serverUnavailable(SOMETHING_WENT_WRONG);
4544
}
4645
};
4746

@@ -79,7 +78,7 @@ const subscribeToChallenge = async (req, res) => {
7978
}
8079
} catch (err) {
8180
logger.error(`Error while retrieving challenges ${err}`);
82-
return res.boom.serverUnavailable(ERROR_MESSAGE);
81+
return res.boom.serverUnavailable(SOMETHING_WENT_WRONG);
8382
}
8483
};
8584

controllers/contributions.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const contributionsService = require("../services/contributions");
22
const { fetchUser } = require("../models/users");
3-
4-
const ERROR_MESSAGE = "Something went wrong. Please try again or contact admin";
3+
const { SOMETHING_WENT_WRONG } = require("../constants/errorMessages");
54

65
/**
76
* Get the contributions of the user
@@ -20,7 +19,7 @@ const getUserContributions = async (req, res) => {
2019
return res.boom.notFound("User doesn't exist");
2120
} catch (err) {
2221
logger.error(`Error while retriving contributions ${err}`);
23-
return res.boom.badImplementation(ERROR_MESSAGE);
22+
return res.boom.badImplementation(SOMETHING_WENT_WRONG);
2423
}
2524
};
2625

controllers/extensionRequests.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { addLog } = require("../models/logs");
33
const tasks = require("../models/tasks");
44
const { getUsername } = require("../utils/users");
55
const { EXTENSION_REQUEST_STATUS } = require("../constants/extensionRequests");
6-
6+
const { INTERNAL_SERVER_ERROR } = require("../constants/errorMessages");
77
/**
88
* Create ETA extension Request
99
*
@@ -66,7 +66,7 @@ const createTaskExtensionRequest = async (req, res) => {
6666
});
6767
} catch (err) {
6868
logger.error(`Error while creating new extension request: ${err}`);
69-
return res.boom.badImplementation("An internal server error occurred");
69+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
7070
}
7171
};
7272

@@ -87,7 +87,7 @@ const fetchExtensionRequests = async (req, res) => {
8787
});
8888
} catch (err) {
8989
logger.error(`Error while fetching Extension Requests ${err}`);
90-
return res.boom.badImplementation("An internal server error occurred");
90+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
9191
}
9292
};
9393

@@ -102,7 +102,7 @@ const getExtensionRequest = async (req, res) => {
102102
extensionRequestData.id = extensionRequestId;
103103
return res.json({ message: "Extension Requests returned successfully!", extensionRequest: extensionRequestData });
104104
} catch (err) {
105-
return res.boom.badImplementation("An internal server error occurred");
105+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
106106
}
107107
};
108108

@@ -128,7 +128,7 @@ const getSelfExtensionRequests = async (req, res) => {
128128
return res.boom.notFound("User doesn't exist");
129129
} catch (error) {
130130
logger.error(`Error while fetching extension requests: ${error}`);
131-
return res.boom.badImplementation("An internal server error occured");
131+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
132132
}
133133
};
134134

@@ -156,7 +156,7 @@ const updateExtensionRequest = async (req, res) => {
156156
return res.status(204).send();
157157
} catch (err) {
158158
logger.error(`Error while updating extension request: ${err}`);
159-
return res.boom.badImplementation("An internal server error occurred");
159+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
160160
}
161161
};
162162

@@ -221,7 +221,7 @@ const updateExtensionRequestStatus = async (req, res) => {
221221
return res.json({ message: `Extension request ${extensionStatus} succesfully`, extensionLog });
222222
} catch (err) {
223223
logger.error(`Error while updating extension request: ${err}`);
224-
return res.boom.badImplementation("An internal server error occurred");
224+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
225225
}
226226
};
227227

controllers/external-accounts.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const externalAccountsModel = require("../models/external-accounts");
2+
const { SOMETHING_WENT_WRONG } = require("../constants/errorMessages");
23

34
const addExternalAccountData = async (req, res) => {
45
const createdOn = Date.now();
@@ -17,7 +18,7 @@ const addExternalAccountData = async (req, res) => {
1718
return res.status(201).json({ message: "Added external account data successfully" });
1819
} catch (error) {
1920
logger.error(`Error adding data: ${error}`);
20-
return res.boom.serverUnavailable("Something went wrong please contact admin");
21+
return res.boom.serverUnavailable(SOMETHING_WENT_WRONG);
2122
}
2223
};
2324

@@ -36,7 +37,7 @@ const getExternalAccountData = async (req, res) => {
3637
return res.status(200).json({ message: "Data returned successfully", attributes: attributes });
3738
} catch (error) {
3839
logger.error(`Error getting external account data: ${error}`);
39-
return res.boom.serverUnavailable("Something went wrong please contact admin");
40+
return res.boom.serverUnavailable(SOMETHING_WENT_WRONG);
4041
}
4142
};
4243

controllers/items.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const ItemTagsModel = require("../models/items");
2+
const { INTERNAL_SERVER_ERROR } = require("../constants/errorMessages");
23

34
/**
45
* Adds a tag to an item with its corresponding a level
@@ -16,7 +17,7 @@ const addTagsToItem = async (req, res) => {
1617
});
1718
} catch (err) {
1819
logger.error(`Error while creating new item: ${err}`);
19-
return res.boom.badImplementation("An internal server error occurred");
20+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
2021
}
2122
};
2223

@@ -37,7 +38,7 @@ const removeTagsFromItem = async (req, res) => {
3738
});
3839
} catch (err) {
3940
logger.error(`Error while creating new item: ${err}`);
40-
return res.boom.badImplementation("An internal server error occurred");
41+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
4142
}
4243
};
4344

@@ -60,7 +61,7 @@ const getItemBasedOnFilter = async (req, res) => {
6061
});
6162
} catch (err) {
6263
logger.error(`Error while creating new item: ${err}`);
63-
return res.boom.badImplementation("An internal server error occurred");
64+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
6465
}
6566
};
6667

controllers/levels.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const LevelModel = require("../models/levels");
22
const admin = require("firebase-admin");
3+
const { INTERNAL_SERVER_ERROR } = require("../constants/errorMessages");
34

45
/**
56
* Creates a level
@@ -24,7 +25,7 @@ const addLevel = async (req, res) => {
2425
});
2526
} catch (err) {
2627
logger.error(`Error while creating new level: ${err}`);
27-
return res.boom.badImplementation("An internal server error occurred");
28+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
2829
}
2930
};
3031

@@ -43,7 +44,7 @@ const deleteLevel = async (req, res) => {
4344
});
4445
} catch (err) {
4546
logger.error(`Error while creating new Level: ${err}`);
46-
return res.boom.badImplementation("An internal server error occurred");
47+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
4748
}
4849
};
4950

@@ -62,7 +63,7 @@ const getAllLevels = async (req, res) => {
6263
});
6364
} catch (err) {
6465
logger.error(`Error while creating new Level: ${err}`);
65-
return res.boom.badImplementation("An internal server error occurred");
66+
return res.boom.badImplementation(INTERNAL_SERVER_ERROR);
6667
}
6768
};
6869

controllers/logs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const logsQuery = require("../models/logs");
2+
const { SOMETHING_WENT_WRONG } = require("../constants/errorMessages");
23

34
/**
45
* Fetches logs
@@ -15,7 +16,7 @@ const fetchLogs = async (req, res) => {
1516
});
1617
} catch (error) {
1718
logger.error(`Error while fetching logs: ${error}`);
18-
return res.boom.serverUnavailable("Something went wrong please contact admin");
19+
return res.boom.serverUnavailable(SOMETHING_WENT_WRONG);
1920
}
2021
};
2122

0 commit comments

Comments
 (0)