Skip to content

Commit

Permalink
fix: use res#json over #send for wider serialization support
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirasaki committed May 21, 2023
1 parent 673e093 commit 454c10a
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/server/commands.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ router.route('/')
const usesCategoryFilter = category !== undefined;
if (usesCategoryFilter) {
const result = queryFilterCommands(clientCommands, category, limit);
res.send(avoidStringifyBigInt(result));
res.json(avoidStringifyBigInt(result));
return;
}

// console.log(clientCommands);

// Return our command map if the map is populated
res.send(
res.json(
avoidStringifyBigInt(clientCommands)
// Limiting our result
.slice(0, limit >= 1 ? limit : clientCommands.length)
Expand All @@ -100,12 +100,12 @@ router.route('/context-menus')
const usesCategoryFilter = category !== undefined;
if (usesCategoryFilter) {
const result = queryFilterCommands(clientCtxMenus, category, limit);
res.send(avoidStringifyBigInt(result));
res.json(avoidStringifyBigInt(result));
return;
}

// Return our command map if the map is populated
res.send(
res.json(
avoidStringifyBigInt(clientCtxMenus)
// Limiting our result
.slice(0, limit >= 1 ? limit : clientCtxMenus.length)
Expand All @@ -123,12 +123,12 @@ router.route('/auto-complete')
const usesCategoryFilter = category !== undefined;
if (usesCategoryFilter) {
const result = queryFilterCommands(clientAutoCompletes, category, limit);
res.send(avoidStringifyBigInt(result));
res.json(avoidStringifyBigInt(result));
return;
}

// Return our command map if the map is populated
res.send(
res.json(
avoidStringifyBigInt(clientAutoCompletes)
// Limiting our result
.slice(0, limit >= 1 ? limit : clientAutoCompletes.length)
Expand All @@ -146,12 +146,12 @@ router.route('/buttons')
const usesCategoryFilter = category !== undefined;
if (usesCategoryFilter) {
const result = queryFilterCommands(clientButtons, category, limit);
res.send(avoidStringifyBigInt(result));
res.json(avoidStringifyBigInt(result));
return;
}

// Return our command map if the map is populated
res.send(
res.json(
avoidStringifyBigInt(clientButtons)
// Limiting our result
.slice(0, limit >= 1 ? limit : clientButtons.length)
Expand All @@ -169,12 +169,12 @@ router.route('/modals')
const usesCategoryFilter = category !== undefined;
if (usesCategoryFilter) {
const result = queryFilterCommands(clientModals, category, limit);
res.send(avoidStringifyBigInt(result));
res.json(avoidStringifyBigInt(result));
return;
}

// Return our command map if the map is populated
res.send(
res.json(
avoidStringifyBigInt(clientModals)
// Limiting our result
.slice(0, limit >= 1 ? limit : clientModals.length)
Expand All @@ -192,12 +192,12 @@ router.route('/select-menus')
const usesCategoryFilter = category !== undefined;
if (usesCategoryFilter) {
const result = queryFilterCommands(clientSelectMenus, category, limit);
res.send(avoidStringifyBigInt(result));
res.json(avoidStringifyBigInt(result));
return;
}

// Return our command map if the map is populated
res.send(
res.json(
avoidStringifyBigInt(clientSelectMenus)
// Limiting our result
.slice(0, limit >= 1 ? limit : clientSelectMenus.length)
Expand All @@ -215,7 +215,7 @@ router.route('/:name')
const { name } = req.params;
// Finding our related command
const cmd = clientCommands.find((cmd) => cmd.data.name === name);
if (cmd) res.send(avoidStringifyBigInt(cmd));
if (cmd) res.json(avoidStringifyBigInt(cmd));
else res.sendStatus(404);
});

Expand All @@ -226,7 +226,7 @@ router.route('/context-menus/:name')
const { name } = req.params;
// Finding our related command
const cmd = clientCtxMenus.find((cmd) => cmd.data.name === name);
if (cmd) res.send(avoidStringifyBigInt(cmd));
if (cmd) res.json(avoidStringifyBigInt(cmd));
else res.sendStatus(404);
});

Expand All @@ -237,7 +237,7 @@ router.route('/auto-complete/:name')
const { name } = req.params;
// Finding our related command
const cmd = clientAutoCompletes.find((cmd) => cmd.data.name === name);
if (cmd) res.send(avoidStringifyBigInt(cmd));
if (cmd) res.json(avoidStringifyBigInt(cmd));
else res.sendStatus(404);
});

Expand All @@ -248,7 +248,7 @@ router.route('/buttons/:name')
const { name } = req.params;
// Finding our related command
const cmd = clientButtons.find((cmd) => cmd.data.name === name);
if (cmd) res.send(avoidStringifyBigInt(cmd));
if (cmd) res.json(avoidStringifyBigInt(cmd));
else res.sendStatus(404);
});

Expand All @@ -259,7 +259,7 @@ router.route('/modals/:name')
const { name } = req.params;
// Finding our related command
const cmd = clientModals.find((cmd) => cmd.data.name === name);
if (cmd) res.send(avoidStringifyBigInt(cmd));
if (cmd) res.json(avoidStringifyBigInt(cmd));
else res.sendStatus(404);
});

Expand All @@ -270,7 +270,7 @@ router.route('/select-menus/:name')
const { name } = req.params;
// Finding our related command
const cmd = clientSelectMenus.find((cmd) => cmd.data.name === name);
if (cmd) res.send(avoidStringifyBigInt(cmd));
if (cmd) res.json(avoidStringifyBigInt(cmd));
else res.sendStatus(404);
});

Expand Down

0 comments on commit 454c10a

Please sign in to comment.