wooks 0.7.10 → 0.7.12
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/dist/index.cjs +18 -43
- package/dist/index.mjs +0 -3
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -1,35 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
const __prostojs_logger = __toESM(require("@prostojs/logger"));
|
|
25
|
-
const __prostojs_router = __toESM(require("@prostojs/router"));
|
|
26
|
-
const __wooksjs_event_core = __toESM(require("@wooksjs/event-core"));
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _prostojs_logger = require("@prostojs/logger");
|
|
3
|
+
let _prostojs_router = require("@prostojs/router");
|
|
4
|
+
let _wooksjs_event_core = require("@wooksjs/event-core");
|
|
27
5
|
|
|
28
6
|
//#region packages/wooks/src/wooks.ts
|
|
29
7
|
function getDefaultLogger(topic) {
|
|
30
|
-
return new
|
|
8
|
+
return new _prostojs_logger.ProstoLogger({
|
|
31
9
|
level: 4,
|
|
32
|
-
transports: [(0,
|
|
10
|
+
transports: [(0, _prostojs_logger.createConsoleTransort)({ format: _prostojs_logger.coloredConsole })]
|
|
33
11
|
}, topic);
|
|
34
12
|
}
|
|
35
13
|
/**
|
|
@@ -42,11 +20,9 @@ function getDefaultLogger(topic) {
|
|
|
42
20
|
* ```
|
|
43
21
|
*/
|
|
44
22
|
var Wooks = class {
|
|
45
|
-
router;
|
|
46
|
-
logger;
|
|
47
23
|
/** @param opts - Optional configuration for router and logger. */
|
|
48
24
|
constructor(opts) {
|
|
49
|
-
this.router = new
|
|
25
|
+
this.router = new _prostojs_router.ProstoRouter({
|
|
50
26
|
silent: true,
|
|
51
27
|
...opts?.router
|
|
52
28
|
});
|
|
@@ -61,12 +37,12 @@ var Wooks = class {
|
|
|
61
37
|
* @param topic - Label for the logger topic.
|
|
62
38
|
*/
|
|
63
39
|
getLogger(topic) {
|
|
64
|
-
if (this.logger instanceof
|
|
40
|
+
if (this.logger instanceof _prostojs_logger.ProstoLogger) return this.logger.createTopic(topic);
|
|
65
41
|
return this.logger;
|
|
66
42
|
}
|
|
67
43
|
/** Returns the current logger configuration options. */
|
|
68
44
|
getLoggerOptions() {
|
|
69
|
-
if (this.logger instanceof
|
|
45
|
+
if (this.logger instanceof _prostojs_logger.ProstoLogger) return this.logger.getOptions();
|
|
70
46
|
return {};
|
|
71
47
|
}
|
|
72
48
|
/**
|
|
@@ -74,10 +50,10 @@ var Wooks = class {
|
|
|
74
50
|
* @param method - HTTP method (e.g., "GET", "POST").
|
|
75
51
|
* @param path - URL path to match against registered routes.
|
|
76
52
|
*/
|
|
77
|
-
lookup(method, path, ctx = (0,
|
|
53
|
+
lookup(method, path, ctx = (0, _wooksjs_event_core.current)()) {
|
|
78
54
|
const found = this.getRouter().lookup(method, path || "");
|
|
79
|
-
ctx.set(
|
|
80
|
-
const ci = (0,
|
|
55
|
+
ctx.set(_wooksjs_event_core.routeParamsKey, found?.ctx?.params || {});
|
|
56
|
+
const ci = (0, _wooksjs_event_core.getContextInjector)();
|
|
81
57
|
if (found?.route?.handlers.length) ci?.hook(method, "Handler:routed", found.route.path);
|
|
82
58
|
else ci?.hook(method, "Handler:not_found");
|
|
83
59
|
return {
|
|
@@ -91,10 +67,10 @@ var Wooks = class {
|
|
|
91
67
|
* Fast lookup that returns only the handlers array (or null).
|
|
92
68
|
* Avoids allocating a result object on each request.
|
|
93
69
|
*/
|
|
94
|
-
lookupHandlers(method, path, ctx = (0,
|
|
70
|
+
lookupHandlers(method, path, ctx = (0, _wooksjs_event_core.current)()) {
|
|
95
71
|
const found = this.getRouter().lookup(method, path || "");
|
|
96
|
-
ctx.set(
|
|
97
|
-
const ci = (0,
|
|
72
|
+
ctx.set(_wooksjs_event_core.routeParamsKey, found?.ctx?.params || {});
|
|
73
|
+
const ci = (0, _wooksjs_event_core.getContextInjector)();
|
|
98
74
|
if (found?.route?.handlers.length) {
|
|
99
75
|
ci?.hook(method, "Handler:routed", found.route.path);
|
|
100
76
|
return found.route.handlers;
|
|
@@ -146,7 +122,6 @@ function getGlobalWooks(logger, routerOpts) {
|
|
|
146
122
|
* ```
|
|
147
123
|
*/
|
|
148
124
|
var WooksAdapterBase = class WooksAdapterBase {
|
|
149
|
-
wooks;
|
|
150
125
|
/**
|
|
151
126
|
* @param wooks - Existing Wooks or adapter instance to share; creates/uses global instance if omitted.
|
|
152
127
|
* @param logger - Custom logger for the global Wooks instance (ignored when `wooks` is provided).
|
|
@@ -197,18 +172,18 @@ exports.getGlobalWooks = getGlobalWooks;
|
|
|
197
172
|
Object.defineProperty(exports, 'useEventId', {
|
|
198
173
|
enumerable: true,
|
|
199
174
|
get: function () {
|
|
200
|
-
return
|
|
175
|
+
return _wooksjs_event_core.useEventId;
|
|
201
176
|
}
|
|
202
177
|
});
|
|
203
178
|
Object.defineProperty(exports, 'useLogger', {
|
|
204
179
|
enumerable: true,
|
|
205
180
|
get: function () {
|
|
206
|
-
return
|
|
181
|
+
return _wooksjs_event_core.useLogger;
|
|
207
182
|
}
|
|
208
183
|
});
|
|
209
184
|
Object.defineProperty(exports, 'useRouteParams', {
|
|
210
185
|
enumerable: true,
|
|
211
186
|
get: function () {
|
|
212
|
-
return
|
|
187
|
+
return _wooksjs_event_core.useRouteParams;
|
|
213
188
|
}
|
|
214
189
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -19,8 +19,6 @@ function getDefaultLogger(topic) {
|
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
var Wooks = class {
|
|
22
|
-
router;
|
|
23
|
-
logger;
|
|
24
22
|
/** @param opts - Optional configuration for router and logger. */
|
|
25
23
|
constructor(opts) {
|
|
26
24
|
this.router = new ProstoRouter({
|
|
@@ -123,7 +121,6 @@ function getGlobalWooks(logger, routerOpts) {
|
|
|
123
121
|
* ```
|
|
124
122
|
*/
|
|
125
123
|
var WooksAdapterBase = class WooksAdapterBase {
|
|
126
|
-
wooks;
|
|
127
124
|
/**
|
|
128
125
|
* @param wooks - Existing Wooks or adapter instance to share; creates/uses global instance if omitted.
|
|
129
126
|
* @param logger - Custom logger for the global Wooks instance (ignored when `wooks` is provided).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wooks",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.12",
|
|
4
4
|
"description": "wooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@prostojs/logger": "^0.4.3",
|
|
44
|
-
"@prostojs/router": "^0.3.
|
|
45
|
-
"@wooksjs/event-core": "^0.7.
|
|
44
|
+
"@prostojs/router": "^0.3.4",
|
|
45
|
+
"@wooksjs/event-core": "^0.7.12"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"typescript": "^5.9.3",
|
|
49
49
|
"vitest": "^3.2.4",
|
|
50
|
-
"@wooksjs/event-http": "^0.7.
|
|
51
|
-
"@wooksjs/http-body": "^0.7.
|
|
50
|
+
"@wooksjs/event-http": "^0.7.12",
|
|
51
|
+
"@wooksjs/http-body": "^0.7.12"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "rolldown -c ../../rolldown.config.mjs"
|