@moostjs/event-http 0.2.6 → 0.2.7
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.d.ts +62 -3
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { IncomingMessage } from 'http';
|
|
4
4
|
import { ServerResponse } from 'http';
|
|
5
|
-
import { TInterceptorFn } from '@moostjs/moost';
|
|
6
|
-
import { TMoostAdapter } from 'moost';
|
|
7
|
-
import { TMoostAdapterOptions } from 'moost';
|
|
8
5
|
import { TProstoRouterPathBuilder } from '@prostojs/router';
|
|
9
6
|
import { TProvideRegistry } from '@prostojs/infact';
|
|
10
7
|
import { TWooksHttpOptions } from '@wooksjs/event-http';
|
|
@@ -67,6 +64,20 @@ export declare const HeaderHook: (name: string) => ParameterDecorator;
|
|
|
67
64
|
|
|
68
65
|
export declare function HttpMethod(method: '*' | 'GET' | 'PUT' | 'POST' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS', path?: string): MethodDecorator;
|
|
69
66
|
|
|
67
|
+
declare class InterceptorHandler {
|
|
68
|
+
protected handlers: TInterceptorFn[];
|
|
69
|
+
constructor(handlers: TInterceptorFn[]);
|
|
70
|
+
protected before: TInterceptorBefore[];
|
|
71
|
+
protected after: TInterceptorAfter[];
|
|
72
|
+
protected onError: TInterceptorOnError[];
|
|
73
|
+
response?: unknown;
|
|
74
|
+
responseOverwritten: boolean;
|
|
75
|
+
replyFn(reply: unknown): void;
|
|
76
|
+
init(): Promise<void>;
|
|
77
|
+
fireBefore(response: unknown): Promise<unknown>;
|
|
78
|
+
fireAfter(response: unknown): Promise<unknown>;
|
|
79
|
+
}
|
|
80
|
+
|
|
70
81
|
/**
|
|
71
82
|
* Get Request IP Address
|
|
72
83
|
* @decorator
|
|
@@ -172,11 +183,59 @@ declare const setHeaderInterceptor: (name: string, value: string, opts?: {
|
|
|
172
183
|
*/
|
|
173
184
|
export declare const StatusHook: ParameterDecorator;
|
|
174
185
|
|
|
186
|
+
declare type TAny = any;
|
|
187
|
+
|
|
175
188
|
export declare interface THttpHandlerMeta {
|
|
176
189
|
method: string;
|
|
177
190
|
path: string;
|
|
178
191
|
}
|
|
179
192
|
|
|
193
|
+
declare type TInterceptorAfter = (response: TAny, reply: (response: TAny) => void) => void | Promise<void>;
|
|
194
|
+
|
|
195
|
+
declare type TInterceptorBefore = (reply: (response: TAny) => void) => void | Promise<void>;
|
|
196
|
+
|
|
197
|
+
declare type TInterceptorFn = {
|
|
198
|
+
(before: (fn: TInterceptorBefore) => void, after: (fn: TInterceptorAfter) => void, onError: (fn: TInterceptorOnError) => void): void | Promise<void>;
|
|
199
|
+
priority?: TInterceptorPriority;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
declare type TInterceptorOnError = (error: Error, reply: (response: TAny) => void) => void | Promise<void>;
|
|
203
|
+
|
|
204
|
+
declare enum TInterceptorPriority {
|
|
205
|
+
BEFORE_ALL = 0,
|
|
206
|
+
BEFORE_GUARD = 1,
|
|
207
|
+
GUARD = 2,
|
|
208
|
+
AFTER_GUARD = 3,
|
|
209
|
+
INTERCEPTOR = 4,
|
|
210
|
+
CATCH_ERROR = 5,
|
|
211
|
+
AFTER_ALL = 6
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
declare interface TMoostAdapter<H extends object> {
|
|
215
|
+
bindHandler<T extends TObject = TObject>(options: TMoostAdapterOptions<H, T>): void | Promise<void>;
|
|
216
|
+
onInit?: () => void | Promise<void>;
|
|
217
|
+
getProvideRegistry?: () => TProvideRegistry;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
declare interface TMoostAdapterOptions<H extends object, T extends object> {
|
|
221
|
+
prefix: string;
|
|
222
|
+
fakeInstance: T;
|
|
223
|
+
getInstance: () => Promise<T>;
|
|
224
|
+
silent: boolean;
|
|
225
|
+
method: keyof T;
|
|
226
|
+
handlers: TMoostHandler<H>[];
|
|
227
|
+
getIterceptorHandler: () => Promise<InterceptorHandler>;
|
|
228
|
+
registerEventScope: (scopeId: string) => () => void;
|
|
229
|
+
resolveArgs: () => Promise<unknown[]>;
|
|
230
|
+
logHandler: (eventName: string) => void;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
declare type TMoostHandler<T extends object> = T & {
|
|
234
|
+
type: string;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
declare type TObject = object;
|
|
238
|
+
|
|
180
239
|
/**
|
|
181
240
|
* Get Requested URL
|
|
182
241
|
* @decorator
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/event-http",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "@moostjs/event-http",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-http#readme",
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"moost": "0.2.
|
|
31
|
+
"moost": "0.2.7",
|
|
32
32
|
"wooks": "^0.2.5"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|