diff options
author | notsapinho <52896767+notsapinho@users.noreply.github.com> | 2021-04-08 11:43:26 -0300 |
---|---|---|
committer | notsapinho <52896767+notsapinho@users.noreply.github.com> | 2021-04-08 11:43:26 -0300 |
commit | e8c097ef273100c6200c8e814965f2cb02de0bc9 (patch) | |
tree | 6cdf25485d11d7aae1a2a4efeab10e2b12ae8b86 /src/util | |
parent | Merge branch 'main' of https://github.com/fosscord/fosscord-server-util (diff) | |
download | server-e8c097ef273100c6200c8e814965f2cb02de0bc9.tar.xz |
added toBigInt and BigInt getters to bitfields
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/Database.ts | 13 | ||||
-rw-r--r-- | src/util/MongoBigInt.ts | 2 | ||||
-rw-r--r-- | src/util/checkToken.ts | 2 | ||||
-rw-r--r-- | src/util/index.ts | 1 | ||||
-rw-r--r-- | src/util/toBigInt.ts | 3 |
5 files changed, 18 insertions, 3 deletions
diff --git a/src/util/Database.ts b/src/util/Database.ts index 5d9afab9..339ac65b 100644 --- a/src/util/Database.ts +++ b/src/util/Database.ts @@ -7,7 +7,12 @@ const uri = process.env.MONGO_URL || "mongodb://localhost:27017/fosscord?readPre console.log(`[DB] connect: ${uri}`); -const connection = mongoose.createConnection(uri, { autoIndex: true, useNewUrlParser: true, useUnifiedTopology: true }); +const connection = mongoose.createConnection(uri, { + autoIndex: true, + useNewUrlParser: true, + useUnifiedTopology: true, + useFindAndModify: false, +}); export default <Connection>connection; @@ -56,6 +61,12 @@ export class MongooseCache extends EventEmitter { } }; + changeStream = (pipeline: any) => { + this.pipeline = pipeline; + this.destroy(); + this.init(); + }; + convertResult = (obj: any) => { if (obj instanceof Long) return BigInt(obj.toString()); if (typeof obj === "object") { diff --git a/src/util/MongoBigInt.ts b/src/util/MongoBigInt.ts index c4e5f623..fc451925 100644 --- a/src/util/MongoBigInt.ts +++ b/src/util/MongoBigInt.ts @@ -44,7 +44,7 @@ class LongSchema extends mongoose.SchemaType { if (val instanceof Number || "number" == typeof val) return BigInt(val); if (!Array.isArray(val) && val.toString) return BigInt(val.toString()); - // @ts-ignore + //@ts-ignore throw new SchemaType.CastError("Long", val); } diff --git a/src/util/checkToken.ts b/src/util/checkToken.ts index b4635126..d5a128b4 100644 --- a/src/util/checkToken.ts +++ b/src/util/checkToken.ts @@ -4,7 +4,7 @@ import Config from "./Config"; export function checkToken(token: string): Promise<any> { return new Promise((res, rej) => { - jwt.verify(token, Config.getAll().api.security.jwtSecret, JWTOptions, (err, decoded: any) => { + jwt.verify(token, Config.getAll()?.api?.security?.jwtSecret, JWTOptions, (err, decoded: any) => { if (err || !decoded) return rej("Invalid Token"); return res(decoded); diff --git a/src/util/index.ts b/src/util/index.ts index b0c7fe62..7e8bca20 100644 --- a/src/util/index.ts +++ b/src/util/index.ts @@ -5,3 +5,4 @@ export * from "./MessageFlags"; export * from "./Permissions"; export * from "./Snowflake"; export * from "./UserFlags"; +export * from "./toBigInt" \ No newline at end of file diff --git a/src/util/toBigInt.ts b/src/util/toBigInt.ts new file mode 100644 index 00000000..d57c4568 --- /dev/null +++ b/src/util/toBigInt.ts @@ -0,0 +1,3 @@ +export default function toBigInt(string: String): BigInt { + return BigInt(string); +} |