Skip to content

Commit

Permalink
round nextRequest field
Browse files Browse the repository at this point in the history
  • Loading branch information
InventivetalentDev committed Apr 30, 2024
1 parent e350986 commit bc6eff7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/generator/Generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ export class SavedSkin {
const info = await this.skin.toResponseJson();
info.duplicate = this.duplicate;
if (delayInfo) {
info.nextRequest = delayInfo.seconds; // deprecated
info.nextRequest = Math.round(delayInfo.seconds); // deprecated

info.delayInfo = {
millis: delayInfo.millis,
Expand Down
14 changes: 12 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@ import morgan from "morgan";
import * as bodyParser from "body-parser";
import fileUpload from "express-fileupload";
import cookieParser from "cookie-parser";
import { accountManagerRoute, accountRoute, apiKeyRoute, generateRoute, getRoute, hiatusRoute, renderRoute, testerRoute, utilRoute } from "./routes";
import {
accountManagerRoute,
accountRoute,
apiKeyRoute,
generateRoute,
getRoute,
hiatusRoute,
renderRoute,
testerRoute,
utilRoute
} from "./routes";
import { MOJ_DIR, UPL_DIR, URL_DIR } from "./generator/Temp";
import { getConfig, getLocalConfig, MineSkinConfig } from "./typings/Configs";
import { isBreadRequest, MineSkinError } from "./typings";
Expand Down Expand Up @@ -302,7 +312,7 @@ async function init() {
errorType: err.name,
errorCode: err.code,
error: err.msg,
nextRequest: (Date.now() / 1000) + delayInfo.seconds, // deprecated
nextRequest: Math.round((Date.now() / 1000) + delayInfo.seconds), // deprecated

delayInfo: {
seconds: delayInfo.seconds,
Expand Down
2 changes: 1 addition & 1 deletion src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export async function checkTraffic(req: Request, res: Response): Promise<boolean
if (lastRequest.getTime() > time - delayInfo.millis) {
res.status(429).json({
error: "Too many requests",
nextRequest: (time / 1000) + delayInfo.seconds + 5, // deprecated
nextRequest: Math.round((time / 1000) + delayInfo.seconds + 5), // deprecated
delay: delayInfo.seconds, // deprecated

delayInfo: {
Expand Down

0 comments on commit bc6eff7

Please sign in to comment.