equipped 5.0.0-beta.13 → 5.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/lib/server/impls/base.js +11 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [5.0.0-beta.14](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.13...v5.0.0-beta.14) (2024-06-02)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* use maps for registered maps for speed ([1882a24](https://github.com/kevinand11/equipped/commit/1882a24d02d666e7779212dbeb67e1022761c823))
|
|
11
|
+
|
|
5
12
|
## [5.0.0-beta.13](https://github.com/kevinand11/equipped/compare/v5.0.0-beta.12...v5.0.0-beta.13) (2024-06-01)
|
|
6
13
|
|
|
7
14
|
|
package/lib/server/impls/base.js
CHANGED
|
@@ -13,7 +13,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
13
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
|
-
var _Server_instances,
|
|
16
|
+
var _Server_instances, _Server_routesByPath, _Server_routesByKey, _Server_schemas, _Server_listener, _Server_regRoute;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.Server = void 0;
|
|
19
19
|
const socket_io_1 = __importDefault(require("socket.io"));
|
|
@@ -25,7 +25,8 @@ const middlewares_1 = require("../middlewares");
|
|
|
25
25
|
class Server {
|
|
26
26
|
constructor(server) {
|
|
27
27
|
_Server_instances.add(this);
|
|
28
|
-
|
|
28
|
+
_Server_routesByPath.set(this, new Map());
|
|
29
|
+
_Server_routesByKey.set(this, new Map());
|
|
29
30
|
_Server_schemas.set(this, {});
|
|
30
31
|
_Server_listener.set(this, null);
|
|
31
32
|
this.staticPath = path_1.default.join(process.cwd(), 'public');
|
|
@@ -95,7 +96,7 @@ class Server {
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
exports.Server = Server;
|
|
98
|
-
|
|
99
|
+
_Server_routesByPath = new WeakMap(), _Server_routesByKey = new WeakMap(), _Server_schemas = new WeakMap(), _Server_listener = new WeakMap(), _Server_instances = new WeakSet(), _Server_regRoute = function _Server_regRoute(route) {
|
|
99
100
|
if (!route.path.startsWith('/'))
|
|
100
101
|
route.path = `/${route.path}`;
|
|
101
102
|
const middlewares = [middlewares_1.parseAuthUser, ...(route.middlewares ?? [])];
|
|
@@ -103,7 +104,8 @@ _Server_routes = new WeakMap(), _Server_schemas = new WeakMap(), _Server_listene
|
|
|
103
104
|
route.onSetupHandler?.(route);
|
|
104
105
|
route.onError?.onSetup?.(route);
|
|
105
106
|
const { method, path, handler, schema, security, onError, hideSchema = false } = route;
|
|
106
|
-
const
|
|
107
|
+
const pathKey = `(${method.toUpperCase()}) ${path}`;
|
|
108
|
+
const { key = pathKey } = route;
|
|
107
109
|
const scheme = schema ?? __classPrivateFieldGet(this, _Server_schemas, "f")[key] ?? {};
|
|
108
110
|
const fullRoute = {
|
|
109
111
|
method, middlewares, handler, key,
|
|
@@ -118,12 +120,11 @@ _Server_routes = new WeakMap(), _Server_schemas = new WeakMap(), _Server_listene
|
|
|
118
120
|
security,
|
|
119
121
|
}
|
|
120
122
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (
|
|
123
|
+
if (__classPrivateFieldGet(this, _Server_routesByPath, "f").get(pathKey))
|
|
124
|
+
throw new Error(`Route path ${pathKey} already registered. All route paths and methods combinations must be unique`);
|
|
125
|
+
if (__classPrivateFieldGet(this, _Server_routesByKey, "f").get(key))
|
|
124
126
|
throw new Error(`Route key ${fullRoute.key} already registered. All route keys must be unique`);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
__classPrivateFieldGet(this, _Server_routes, "f").push(fullRoute);
|
|
127
|
+
__classPrivateFieldGet(this, _Server_routesByPath, "f").set(pathKey, fullRoute);
|
|
128
|
+
__classPrivateFieldGet(this, _Server_routesByKey, "f").set(key, fullRoute);
|
|
128
129
|
this.registerRoute(fullRoute);
|
|
129
130
|
};
|