wooks 0.2.23 → 0.3.1
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 +1 -1
- package/dist/index.cjs +16 -2
- package/dist/index.d.ts +16 -1
- package/dist/index.mjs +16 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ It utilizes such a technique as you can see in React Hooks or Vue Composables. I
|
|
|
23
23
|
- [@wooksjs/http-static](https://github.com/wooksjs/wooksjs/tree/main/packages/http-static) - to serve static files
|
|
24
24
|
- [@wooksjs/http-proxy](https://github.com/wooksjs/wooksjs/tree/main/packages/http-proxy) - to proxy requests
|
|
25
25
|
|
|
26
|
-
##
|
|
26
|
+
## Installation
|
|
27
27
|
|
|
28
28
|
`npm install wooks`
|
|
29
29
|
|
package/dist/index.cjs
CHANGED
|
@@ -38,10 +38,14 @@ class Wooks {
|
|
|
38
38
|
return {};
|
|
39
39
|
}
|
|
40
40
|
lookup(method, path) {
|
|
41
|
-
var _a, _b;
|
|
41
|
+
var _a, _b, _c, _d;
|
|
42
42
|
const found = this.getRouter().lookup(method, path || '');
|
|
43
43
|
eventCore.useEventContext().store('routeParams').value = ((_a = found === null || found === void 0 ? void 0 : found.ctx) === null || _a === void 0 ? void 0 : _a.params) || {};
|
|
44
|
-
return
|
|
44
|
+
return {
|
|
45
|
+
handlers: ((_b = found === null || found === void 0 ? void 0 : found.route) === null || _b === void 0 ? void 0 : _b.handlers) || null,
|
|
46
|
+
segments: ((_c = found === null || found === void 0 ? void 0 : found.route) === null || _c === void 0 ? void 0 : _c.segments) || null,
|
|
47
|
+
firstStatic: ((_d = found === null || found === void 0 ? void 0 : found.route) === null || _d === void 0 ? void 0 : _d.firstStatic) || null,
|
|
48
|
+
};
|
|
45
49
|
}
|
|
46
50
|
on(method, path, handler) {
|
|
47
51
|
return this.router.on(method, path, handler);
|
|
@@ -71,6 +75,16 @@ class WooksAdapterBase {
|
|
|
71
75
|
getWooks() {
|
|
72
76
|
return this.wooks;
|
|
73
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Get logger instance for application logs
|
|
80
|
+
* ```js
|
|
81
|
+
* const app = createHttpApp()
|
|
82
|
+
* const logger = app.getLogger('app-logger')
|
|
83
|
+
* logger.log('My App log message')
|
|
84
|
+
* ```
|
|
85
|
+
* @param topic topic for logger
|
|
86
|
+
* @returns logger instance
|
|
87
|
+
*/
|
|
74
88
|
getLogger(topic) {
|
|
75
89
|
return this.getWooks().getLogger(topic);
|
|
76
90
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ProstoRouter } from '@prostojs/router';
|
|
2
2
|
import { TConsoleBase } from '@prostojs/logger';
|
|
3
3
|
import { TEventOptions } from '@wooksjs/event-core';
|
|
4
|
+
import { TParsedSegment } from '@prostojs/router';
|
|
4
5
|
import { TProstoLoggerOptions } from '@prostojs/logger';
|
|
5
6
|
import { TProstoRouterPathHandle } from '@prostojs/router';
|
|
6
7
|
|
|
@@ -24,7 +25,11 @@ export declare class Wooks {
|
|
|
24
25
|
getRouter(): ProstoRouter<TWooksHandler<unknown>>;
|
|
25
26
|
getLogger(topic: string): TConsoleBase;
|
|
26
27
|
getLoggerOptions(): TProstoLoggerOptions;
|
|
27
|
-
lookup(method: string, path: string):
|
|
28
|
+
lookup(method: string, path: string): {
|
|
29
|
+
handlers: TWooksHandler<unknown>[] | null;
|
|
30
|
+
segments: TParsedSegment[] | null;
|
|
31
|
+
firstStatic: string | null;
|
|
32
|
+
};
|
|
28
33
|
on<ResType = unknown, ParamsType = Record<string, string | string[]>>(method: string, path: string, handler: TWooksHandler<ResType>): TProstoRouterPathHandle<ParamsType>;
|
|
29
34
|
}
|
|
30
35
|
|
|
@@ -32,6 +37,16 @@ export declare class WooksAdapterBase {
|
|
|
32
37
|
protected wooks: Wooks;
|
|
33
38
|
constructor(wooks?: Wooks | WooksAdapterBase, logger?: TConsoleBase);
|
|
34
39
|
getWooks(): Wooks;
|
|
40
|
+
/**
|
|
41
|
+
* Get logger instance for application logs
|
|
42
|
+
* ```js
|
|
43
|
+
* const app = createHttpApp()
|
|
44
|
+
* const logger = app.getLogger('app-logger')
|
|
45
|
+
* logger.log('My App log message')
|
|
46
|
+
* ```
|
|
47
|
+
* @param topic topic for logger
|
|
48
|
+
* @returns logger instance
|
|
49
|
+
*/
|
|
35
50
|
getLogger(topic: string): TConsoleBase;
|
|
36
51
|
protected getLoggerOptions(): TProstoLoggerOptions<Record<string, never>>;
|
|
37
52
|
protected mergeEventOptions(opts?: TEventOptions): TEventOptions;
|
package/dist/index.mjs
CHANGED
|
@@ -37,10 +37,14 @@ class Wooks {
|
|
|
37
37
|
return {};
|
|
38
38
|
}
|
|
39
39
|
lookup(method, path) {
|
|
40
|
-
var _a, _b;
|
|
40
|
+
var _a, _b, _c, _d;
|
|
41
41
|
const found = this.getRouter().lookup(method, path || '');
|
|
42
42
|
useEventContext().store('routeParams').value = ((_a = found === null || found === void 0 ? void 0 : found.ctx) === null || _a === void 0 ? void 0 : _a.params) || {};
|
|
43
|
-
return
|
|
43
|
+
return {
|
|
44
|
+
handlers: ((_b = found === null || found === void 0 ? void 0 : found.route) === null || _b === void 0 ? void 0 : _b.handlers) || null,
|
|
45
|
+
segments: ((_c = found === null || found === void 0 ? void 0 : found.route) === null || _c === void 0 ? void 0 : _c.segments) || null,
|
|
46
|
+
firstStatic: ((_d = found === null || found === void 0 ? void 0 : found.route) === null || _d === void 0 ? void 0 : _d.firstStatic) || null,
|
|
47
|
+
};
|
|
44
48
|
}
|
|
45
49
|
on(method, path, handler) {
|
|
46
50
|
return this.router.on(method, path, handler);
|
|
@@ -70,6 +74,16 @@ class WooksAdapterBase {
|
|
|
70
74
|
getWooks() {
|
|
71
75
|
return this.wooks;
|
|
72
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Get logger instance for application logs
|
|
79
|
+
* ```js
|
|
80
|
+
* const app = createHttpApp()
|
|
81
|
+
* const logger = app.getLogger('app-logger')
|
|
82
|
+
* logger.log('My App log message')
|
|
83
|
+
* ```
|
|
84
|
+
* @param topic topic for logger
|
|
85
|
+
* @returns logger instance
|
|
86
|
+
*/
|
|
73
87
|
getLogger(topic) {
|
|
74
88
|
return this.getWooks().getLogger(topic);
|
|
75
89
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "wooks",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@prostojs/router": "^0.1.0",
|
|
35
35
|
"@prostojs/logger": "^0.3.6",
|
|
36
|
-
"@wooksjs/event-core": "0.
|
|
36
|
+
"@wooksjs/event-core": "0.3.1"
|
|
37
37
|
},
|
|
38
38
|
"homepage": "https://github.com/wooksjs/wooksjs/tree/main/packages/wooks#readme"
|
|
39
39
|
}
|