@wooksjs/event-http 0.2.17 → 0.2.18

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 CHANGED
@@ -808,7 +808,7 @@ class HttpErrorRenderer extends BaseHttpResponseRenderer {
808
808
  `<head><title>${data.statusCode} ${httpStatusCodes[data.statusCode]}</title></head>` +
809
809
  `<body><center><h1>${data.statusCode} ${httpStatusCodes[data.statusCode]}</h1></center>` +
810
810
  `<center><h4>${data.message}</h1></center><hr color="#666">` +
811
- `<center style="color: #666;"> Wooks v${"0.2.17"} </center>` +
811
+ `<center style="color: #666;"> Wooks v${"0.2.18"} </center>` +
812
812
  `${keys.length ? `<pre style="${preStyles}">${JSON.stringify(Object.assign(Object.assign({}, data), { statusCode: undefined, message: undefined, error: undefined }), null, ' ')}</pre>` : ''}` +
813
813
  '</body></html>';
814
814
  }
package/dist/index.d.ts CHANGED
@@ -6,9 +6,9 @@ import { IncomingMessage } from 'http';
6
6
  import { Server } from 'http';
7
7
  import { ServerResponse } from 'http';
8
8
  import { TConsoleBase } from '@prostojs/logger';
9
+ import { TEmpty } from '@wooksjs/event-core';
9
10
  import { TEventOptions } from '@wooksjs/event-core';
10
11
  import { TGenericContextStore } from '@wooksjs/event-core';
11
- import { TGenericEvent } from '@wooksjs/event-core';
12
12
  import { TProstoRouterPathBuilder } from '@prostojs/router';
13
13
  import { TWooksHandler } from 'wooks';
14
14
  import { URLSearchParams as URLSearchParams_2 } from 'url';
@@ -50,25 +50,25 @@ export declare class BaseHttpResponseRenderer<T = unknown> implements TWooksResp
50
50
  export declare function createHttpApp(opts?: TWooksHttpOptions, wooks?: Wooks | WooksAdapterBase): WooksHttp;
51
51
 
52
52
  export declare function createHttpContext(data: THttpEventData, options: TEventOptions): {
53
- getCtx: () => THttpContextStore;
54
- restoreCtx: () => THttpContextStore;
53
+ getCtx: () => THttpContextStore & TGenericContextStore<THttpEventData>;
54
+ restoreCtx: () => TGenericContextStore<TEmpty>;
55
55
  clearCtx: () => null;
56
- store: <K extends keyof THttpContextStore>(key: K) => {
57
- value: THttpContextStore[K];
58
- hook: <K2 extends keyof Required<THttpContextStore>[K]>(key2: K2) => {
59
- value: Required<THttpContextStore>[K][K2];
56
+ store: <K extends keyof THttpContextStore | keyof TGenericContextStore<THttpEventData>>(key: K) => {
57
+ value: (THttpContextStore & TGenericContextStore<THttpEventData>)[K];
58
+ hook: <K2 extends keyof Required<THttpContextStore & TGenericContextStore<THttpEventData>>[K]>(key2: K2) => {
59
+ value: Required<THttpContextStore & TGenericContextStore<THttpEventData>>[K][K2];
60
60
  isDefined: boolean;
61
61
  };
62
- init: <K2_1 extends keyof Required<THttpContextStore>[K]>(key2: K2_1, getter: () => Required<Required<THttpContextStore>[K]>[K2_1]) => Required<Required<THttpContextStore>[K]>[K2_1];
63
- set: <K2_2 extends keyof Required<THttpContextStore>[K]>(key2: K2_2, v: Required<THttpContextStore[K]>[K2_2]) => Required<THttpContextStore[K]>[K2_2];
64
- get: <K2_3 extends keyof Required<THttpContextStore>[K]>(key2: K2_3) => Required<THttpContextStore>[K][K2_3];
65
- has: <K2_4 extends keyof Required<THttpContextStore>[K]>(key2: K2_4) => boolean;
66
- del: <K2_5 extends keyof Required<THttpContextStore>[K]>(key2: K2_5) => void;
62
+ init: <K2_1 extends keyof Required<THttpContextStore & TGenericContextStore<THttpEventData>>[K]>(key2: K2_1, getter: () => Required<Required<THttpContextStore & TGenericContextStore<THttpEventData>>[K]>[K2_1]) => Required<Required<THttpContextStore & TGenericContextStore<THttpEventData>>[K]>[K2_1];
63
+ set: <K2_2 extends keyof Required<THttpContextStore & TGenericContextStore<THttpEventData>>[K]>(key2: K2_2, v: Required<(THttpContextStore & TGenericContextStore<THttpEventData>)[K]>[K2_2]) => Required<(THttpContextStore & TGenericContextStore<THttpEventData>)[K]>[K2_2];
64
+ get: <K2_3 extends keyof Required<THttpContextStore & TGenericContextStore<THttpEventData>>[K]>(key2: K2_3) => Required<THttpContextStore & TGenericContextStore<THttpEventData>>[K][K2_3];
65
+ has: <K2_4 extends keyof Required<THttpContextStore & TGenericContextStore<THttpEventData>>[K]>(key2: K2_4) => boolean;
66
+ del: <K2_5 extends keyof Required<THttpContextStore & TGenericContextStore<THttpEventData>>[K]>(key2: K2_5) => void;
67
67
  entries: () => [string, unknown][];
68
68
  clear: () => void;
69
69
  };
70
- getStore: <K_1 extends keyof THttpContextStore>(key: K_1) => THttpContextStore[K_1];
71
- setStore: <K_2 extends keyof THttpContextStore>(key: K_2, v: THttpContextStore[K_2]) => void;
70
+ getStore: <K_1 extends keyof THttpContextStore | keyof TGenericContextStore<THttpEventData>>(key: K_1) => (THttpContextStore & TGenericContextStore<THttpEventData>)[K_1];
71
+ setStore: <K_2 extends keyof THttpContextStore | keyof TGenericContextStore<THttpEventData>>(key: K_2, v: (THttpContextStore & TGenericContextStore<THttpEventData>)[K_2]) => void;
72
72
  };
73
73
 
74
74
  export declare function createWooksResponder(renderer?: TWooksResponseRenderer<any>, errorRenderer?: TWooksResponseRenderer<any>): {
@@ -266,7 +266,7 @@ export declare type THeaderHook = ReturnType<typeof useSetHeader>;
266
266
 
267
267
  declare type THttpBadRequestCodes = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
268
268
 
269
- export declare interface THttpContextStore extends TGenericContextStore<THttpEvent> {
269
+ export declare interface THttpContextStore {
270
270
  searchParams?: TSearchParamsCache;
271
271
  cookies?: {
272
272
  [name: string]: string | null;
@@ -292,7 +292,7 @@ export declare interface THttpContextStore extends TGenericContextStore<THttpEve
292
292
 
293
293
  declare type THttpErrorCodes = THttpBadRequestCodes | THttpServerErrorCodes;
294
294
 
295
- export declare interface THttpEvent extends TGenericEvent, THttpEventData {
295
+ export declare interface THttpEvent {
296
296
  type: 'HTTP';
297
297
  }
298
298
 
@@ -383,26 +383,26 @@ export declare function useCookies(): {
383
383
 
384
384
  export declare function useHeaders(): IncomingHttpHeaders;
385
385
 
386
- export declare function useHttpContext<T extends object>(): {
387
- getCtx: () => THttpContextStore & T;
388
- restoreCtx: () => THttpContextStore & T;
386
+ export declare function useHttpContext<T extends TEmpty>(): {
387
+ getCtx: () => THttpContextStore & T & TGenericContextStore<THttpEventData>;
388
+ restoreCtx: () => TGenericContextStore<TEmpty>;
389
389
  clearCtx: () => null;
390
- store: <K extends keyof THttpContextStore | keyof T>(key: K) => {
391
- value: (THttpContextStore & T)[K];
392
- hook: <K2 extends keyof Required<THttpContextStore & T>[K]>(key2: K2) => {
393
- value: Required<THttpContextStore & T>[K][K2];
390
+ store: <K extends keyof THttpContextStore | keyof TGenericContextStore<THttpEventData> | keyof T>(key: K) => {
391
+ value: (THttpContextStore & T & TGenericContextStore<THttpEventData>)[K];
392
+ hook: <K2 extends keyof Required<THttpContextStore & T & TGenericContextStore<THttpEventData>>[K]>(key2: K2) => {
393
+ value: Required<THttpContextStore & T & TGenericContextStore<THttpEventData>>[K][K2];
394
394
  isDefined: boolean;
395
395
  };
396
- init: <K2_1 extends keyof Required<THttpContextStore & T>[K]>(key2: K2_1, getter: () => Required<Required<THttpContextStore & T>[K]>[K2_1]) => Required<Required<THttpContextStore & T>[K]>[K2_1];
397
- set: <K2_2 extends keyof Required<THttpContextStore & T>[K]>(key2: K2_2, v: Required<(THttpContextStore & T)[K]>[K2_2]) => Required<(THttpContextStore & T)[K]>[K2_2];
398
- get: <K2_3 extends keyof Required<THttpContextStore & T>[K]>(key2: K2_3) => Required<THttpContextStore & T>[K][K2_3];
399
- has: <K2_4 extends keyof Required<THttpContextStore & T>[K]>(key2: K2_4) => boolean;
400
- del: <K2_5 extends keyof Required<THttpContextStore & T>[K]>(key2: K2_5) => void;
396
+ init: <K2_1 extends keyof Required<THttpContextStore & T & TGenericContextStore<THttpEventData>>[K]>(key2: K2_1, getter: () => Required<Required<THttpContextStore & T & TGenericContextStore<THttpEventData>>[K]>[K2_1]) => Required<Required<THttpContextStore & T & TGenericContextStore<THttpEventData>>[K]>[K2_1];
397
+ set: <K2_2 extends keyof Required<THttpContextStore & T & TGenericContextStore<THttpEventData>>[K]>(key2: K2_2, v: Required<(THttpContextStore & T & TGenericContextStore<THttpEventData>)[K]>[K2_2]) => Required<(THttpContextStore & T & TGenericContextStore<THttpEventData>)[K]>[K2_2];
398
+ get: <K2_3 extends keyof Required<THttpContextStore & T & TGenericContextStore<THttpEventData>>[K]>(key2: K2_3) => Required<THttpContextStore & T & TGenericContextStore<THttpEventData>>[K][K2_3];
399
+ has: <K2_4 extends keyof Required<THttpContextStore & T & TGenericContextStore<THttpEventData>>[K]>(key2: K2_4) => boolean;
400
+ del: <K2_5 extends keyof Required<THttpContextStore & T & TGenericContextStore<THttpEventData>>[K]>(key2: K2_5) => void;
401
401
  entries: () => [string, unknown][];
402
402
  clear: () => void;
403
403
  };
404
- getStore: <K_1 extends keyof THttpContextStore | keyof T>(key: K_1) => (THttpContextStore & T)[K_1];
405
- setStore: <K_2 extends keyof THttpContextStore | keyof T>(key: K_2, v: (THttpContextStore & T)[K_2]) => void;
404
+ getStore: <K_1 extends keyof THttpContextStore | keyof TGenericContextStore<THttpEventData> | keyof T>(key: K_1) => (THttpContextStore & T & TGenericContextStore<THttpEventData>)[K_1];
405
+ setStore: <K_2 extends keyof THttpContextStore | keyof TGenericContextStore<THttpEventData> | keyof T>(key: K_2, v: (THttpContextStore & T & TGenericContextStore<THttpEventData>)[K_2]) => void;
406
406
  };
407
407
 
408
408
  export declare function useRequest(): {
package/dist/index.mjs CHANGED
@@ -806,7 +806,7 @@ class HttpErrorRenderer extends BaseHttpResponseRenderer {
806
806
  `<head><title>${data.statusCode} ${httpStatusCodes[data.statusCode]}</title></head>` +
807
807
  `<body><center><h1>${data.statusCode} ${httpStatusCodes[data.statusCode]}</h1></center>` +
808
808
  `<center><h4>${data.message}</h1></center><hr color="#666">` +
809
- `<center style="color: #666;"> Wooks v${"0.2.17"} </center>` +
809
+ `<center style="color: #666;"> Wooks v${"0.2.18"} </center>` +
810
810
  `${keys.length ? `<pre style="${preStyles}">${JSON.stringify(Object.assign(Object.assign({}, data), { statusCode: undefined, message: undefined, error: undefined }), null, ' ')}</pre>` : ''}` +
811
811
  '</body></html>';
812
812
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wooksjs/event-http",
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "description": "@wooksjs/event-http",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",
@@ -31,9 +31,9 @@
31
31
  "url": "https://github.com/wooksjs/wooksjs/issues"
32
32
  },
33
33
  "peerDependencies": {
34
- "wooks": "0.2.17",
34
+ "wooks": "0.2.18",
35
35
  "@prostojs/router": "^0.0.16",
36
- "@wooksjs/event-core": "0.2.17"
36
+ "@wooksjs/event-core": "0.2.18"
37
37
  },
38
38
  "dependencies": {
39
39
  "@prostojs/logger": "^0.3.4"