mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-26 04:03:03 +01:00
✨ convertBigIntToString
This commit is contained in:
parent
047066aca9
commit
6ab626fc0d
2
dist/util/checkToken.d.ts
vendored
2
dist/util/checkToken.d.ts
vendored
@ -1 +1 @@
|
||||
export declare function checkToken(token: string): Promise<unknown>;
|
||||
export declare function checkToken(token: string): Promise<any>;
|
||||
|
2
dist/util/convertBigIntToString.d.ts
vendored
Normal file
2
dist/util/convertBigIntToString.d.ts
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import "missing-native-js-functions";
|
||||
export declare function convertBigIntToString(obj: any): any;
|
16
dist/util/convertBigIntToString.js
vendored
Normal file
16
dist/util/convertBigIntToString.js
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.convertBigIntToString = void 0;
|
||||
require("missing-native-js-functions");
|
||||
function convertBigIntToString(obj) {
|
||||
if (typeof obj === "bigint")
|
||||
obj = obj.toString();
|
||||
if (typeof obj === "object") {
|
||||
obj.keys().forEach((key) => {
|
||||
obj[key] = convertBigIntToString(obj[key]);
|
||||
});
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
exports.convertBigIntToString = convertBigIntToString;
|
||||
//# sourceMappingURL=convertBigIntToString.js.map
|
1
dist/util/convertBigIntToString.js.map
vendored
Normal file
1
dist/util/convertBigIntToString.js.map
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"convertBigIntToString.js","sourceRoot":"","sources":["../../src/util/convertBigIntToString.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AAErC,SAAgB,qBAAqB,CAAC,GAAQ;IAC7C,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,GAAG,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC;IAElD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;QAC5B,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;YAClC,GAAG,CAAC,GAAG,CAAC,GAAG,qBAAqB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;KACH;IAED,OAAO,GAAG,CAAC;AACZ,CAAC;AAVD,sDAUC"}
|
1013
package-lock.json
generated
1013
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,8 @@
|
||||
"homepage": "https://github.com/discord-open-source/discord-server-util#readme",
|
||||
"dependencies": {
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"lambert-db": "^1.1.4"
|
||||
"lambert-db": "^1.1.4",
|
||||
"missing-native-js-functions": "^1.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jsonwebtoken": "^8.5.0",
|
||||
|
@ -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");
|
||||
|
13
src/util/convertBigIntToString.ts
Normal file
13
src/util/convertBigIntToString.ts
Normal file
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user