topsyde-utils 1.0.14 → 1.0.15
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 +19 -14
- package/dist/singleton.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
@@ -97,29 +97,34 @@ const db = Database.getInstance();
|
|
97
97
|
db.connect();
|
98
98
|
```
|
99
99
|
|
100
|
-
###
|
100
|
+
### Importing from Subdirectories
|
101
101
|
|
102
|
-
The package
|
102
|
+
The package supports two ways to import modules:
|
103
|
+
|
104
|
+
#### 1. Import from the root package
|
103
105
|
|
104
106
|
```typescript
|
105
|
-
// Import the
|
107
|
+
// Import from the root package
|
106
108
|
import { Router } from 'topsyde-utils';
|
107
109
|
|
108
|
-
//
|
109
|
-
|
110
|
+
// Use directly without namespace
|
111
|
+
Router.SetRoutes(routes);
|
112
|
+
```
|
110
113
|
|
111
|
-
|
112
|
-
router.addRoute(new Router.Route('/users', 'GET', async (req, res) => {
|
113
|
-
// Handle request
|
114
|
-
}));
|
114
|
+
#### 2. Import directly from subdirectories
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
116
|
+
```typescript
|
117
|
+
// Import directly from a subdirectory
|
118
|
+
import { Router, Routes } from 'topsyde-utils/router';
|
119
|
+
import { Controller } from 'topsyde-utils/server';
|
120
|
+
|
121
|
+
// Use the imported classes directly
|
122
|
+
Router.SetRoutes(routes);
|
123
|
+
const controller = new Controller();
|
121
124
|
```
|
122
125
|
|
126
|
+
This approach provides more flexibility and cleaner imports, especially when you only need specific components from a subdirectory.
|
127
|
+
|
123
128
|
## API Documentation
|
124
129
|
|
125
130
|
### Throwable
|
package/dist/singleton.js
CHANGED
@@ -43,8 +43,8 @@ class Singleton {
|
|
43
43
|
// Ensure the constructor is only called from getInstance
|
44
44
|
const constructorName = this.constructor.name;
|
45
45
|
const callerName = new Error().stack?.split("\n")[2]?.trim() || "";
|
46
|
-
if (!callerName.includes("
|
47
|
-
console.warn(`${constructorName} is a singleton and should be accessed via ${constructorName}.
|
46
|
+
if (!callerName.includes("GetInstance")) {
|
47
|
+
console.warn(`${constructorName} is a singleton and should be accessed via ${constructorName}.GetInstance()`);
|
48
48
|
}
|
49
49
|
}
|
50
50
|
/**
|