Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ build
*/.DS_Store
src/models/globalBadWordsList.json
src/config/overrides.js
src/config/overrides.js
1 change: 1 addition & 0 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const defaults = {
sendGrid: "",
sendMail: "",
enableEmailAlerts: true,
maxServersPerPage: 50,

urlPrefix: "https://remo.tv/",
supportEmail: "jill@remo.tv",
Expand Down
10 changes: 10 additions & 0 deletions src/modules/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ module.exports.createTimeStamp = () => {
return Date.now();
};

module.exports.splitToChunks = (arr, chunkSize, acc = []) => (
arr.length > chunkSize ?
this.splitToChunks(
arr.slice(chunkSize),
chunkSize,
[...acc, arr.slice(0, chunkSize)]
) :
[...acc, arr]
);

module.exports.createTimer = (interval, callback, object) => {
// console.log("DING");
const timer = new setInterval(() => {
Expand Down
8 changes: 8 additions & 0 deletions src/routes/api/robotServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ const { jsonError, logger } = require("../../modules/logging");
//LIST ACTIVE SERVERS
router.get("/list", async (req, res) => {
const { getPublicServers } = require("../../controllers/robotServer");
const { maxServersPerPage } = require("../../config")
const { splitToChunks } = require("../../modules/utilities")
let display = await getPublicServers();
if ((typeof req.query.page !== 'undefined') /*if the page param is included in the query*/ && (!isNaN(+req.query.page)) /*check if it is a number*/ && (Number.isInteger(+req.query.page)) /*check if it is whole (page 2.4 isn't possible)*/) {
let pageNum = +req.query.page;
display = splitToChunks(display, maxServersPerPage)[pageNum-1]
} else {
//allow for some time before depreciation of not using page param
}
res.send(display);
});

Expand Down