wooks 0.2.15 → 0.2.17
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 +19 -5
- package/dist/index.d.ts +7 -2
- package/dist/index.mjs +19 -5
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,12 @@ class Wooks {
|
|
|
31
31
|
}
|
|
32
32
|
return this.logger;
|
|
33
33
|
}
|
|
34
|
+
getLoggerOptions() {
|
|
35
|
+
if (this.logger instanceof logger.ProstoLogger) {
|
|
36
|
+
return this.logger.getOptions();
|
|
37
|
+
}
|
|
38
|
+
return {};
|
|
39
|
+
}
|
|
34
40
|
lookup(method, path) {
|
|
35
41
|
var _a, _b;
|
|
36
42
|
const found = this.getRouter().lookup(method, path || '');
|
|
@@ -42,14 +48,16 @@ class Wooks {
|
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
let gWooks;
|
|
45
|
-
function getGlobalWooks() {
|
|
51
|
+
function getGlobalWooks(logger) {
|
|
46
52
|
if (!gWooks) {
|
|
47
|
-
gWooks = new Wooks(
|
|
53
|
+
gWooks = new Wooks({
|
|
54
|
+
logger,
|
|
55
|
+
});
|
|
48
56
|
}
|
|
49
57
|
return gWooks;
|
|
50
58
|
}
|
|
51
59
|
class WooksAdapterBase {
|
|
52
|
-
constructor(wooks) {
|
|
60
|
+
constructor(wooks, logger) {
|
|
53
61
|
if (wooks && wooks instanceof WooksAdapterBase) {
|
|
54
62
|
this.wooks = wooks.getWooks();
|
|
55
63
|
}
|
|
@@ -57,14 +65,20 @@ class WooksAdapterBase {
|
|
|
57
65
|
this.wooks = wooks;
|
|
58
66
|
}
|
|
59
67
|
else {
|
|
60
|
-
this.wooks = getGlobalWooks();
|
|
68
|
+
this.wooks = getGlobalWooks(logger);
|
|
61
69
|
}
|
|
62
70
|
}
|
|
63
71
|
getWooks() {
|
|
64
72
|
return this.wooks;
|
|
65
73
|
}
|
|
66
74
|
getLogger(topic) {
|
|
67
|
-
return this.
|
|
75
|
+
return this.getWooks().getLogger(topic);
|
|
76
|
+
}
|
|
77
|
+
getLoggerOptions() {
|
|
78
|
+
return this.getWooks().getLoggerOptions();
|
|
79
|
+
}
|
|
80
|
+
mergeEventOptions(opts) {
|
|
81
|
+
return Object.assign(Object.assign({}, (opts || {})), { eventLogger: Object.assign(Object.assign({}, this.getLoggerOptions()), ((opts === null || opts === void 0 ? void 0 : opts.eventLogger) || {})) });
|
|
68
82
|
}
|
|
69
83
|
on(method, path, handler) {
|
|
70
84
|
return this.wooks.on(method, path, handler);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ProstoRouter } from '@prostojs/router';
|
|
2
2
|
import { TConsoleBase } from '@prostojs/logger';
|
|
3
|
+
import { TEventOptions } from '@wooksjs/event-core';
|
|
4
|
+
import { TProstoLoggerOptions } from '@prostojs/logger';
|
|
3
5
|
import { TProstoRouterPathBuilder } from '@prostojs/router';
|
|
4
6
|
|
|
5
|
-
export declare function getGlobalWooks(): Wooks;
|
|
7
|
+
export declare function getGlobalWooks(logger?: TConsoleBase): Wooks;
|
|
6
8
|
|
|
7
9
|
export declare type TWooksHandler<ResType = unknown> = () => Promise<ResType> | ResType;
|
|
8
10
|
|
|
@@ -21,15 +23,18 @@ export declare class Wooks {
|
|
|
21
23
|
constructor(opts?: TWooksOptions);
|
|
22
24
|
getRouter(): ProstoRouter<TWooksHandler<unknown>>;
|
|
23
25
|
getLogger(topic: string): TConsoleBase;
|
|
26
|
+
getLoggerOptions(): TProstoLoggerOptions;
|
|
24
27
|
lookup(method: string, path: string): TWooksHandler<unknown>[] | null;
|
|
25
28
|
on<ResType = unknown, ParamsType = Record<string, string | string[]>>(method: string, path: string, handler: TWooksHandler<ResType>): TProstoRouterPathBuilder<ParamsType>;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
export declare class WooksAdapterBase {
|
|
29
32
|
protected wooks: Wooks;
|
|
30
|
-
constructor(wooks?: Wooks | WooksAdapterBase);
|
|
33
|
+
constructor(wooks?: Wooks | WooksAdapterBase, logger?: TConsoleBase);
|
|
31
34
|
getWooks(): Wooks;
|
|
32
35
|
getLogger(topic: string): TConsoleBase;
|
|
36
|
+
protected getLoggerOptions(): TProstoLoggerOptions<Record<string, never>>;
|
|
37
|
+
protected mergeEventOptions(opts?: TEventOptions): TEventOptions;
|
|
33
38
|
on<ResType = unknown, ParamsType = Record<string, string | string[]>>(method: string, path: string, handler: TWooksHandler<ResType>): TProstoRouterPathBuilder<ParamsType>;
|
|
34
39
|
}
|
|
35
40
|
|
package/dist/index.mjs
CHANGED
|
@@ -30,6 +30,12 @@ class Wooks {
|
|
|
30
30
|
}
|
|
31
31
|
return this.logger;
|
|
32
32
|
}
|
|
33
|
+
getLoggerOptions() {
|
|
34
|
+
if (this.logger instanceof ProstoLogger) {
|
|
35
|
+
return this.logger.getOptions();
|
|
36
|
+
}
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
33
39
|
lookup(method, path) {
|
|
34
40
|
var _a, _b;
|
|
35
41
|
const found = this.getRouter().lookup(method, path || '');
|
|
@@ -41,14 +47,16 @@ class Wooks {
|
|
|
41
47
|
}
|
|
42
48
|
}
|
|
43
49
|
let gWooks;
|
|
44
|
-
function getGlobalWooks() {
|
|
50
|
+
function getGlobalWooks(logger) {
|
|
45
51
|
if (!gWooks) {
|
|
46
|
-
gWooks = new Wooks(
|
|
52
|
+
gWooks = new Wooks({
|
|
53
|
+
logger,
|
|
54
|
+
});
|
|
47
55
|
}
|
|
48
56
|
return gWooks;
|
|
49
57
|
}
|
|
50
58
|
class WooksAdapterBase {
|
|
51
|
-
constructor(wooks) {
|
|
59
|
+
constructor(wooks, logger) {
|
|
52
60
|
if (wooks && wooks instanceof WooksAdapterBase) {
|
|
53
61
|
this.wooks = wooks.getWooks();
|
|
54
62
|
}
|
|
@@ -56,14 +64,20 @@ class WooksAdapterBase {
|
|
|
56
64
|
this.wooks = wooks;
|
|
57
65
|
}
|
|
58
66
|
else {
|
|
59
|
-
this.wooks = getGlobalWooks();
|
|
67
|
+
this.wooks = getGlobalWooks(logger);
|
|
60
68
|
}
|
|
61
69
|
}
|
|
62
70
|
getWooks() {
|
|
63
71
|
return this.wooks;
|
|
64
72
|
}
|
|
65
73
|
getLogger(topic) {
|
|
66
|
-
return this.
|
|
74
|
+
return this.getWooks().getLogger(topic);
|
|
75
|
+
}
|
|
76
|
+
getLoggerOptions() {
|
|
77
|
+
return this.getWooks().getLoggerOptions();
|
|
78
|
+
}
|
|
79
|
+
mergeEventOptions(opts) {
|
|
80
|
+
return Object.assign(Object.assign({}, (opts || {})), { eventLogger: Object.assign(Object.assign({}, this.getLoggerOptions()), ((opts === null || opts === void 0 ? void 0 : opts.eventLogger) || {})) });
|
|
67
81
|
}
|
|
68
82
|
on(method, path, handler) {
|
|
69
83
|
return this.wooks.on(method, path, handler);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wooks",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "wooks",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@prostojs/router": "^0.0.16",
|
|
35
|
-
"@prostojs/logger": "^0.3.
|
|
36
|
-
"@wooksjs/event-core": "0.2.
|
|
35
|
+
"@prostojs/logger": "^0.3.4",
|
|
36
|
+
"@wooksjs/event-core": "0.2.17"
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/wooksjs/wooksjs/tree/main/packages/wooks#readme"
|
|
39
39
|
}
|