summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-06 09:20:07 +0100
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-06 09:20:07 +0100
commit6ab626fc0dcb4ce62345c9ee967ba300474728e2 (patch)
tree70732944b28d7daec211484c7452092f3e3c4d18 /src
parent:bug: export files and classes (diff)
downloadserver-6ab626fc0dcb4ce62345c9ee967ba300474728e2.tar.xz
:sparkles: convertBigIntToString
Diffstat (limited to 'src')
-rw-r--r--src/util/checkToken.ts2
-rw-r--r--src/util/convertBigIntToString.ts13
2 files changed, 14 insertions, 1 deletions
diff --git a/src/util/checkToken.ts b/src/util/checkToken.ts

index 96c7806a..b4635126 100644 --- a/src/util/checkToken.ts +++ b/src/util/checkToken.ts
@@ -2,7 +2,7 @@ import { JWTOptions } from "./Constants"; import jwt from "jsonwebtoken"; import Config from "./Config"; -export function checkToken(token: string) { +export function checkToken(token: string): Promise<any> { return new Promise((res, rej) => { jwt.verify(token, Config.getAll().api.security.jwtSecret, JWTOptions, (err, decoded: any) => { if (err || !decoded) return rej("Invalid Token"); diff --git a/src/util/convertBigIntToString.ts b/src/util/convertBigIntToString.ts new file mode 100644
index 00000000..2c8d9a38 --- /dev/null +++ b/src/util/convertBigIntToString.ts
@@ -0,0 +1,13 @@ +import "missing-native-js-functions"; + +export function convertBigIntToString(obj: any) { + if (typeof obj === "bigint") obj = obj.toString(); + + if (typeof obj === "object") { + obj.keys().forEach((key: string) => { + obj[key] = convertBigIntToString(obj[key]); + }); + } + + return obj; +}