perf: use the builtin UUID generator for Peer ids instead of the uuid
module
This commit is contained in:
parent
1aaafbc450
commit
5d882dd0c6
28
package-lock.json
generated
28
package-lock.json
generated
@ -12,7 +12,6 @@
|
|||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"uuid": "^3.4.0",
|
|
||||||
"ws": "^7.2.3",
|
"ws": "^7.2.3",
|
||||||
"yargs": "^15.3.1"
|
"yargs": "^15.3.1"
|
||||||
},
|
},
|
||||||
@ -27,7 +26,6 @@
|
|||||||
"@types/express": "^4.17.3",
|
"@types/express": "^4.17.3",
|
||||||
"@types/mocha": "^7.0.2",
|
"@types/mocha": "^7.0.2",
|
||||||
"@types/node": "^14.18.33",
|
"@types/node": "^14.18.33",
|
||||||
"@types/uuid": "^3.4.8",
|
|
||||||
"@types/ws": "^7.2.3",
|
"@types/ws": "^7.2.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.24.0",
|
"@typescript-eslint/eslint-plugin": "^2.24.0",
|
||||||
"@typescript-eslint/parser": "^2.24.0",
|
"@typescript-eslint/parser": "^2.24.0",
|
||||||
@ -1095,12 +1093,6 @@
|
|||||||
"@types/mime": "*"
|
"@types/mime": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/uuid": {
|
|
||||||
"version": "3.4.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.8.tgz",
|
|
||||||
"integrity": "sha512-zHWce3allXWSmRx6/AGXKCtSOA7JjeWd2L3t4aHfysNk8mouQnWCocveaT7a4IEIlPVHp81jzlnknqTgCjCLXA==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/@types/ws": {
|
"node_modules/@types/ws": {
|
||||||
"version": "7.2.3",
|
"version": "7.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.2.3.tgz",
|
||||||
@ -9536,15 +9528,6 @@
|
|||||||
"node": ">= 0.4.0"
|
"node": ">= 0.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/uuid": {
|
|
||||||
"version": "3.4.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
|
||||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
|
||||||
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
|
||||||
"bin": {
|
|
||||||
"uuid": "bin/uuid"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/v8-compile-cache": {
|
"node_modules/v8-compile-cache": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz",
|
||||||
@ -10697,12 +10680,6 @@
|
|||||||
"@types/mime": "*"
|
"@types/mime": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/uuid": {
|
|
||||||
"version": "3.4.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.8.tgz",
|
|
||||||
"integrity": "sha512-zHWce3allXWSmRx6/AGXKCtSOA7JjeWd2L3t4aHfysNk8mouQnWCocveaT7a4IEIlPVHp81jzlnknqTgCjCLXA==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"@types/ws": {
|
"@types/ws": {
|
||||||
"version": "7.2.3",
|
"version": "7.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.2.3.tgz",
|
||||||
@ -16919,11 +16896,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||||
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
|
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
|
||||||
},
|
},
|
||||||
"uuid": {
|
|
||||||
"version": "3.4.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
|
||||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
|
|
||||||
},
|
|
||||||
"v8-compile-cache": {
|
"v8-compile-cache": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz",
|
||||||
|
@ -43,7 +43,6 @@
|
|||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"uuid": "^3.4.0",
|
|
||||||
"ws": "^7.2.3",
|
"ws": "^7.2.3",
|
||||||
"yargs": "^15.3.1"
|
"yargs": "^15.3.1"
|
||||||
},
|
},
|
||||||
@ -55,7 +54,6 @@
|
|||||||
"@types/express": "^4.17.3",
|
"@types/express": "^4.17.3",
|
||||||
"@types/mocha": "^7.0.2",
|
"@types/mocha": "^7.0.2",
|
||||||
"@types/node": "^14.18.33",
|
"@types/node": "^14.18.33",
|
||||||
"@types/uuid": "^3.4.8",
|
|
||||||
"@types/ws": "^7.2.3",
|
"@types/ws": "^7.2.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.24.0",
|
"@typescript-eslint/eslint-plugin": "^2.24.0",
|
||||||
"@typescript-eslint/parser": "^2.24.0",
|
"@typescript-eslint/parser": "^2.24.0",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import uuidv4 from "uuid/v4";
|
|
||||||
import { IClient } from "./client";
|
import { IClient } from "./client";
|
||||||
import { IMessage } from "./message";
|
import { IMessage } from "./message";
|
||||||
import { IMessageQueue, MessageQueue } from "./messageQueue";
|
import { IMessageQueue, MessageQueue } from "./messageQueue";
|
||||||
|
import {randomUUID} from "crypto";
|
||||||
|
|
||||||
export interface IRealm {
|
export interface IRealm {
|
||||||
getClientsIds(): string[];
|
getClientsIds(): string[];
|
||||||
@ -70,7 +70,7 @@ export class Realm implements IRealm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public generateClientId(generateClientId?: () => string): string {
|
public generateClientId(generateClientId?: () => string): string {
|
||||||
const generateId = generateClientId ? generateClientId : uuidv4;
|
const generateId = generateClientId ? generateClientId : randomUUID;
|
||||||
|
|
||||||
let clientId = generateId();
|
let clientId = generateId();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user