@dws-std/registry 1.2.0 → 1.3.0
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/README.md +5 -5
- package/dist/index.js +7 -7
- package/dist/registry.d.ts +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -42,11 +42,11 @@ Register your instances once at startup. They're available everywhere after that
|
|
|
42
42
|
import { Registry } from '@dws-std/registry';
|
|
43
43
|
|
|
44
44
|
class DatabaseConnection {
|
|
45
|
-
private
|
|
45
|
+
private isConnected: boolean = false;
|
|
46
46
|
|
|
47
47
|
public constructor() {
|
|
48
48
|
console.log('Database connection created');
|
|
49
|
-
this.
|
|
49
|
+
this.isConnected = true;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
public query(sql: string): string[] {
|
|
@@ -56,12 +56,12 @@ class DatabaseConnection {
|
|
|
56
56
|
|
|
57
57
|
class ApiClient {
|
|
58
58
|
public constructor(
|
|
59
|
-
private readonly
|
|
60
|
-
private readonly
|
|
59
|
+
private readonly baseUrl: string,
|
|
60
|
+
private readonly apiKey: string
|
|
61
61
|
) {}
|
|
62
62
|
|
|
63
63
|
public get baseUrl(): string {
|
|
64
|
-
return this.
|
|
64
|
+
return this.baseUrl;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
package/dist/index.js
CHANGED
|
@@ -7,24 +7,24 @@ var REGISTRY_ERROR_KEYS = {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
class Registry {
|
|
10
|
-
static
|
|
10
|
+
static registry = new Map;
|
|
11
11
|
static register(name, instance) {
|
|
12
|
-
if (this.
|
|
12
|
+
if (this.registry.has(name))
|
|
13
13
|
throw new Exception(`Instance already registered: ${name}`, {
|
|
14
14
|
key: REGISTRY_ERROR_KEYS.CLASS_INSTANCE_ALREADY_REGISTERED,
|
|
15
15
|
cause: name
|
|
16
16
|
});
|
|
17
|
-
this.
|
|
17
|
+
this.registry.set(name, instance);
|
|
18
18
|
}
|
|
19
19
|
static unregister(name) {
|
|
20
|
-
if (!this.
|
|
20
|
+
if (!this.registry.delete(name))
|
|
21
21
|
throw new Exception(`Instance not registered: ${name}`, {
|
|
22
22
|
key: REGISTRY_ERROR_KEYS.CLASS_INSTANCE_NOT_REGISTERED,
|
|
23
23
|
cause: name
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
static get(name) {
|
|
27
|
-
const instance = this.
|
|
27
|
+
const instance = this.registry.get(name);
|
|
28
28
|
if (!instance)
|
|
29
29
|
throw new Exception(`Instance not registered: ${name}`, {
|
|
30
30
|
key: REGISTRY_ERROR_KEYS.CLASS_INSTANCE_NOT_REGISTERED,
|
|
@@ -33,10 +33,10 @@ class Registry {
|
|
|
33
33
|
return instance;
|
|
34
34
|
}
|
|
35
35
|
static has(name) {
|
|
36
|
-
return this.
|
|
36
|
+
return this.registry.has(name);
|
|
37
37
|
}
|
|
38
38
|
static clear() {
|
|
39
|
-
this.
|
|
39
|
+
this.registry.clear();
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
export {
|
package/dist/registry.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dws-std/registry",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Centralized, type-safe registry for managing named instances.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
"test": "bun test --pass-with-no-tests --coverage"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@dws-std/error": "^2.
|
|
41
|
+
"@dws-std/error": "^2.3.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/bun": "^1.3.
|
|
45
|
-
"oxfmt": "0.
|
|
46
|
-
"oxlint": "1.
|
|
47
|
-
"oxlint-tsgolint": "0.
|
|
48
|
-
"typescript": "^6.0.
|
|
44
|
+
"@types/bun": "^1.3.14",
|
|
45
|
+
"oxfmt": "0.55.0",
|
|
46
|
+
"oxlint": "1.70.0",
|
|
47
|
+
"oxlint-tsgolint": "0.23.0",
|
|
48
|
+
"typescript": "^6.0.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@dws-std/error": "^2.
|
|
51
|
+
"@dws-std/error": "^2.3.0"
|
|
52
52
|
}
|
|
53
53
|
}
|