diff --git a/package-lock.json b/package-lock.json
index 7fbf5002..97ecfb8c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -14,7 +14,7 @@
"copyfiles": "^2.4.1",
"crc-32": "^1.2.2",
"express": "^5",
- "json-with-bigint": "^3.2.1",
+ "json-with-bigint": "^3.2.2",
"mongoose": "^8.11.0",
"morgan": "^1.10.0",
"typescript": ">=5.5 <5.6.0",
@@ -2348,9 +2348,9 @@
"license": "MIT"
},
"node_modules/json-with-bigint": {
- "version": "3.2.1",
- "resolved": "https://registry.npmjs.org/json-with-bigint/-/json-with-bigint-3.2.1.tgz",
- "integrity": "sha512-0f8RHpU1AwBFwIPmtm71W+cFxzlXdiBmzc3JqydsNDSKSAsr0Lso6KXRbz0h2LRwTIRiHAk/UaD+xaAN5f577w==",
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/json-with-bigint/-/json-with-bigint-3.2.2.tgz",
+ "integrity": "sha512-zbaZ+MZ2PEcAD0yINpxvlLMKzoC1GPqy5p8/ZgzRJRoB+NCczGrTX9x2ashSvkfYTitQKbV5aYQCJCiHxrzF2w==",
"license": "MIT"
},
"node_modules/json5": {
diff --git a/package.json b/package.json
index 0cd17cb3..98e770ec 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,7 @@
"copyfiles": "^2.4.1",
"crc-32": "^1.2.2",
"express": "^5",
- "json-with-bigint": "^3.2.1",
+ "json-with-bigint": "^3.2.2",
"mongoose": "^8.11.0",
"morgan": "^1.10.0",
"typescript": ">=5.5 <5.6.0",
diff --git a/src/index.ts b/src/index.ts
index f540f96e..8c38237f 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -9,25 +9,12 @@ import { app } from "./app";
import { config, validateConfig } from "./services/configService";
import { registerLogFileCreationListener } from "@/src/utils/logger";
import mongoose from "mongoose";
+import { Json, JSONStringify } from "json-with-bigint";
-// Patch JSON.stringify to work flawlessly with Bigints. Yeah, it's not pretty.
-// TODO: Might wanna use json-with-bigint if/when possible.
-{
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
- (BigInt.prototype as any).toJSON = function (): string {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
- return "" + this.toString() + "";
- };
- const og_stringify = JSON.stringify;
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- JSON.stringify = (obj: any, replacer?: any, space?: string | number): string => {
- return og_stringify(obj, replacer as string[], space)
- .split(`"`)
- .join(``)
- .split(`"`)
- .join(``);
- };
-}
+// Patch JSON.stringify to work flawlessly with Bigints.
+JSON.stringify = (obj: Exclude, _replacer?: unknown, space?: string | number): string => {
+ return JSONStringify(obj, space);
+};
registerLogFileCreationListener();
validateConfig();