Skip to content
This repository has been archived by the owner on Mar 27, 2023. It is now read-only.

Commit

Permalink
fix resource buying issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tovade committed May 2, 2022
1 parent a939d0b commit 03e5f37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion frontend/pages/dashboard/store.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
<div class="mb-4">
<label class="form-control-label" for="servers">Extra Servers</label><br>
<input type="text" class="rounded form-control" name="disk"></input>
<input type="text" class="rounded form-control" name="servers"></input>
<span class="text-sm">For each extra server it will cost <%= settings.store.servers.cost %> coins</span>
</div>
<% } %>
Expand Down
18 changes: 9 additions & 9 deletions handlers/store/buy_resources.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/* eslint-disable camelcase */
const functions = require("../../functions.js");
const suspendCheck = require("../servers/suspension_system.js");
const functions = require('../../functions.js');
const suspendCheck = require('../servers/suspension_system.js');

module.exports.load = async function (app, ifValidAPI, ejs) {
app.post(
"/store/buy_resources",
'/store/buy_resources',

process.rateLimit({
windowMs: 1000,
max: 1,
message:
"You have been requesting this endpoint too fast. Please try again.",
'You have been requesting this endpoint too fast. Please try again.',
}),

async (req, res) => {
Expand Down Expand Up @@ -63,12 +63,12 @@ module.exports.load = async function (app, ifValidAPI, ejs) {
if (process.env.store[type].enabled) {
how_many_are_enabled++;

if (typeof amount === "object" && amount == null) {
if (typeof amount === 'object' && amount == null) {
test_if_all_zero++;
} else if (typeof amount !== "number") {
} else if (typeof amount !== 'number') {
resource_check_errors.push({
type: type,
reason: "not a number or null",
reason: 'not a number or null',
});
hardcoded_errors.push(
`The provided ${type} is not a number, nor null.`
Expand All @@ -84,7 +84,7 @@ module.exports.load = async function (app, ifValidAPI, ejs) {
// Due to Javascript number limitations.
resource_check_errors.push({
type: type,
reason: "number is too big",
reason: 'number is too big',
max: 1073741823 - amount,
});
hardcoded_errors.push(
Expand All @@ -96,7 +96,7 @@ module.exports.load = async function (app, ifValidAPI, ejs) {
if (check_multiple !== Math.round(check_multiple)) {
resource_check_errors.push({
type: type,
reason: "number is not a multiple of x",
reason: 'number is not a multiple of x',
x: process.env.store[type].per,
});
hardcoded_errors.push(
Expand Down

0 comments on commit 03e5f37

Please sign in to comment.