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 CHANGED
@@ -97,29 +97,34 @@ const db = Database.getInstance();
97
97
  db.connect();
98
98
  ```
99
99
 
100
- ### Using Modules from Subdirectories
100
+ ### Importing from Subdirectories
101
101
 
102
- The package organizes related functionality into modules. For example, the router module:
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 entire Router module
107
+ // Import from the root package
106
108
  import { Router } from 'topsyde-utils';
107
109
 
108
- // Create a new router
109
- const router = new Router.Router();
110
+ // Use directly without namespace
111
+ Router.SetRoutes(routes);
112
+ ```
110
113
 
111
- // Add a route
112
- router.addRoute(new Router.Route('/users', 'GET', async (req, res) => {
113
- // Handle request
114
- }));
114
+ #### 2. Import directly from subdirectories
115
115
 
116
- // Use middleware
117
- Router.applyMiddleware(req, res, [
118
- Router.commonMiddleware.logger,
119
- Router.commonMiddleware.cors
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("getInstance")) {
47
- console.warn(`${constructorName} is a singleton and should be accessed via ${constructorName}.getInstance()`);
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
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "topsyde-utils",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "A bundle of TypeScript utility classes and functions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",