mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-23 17:23:18 +00:00
✨ convertBigIntToString
This commit is contained in:
1 parent
047066aca9
commit
6ab626fc0d
8 files changed
+36
-3
No files matched your search
@@ -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");
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user