@jwn-js/common 2.0.20 → 2.0.21

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.
Files changed (41) hide show
  1. package/ApiError.d.ts +47 -47
  2. package/Jwt.d.ts +36 -36
  3. package/LICENSE +21 -21
  4. package/Memcached.d.ts +64 -64
  5. package/README.md +20 -20
  6. package/Server.d.ts +139 -139
  7. package/cookieParse.d.ts +4 -4
  8. package/cookieString.d.ts +9 -9
  9. package/docs/assets/highlight.css +1 -1
  10. package/docs/assets/main.js +2 -2
  11. package/docs/assets/search.js +1 -1
  12. package/docs/assets/style.css +28 -2
  13. package/docs/classes/ApiError.html +8 -9
  14. package/docs/classes/AsyncJwt.html +4 -4
  15. package/docs/classes/Controller.html +7 -7
  16. package/docs/classes/Jwt.html +4 -4
  17. package/docs/classes/Memcached.html +8 -8
  18. package/docs/classes/Model.html +3 -3
  19. package/docs/classes/Server.html +9 -9
  20. package/docs/classes/Ssr.html +2 -2
  21. package/docs/classes/Web.html +3 -3
  22. package/docs/index.html +1 -1
  23. package/docs/interfaces/ApiErrorMessage.html +1 -1
  24. package/docs/interfaces/ContextSsr.html +9 -9
  25. package/docs/interfaces/ContextWeb.html +1 -1
  26. package/docs/interfaces/OptionsSsr.html +1 -1
  27. package/docs/interfaces/OptionsWeb.html +1 -1
  28. package/docs/interfaces/Route.html +1 -1
  29. package/docs/interfaces/Schema.html +1 -1
  30. package/docs/interfaces/ServerHandler.html +1 -1
  31. package/docs/interfaces/ServerOptions.html +1 -1
  32. package/docs/interfaces/ServerWebsocket.html +1 -1
  33. package/docs/modules.html +27 -27
  34. package/index.d.ts +904 -905
  35. package/jsonBody.d.ts +5 -5
  36. package/multipartBody.d.ts +27 -27
  37. package/package.json +3 -3
  38. package/readConfig.d.ts +4 -4
  39. package/readConfigSync.d.ts +4 -4
  40. package/staticBody.d.ts +17 -17
  41. package/urlencodedBody.d.ts +5 -5
package/index.d.ts CHANGED
@@ -5,943 +5,942 @@ import * as uWebSockets_js from 'uWebSockets.js';
5
5
  import { RecognizedString, HttpResponse, HttpRequest, WebSocketBehavior, AppOptions, TemplatedApp } from 'uWebSockets.js';
6
6
  import { Client } from 'memjs';
7
7
  import { Query } from 'buildmsql';
8
- import * as __ from '..';
9
8
  export { Context as ContextSsr } from 'vite-ssr-vue';
10
9
 
11
- /**
12
- * Input params of error
13
- */
14
- interface ApiErrorMessage {
15
- message?: string;
16
- code?: number;
17
- statusCode?: number;
18
- data?: Record<string, unknown>;
19
- headers?: Record<string, string>;
20
- }
21
- /**
22
- * @class Api Error
23
- * @description Base error class for @jwn-js
24
- */
25
- declare class ApiError extends Error {
26
- statusCode: number;
27
- code: number;
28
- data: Record<string, unknown>;
29
- headers: Record<string, string>;
30
- /**
31
- * @constructor
32
- * @param message
33
- * @param code
34
- * @param statusCode
35
- */
36
- constructor(message?: string, code?: number, statusCode?: number);
37
- constructor(params: ApiErrorMessage | string, code?: number, statusCode?: number);
38
- /**
39
- * Get error message
40
- */
41
- getMessage(): string;
42
- /**
43
- * Get internal status code
44
- */
45
- getStatusCode(): number;
46
- /**
47
- * Get internal error code
48
- */
49
- getCode(): number;
50
- /**
51
- * Get error data
52
- */
53
- getData(): Record<string, unknown>;
54
- /**
55
- * Get error headers
56
- */
57
- getHeaders(): Record<string, string>;
10
+ /**
11
+ * Input params of error
12
+ */
13
+ interface ApiErrorMessage {
14
+ message?: string;
15
+ code?: number;
16
+ statusCode?: number;
17
+ data?: Record<string, unknown>;
18
+ headers?: Record<string, string>;
19
+ }
20
+ /**
21
+ * @class Api Error
22
+ * @description Base error class for @jwn-js
23
+ */
24
+ declare class ApiError extends Error {
25
+ statusCode: number;
26
+ code: number;
27
+ data: Record<string, unknown>;
28
+ headers: Record<string, string>;
29
+ /**
30
+ * @constructor
31
+ * @param message
32
+ * @param code
33
+ * @param statusCode
34
+ */
35
+ constructor(message?: string, code?: number, statusCode?: number);
36
+ constructor(params: ApiErrorMessage | string, code?: number, statusCode?: number);
37
+ /**
38
+ * Get error message
39
+ */
40
+ getMessage(): string;
41
+ /**
42
+ * Get internal status code
43
+ */
44
+ getStatusCode(): number;
45
+ /**
46
+ * Get internal error code
47
+ */
48
+ getCode(): number;
49
+ /**
50
+ * Get error data
51
+ */
52
+ getData(): Record<string, unknown>;
53
+ /**
54
+ * Get error headers
55
+ */
56
+ getHeaders(): Record<string, string>;
58
57
  }
59
58
 
60
- declare module 'uWebSockets.js' {
61
- interface HttpRequest {
62
- cookies: Record<string, any>;
63
- }
64
- }
65
- interface Handler {
66
- method?: 'any' | 'connect' | 'del' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
67
- pattern?: RecognizedString;
68
- handler: (res: HttpResponse, req: HttpRequest, next: CallableFunction) => void | Promise<void | boolean | Error | string>;
69
- }
70
- interface WebSocket {
71
- method: 'ws';
72
- pattern?: RecognizedString;
73
- behavior: WebSocketBehavior;
74
- }
75
- declare type Routes = Array<Handler | WebSocket | CallableFunction>;
76
- interface Options {
77
- routes: Routes;
78
- host?: string;
79
- port?: number;
80
- timeout?: number;
81
- mode?: "development" | "production";
82
- appOptions?: AppOptions;
83
- logLevel?: "info" | "warn" | "error" | "silent";
84
- }
85
- /**
86
- * Status code to string
87
- */
88
- declare const codeToStatus: (code: number) => any;
89
- /**
90
- * Create server
91
- */
92
- declare class Server {
93
- private _logLevel;
94
- /**
95
- * Listen socket
96
- * @private
97
- */
98
- private _socket;
99
- /**
100
- * Request timeout
101
- * @private
102
- */
103
- private readonly _timeout;
104
- private readonly _routes;
105
- private _host;
106
- private _port;
107
- private readonly _mode;
108
- private readonly _appOptions;
109
- private _app;
110
- private _protocol;
111
- /**
112
- *Timeout identification
113
- * @private
114
- */
115
- private _timeoutId;
116
- /**
117
- * Default route options
118
- * @private
119
- */
120
- private _defaultRoute;
121
- /**
122
- * @constructor
123
- * @param options
124
- */
125
- constructor(options: Options);
126
- /**
127
- * Get TemplatedApp instance
128
- */
129
- getApp(): TemplatedApp;
130
- /**
131
- * Create app (server http)
132
- * @returns this
133
- */
134
- app(): this;
135
- /**
136
- * Create sslApp
137
- * @returns this
138
- */
139
- sslApp(): this;
140
- /**
141
- * Push route
142
- * @param route
143
- * @returns this
144
- */
145
- push(route: Handler | WebSocket | CallableFunction): this;
146
- /**
147
- * unshift route
148
- * @param route
149
- * @returns this
150
- */
151
- unshift(route: Handler | WebSocket | CallableFunction): this;
152
- /**
153
- * Create server listener
154
- * @param host - host or port
155
- * @param port
156
- * @param fn
157
- * @returns this
158
- */
159
- listen(host: string, port: number, fn?: CallableFunction): this;
160
- listen(port: number, fn?: CallableFunction): this;
161
- listen(fn?: CallableFunction): this;
162
- /**
163
- * Closes a uSockets listen socket.
164
- */
165
- close(): Promise<this>;
166
- /**
167
- * Return socket port
168
- */
169
- socketPort(): Promise<number>;
170
- /**
171
- * Create decoration of handler
172
- * @param res http response
173
- * @param req http request
174
- * @param fn handler
175
- * @private
176
- */
177
- private _createHandler;
178
- /**
179
- * Redirect request
180
- * @param res
181
- * @param req
182
- * @param url string of url
183
- * @param code redirect status code
184
- * @private
185
- */
186
- private static _redirect;
187
- /**
188
- * Abort request by timeout
189
- * @private
190
- */
191
- private _abortTimeout;
192
- /**
193
- * lookup for host
194
- * @param host
195
- * @param resolve
196
- * @private
197
- */
198
- private _lookup;
59
+ declare module 'uWebSockets.js' {
60
+ interface HttpRequest {
61
+ cookies: Record<string, any>;
62
+ }
63
+ }
64
+ interface Handler {
65
+ method?: 'any' | 'connect' | 'del' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
66
+ pattern?: RecognizedString;
67
+ handler: (res: HttpResponse, req: HttpRequest, next: CallableFunction) => void | Promise<void | boolean | Error | string>;
68
+ }
69
+ interface WebSocket {
70
+ method: 'ws';
71
+ pattern?: RecognizedString;
72
+ behavior: WebSocketBehavior;
73
+ }
74
+ declare type Routes = Array<Handler | WebSocket | CallableFunction>;
75
+ interface Options {
76
+ routes: Routes;
77
+ host?: string;
78
+ port?: number;
79
+ timeout?: number;
80
+ mode?: "development" | "production";
81
+ appOptions?: AppOptions;
82
+ logLevel?: "info" | "warn" | "error" | "silent";
83
+ }
84
+ /**
85
+ * Status code to string
86
+ */
87
+ declare const codeToStatus: (code: number) => any;
88
+ /**
89
+ * Create server
90
+ */
91
+ declare class Server {
92
+ private _logLevel;
93
+ /**
94
+ * Listen socket
95
+ * @private
96
+ */
97
+ private _socket;
98
+ /**
99
+ * Request timeout
100
+ * @private
101
+ */
102
+ private readonly _timeout;
103
+ private readonly _routes;
104
+ private _host;
105
+ private _port;
106
+ private readonly _mode;
107
+ private readonly _appOptions;
108
+ private _app;
109
+ private _protocol;
110
+ /**
111
+ *Timeout identification
112
+ * @private
113
+ */
114
+ private _timeoutId;
115
+ /**
116
+ * Default route options
117
+ * @private
118
+ */
119
+ private _defaultRoute;
120
+ /**
121
+ * @constructor
122
+ * @param options
123
+ */
124
+ constructor(options: Options);
125
+ /**
126
+ * Get TemplatedApp instance
127
+ */
128
+ getApp(): TemplatedApp;
129
+ /**
130
+ * Create app (server http)
131
+ * @returns this
132
+ */
133
+ app(): this;
134
+ /**
135
+ * Create sslApp
136
+ * @returns this
137
+ */
138
+ sslApp(): this;
139
+ /**
140
+ * Push route
141
+ * @param route
142
+ * @returns this
143
+ */
144
+ push(route: Handler | WebSocket | CallableFunction): this;
145
+ /**
146
+ * unshift route
147
+ * @param route
148
+ * @returns this
149
+ */
150
+ unshift(route: Handler | WebSocket | CallableFunction): this;
151
+ /**
152
+ * Create server listener
153
+ * @param host - host or port
154
+ * @param port
155
+ * @param fn
156
+ * @returns this
157
+ */
158
+ listen(host: string, port: number, fn?: CallableFunction): this;
159
+ listen(port: number, fn?: CallableFunction): this;
160
+ listen(fn?: CallableFunction): this;
161
+ /**
162
+ * Closes a uSockets listen socket.
163
+ */
164
+ close(): Promise<this>;
165
+ /**
166
+ * Return socket port
167
+ */
168
+ socketPort(): Promise<number>;
169
+ /**
170
+ * Create decoration of handler
171
+ * @param res http response
172
+ * @param req http request
173
+ * @param fn handler
174
+ * @private
175
+ */
176
+ private _createHandler;
177
+ /**
178
+ * Redirect request
179
+ * @param res
180
+ * @param req
181
+ * @param url string of url
182
+ * @param code redirect status code
183
+ * @private
184
+ */
185
+ private static _redirect;
186
+ /**
187
+ * Abort request by timeout
188
+ * @private
189
+ */
190
+ private _abortTimeout;
191
+ /**
192
+ * lookup for host
193
+ * @param host
194
+ * @param resolve
195
+ * @private
196
+ */
197
+ private _lookup;
199
198
  }
200
199
 
201
- /**
202
- * @class Jwt
203
- * @description working with jwt tokens
204
- */
205
- declare class Jwt {
206
- private readonly secret;
207
- private readonly algorithm;
208
- /**
209
- * @constructor
210
- * @param secret
211
- * @param opt addition options
212
- */
213
- constructor(secret: string, opt?: {
214
- algorithm: string;
215
- });
216
- /**
217
- * Verify jwt token
218
- * @param jwt token
219
- * @returns is token valid
220
- */
221
- verify(jwt: string): boolean;
222
- /**
223
- * Get token
224
- * @param data - user data
225
- * @returns jwt
226
- */
227
- sign(data: any): string;
228
- /**
229
- * Decode token
230
- * @param jwt - jwt token
231
- * @returns {head, body}
232
- */
233
- decode(jwt: string): {
234
- head: any;
235
- body: any;
236
- };
200
+ /**
201
+ * @class Jwt
202
+ * @description working with jwt tokens
203
+ */
204
+ declare class Jwt {
205
+ private readonly secret;
206
+ private readonly algorithm;
207
+ /**
208
+ * @constructor
209
+ * @param secret
210
+ * @param opt addition options
211
+ */
212
+ constructor(secret: string, opt?: {
213
+ algorithm: string;
214
+ });
215
+ /**
216
+ * Verify jwt token
217
+ * @param jwt token
218
+ * @returns is token valid
219
+ */
220
+ verify(jwt: string): boolean;
221
+ /**
222
+ * Get token
223
+ * @param data - user data
224
+ * @returns jwt
225
+ */
226
+ sign(data: any): string;
227
+ /**
228
+ * Decode token
229
+ * @param jwt - jwt token
230
+ * @returns {head, body}
231
+ */
232
+ decode(jwt: string): {
233
+ head: any;
234
+ body: any;
235
+ };
237
236
  }
238
237
 
239
- /**
240
- * @class Jwt
241
- * @description working with jwt tokens use webcrypto
242
- */
243
- declare class AsyncJwt {
244
- private readonly secret;
245
- private readonly algorithm;
246
- /**
247
- * @constructor
248
- * @param secret
249
- * @param opt addition options
250
- */
251
- constructor(secret: string, opt?: {
252
- algorithm: string;
253
- });
254
- /**
255
- * Verify jwt token
256
- * @param jwt token
257
- * @returns is token valid
258
- */
259
- verify(jwt: string): Promise<boolean>;
260
- /**
261
- * Get token
262
- * @param data - user data
263
- * @returns jwt
264
- */
265
- sign(data: any): Promise<string>;
266
- /**
267
- * Decode token
268
- * @param jwt - jwt token
269
- * @returns {head, body}
270
- */
271
- decode(jwt: string): {
272
- head: any;
273
- body: any;
274
- };
275
- /**
276
- * Sign
277
- * @param str input string
278
- * @returns base64 sign
279
- * @private
280
- */
281
- private signString;
238
+ /**
239
+ * @class Jwt
240
+ * @description working with jwt tokens use webcrypto
241
+ */
242
+ declare class AsyncJwt {
243
+ private readonly secret;
244
+ private readonly algorithm;
245
+ /**
246
+ * @constructor
247
+ * @param secret
248
+ * @param opt addition options
249
+ */
250
+ constructor(secret: string, opt?: {
251
+ algorithm: string;
252
+ });
253
+ /**
254
+ * Verify jwt token
255
+ * @param jwt token
256
+ * @returns is token valid
257
+ */
258
+ verify(jwt: string): Promise<boolean>;
259
+ /**
260
+ * Get token
261
+ * @param data - user data
262
+ * @returns jwt
263
+ */
264
+ sign(data: any): Promise<string>;
265
+ /**
266
+ * Decode token
267
+ * @param jwt - jwt token
268
+ * @returns {head, body}
269
+ */
270
+ decode(jwt: string): {
271
+ head: any;
272
+ body: any;
273
+ };
274
+ /**
275
+ * Sign
276
+ * @param str input string
277
+ * @returns base64 sign
278
+ * @private
279
+ */
280
+ private signString;
282
281
  }
283
282
 
284
- declare class Memcached {
285
- memjs: Client | null;
286
- specialHeaders: Record<string, any>;
287
- maxKeyLength: number;
288
- debug: number;
289
- prefix: string;
290
- /**
291
- * @constructor
292
- * @param memjs - memjs Client instance
293
- * @param specialHeaders - special headers
294
- * @param maxKeyLength - max key length
295
- * @param debug
296
- */
297
- constructor(memjs: Client | null, specialHeaders?: {
298
- 'x-cache': string;
299
- }, maxKeyLength?: number, debug?: number);
300
- /**
301
- * Is Client exists
302
- */
303
- isClient(): boolean;
304
- /**
305
- * Is in client is one or more conected servers
306
- */
307
- isConnectedServers(): boolean;
308
- /**
309
- * Set value to memcache
310
- * @param key string key
311
- * @param value value
312
- * @param expires expiers in second
313
- */
314
- setValue(key: string, value: string | Buffer, expires: number | undefined | null): Promise<void>;
315
- /**
316
- * Get value from memory
317
- * @param key string key
318
- */
319
- getValue(key: string): Promise<null | Buffer>;
320
- /**
321
- * Delete value
322
- * @param key
323
- */
324
- deleteValue(key: string): Promise<boolean>;
325
- /**
326
- * Set page to cache
327
- * @param url https://yur.site.net
328
- * @param headers
329
- * @param data eny data string or Buffer
330
- * @param expires
331
- */
332
- setPage(url: string, headers: Record<string, any>, data: string | Buffer, expires: number | undefined | null): Promise<void>;
333
- /**
334
- * Get Page and headers
335
- * @param url https://your.site.net
336
- * @returns {data, headers}
337
- */
338
- getPage(url: string): Promise<null | {
339
- data: Buffer;
340
- headers: Record<string, any>;
341
- }>;
342
- /**
343
- * Keys to lower case in Object
344
- * @param o
345
- * @private
346
- */
347
- private objectKeysToLower;
283
+ declare class Memcached {
284
+ memjs: Client | null;
285
+ specialHeaders: Record<string, any>;
286
+ maxKeyLength: number;
287
+ debug: number;
288
+ prefix: string;
289
+ /**
290
+ * @constructor
291
+ * @param memjs - memjs Client instance
292
+ * @param specialHeaders - special headers
293
+ * @param maxKeyLength - max key length
294
+ * @param debug
295
+ */
296
+ constructor(memjs: Client | null, specialHeaders?: {
297
+ 'x-cache': string;
298
+ }, maxKeyLength?: number, debug?: number);
299
+ /**
300
+ * Is Client exists
301
+ */
302
+ isClient(): boolean;
303
+ /**
304
+ * Is in client is one or more conected servers
305
+ */
306
+ isConnectedServers(): boolean;
307
+ /**
308
+ * Set value to memcache
309
+ * @param key string key
310
+ * @param value value
311
+ * @param expires expiers in second
312
+ */
313
+ setValue(key: string, value: string | Buffer, expires: number | undefined | null): Promise<void>;
314
+ /**
315
+ * Get value from memory
316
+ * @param key string key
317
+ */
318
+ getValue(key: string): Promise<null | Buffer>;
319
+ /**
320
+ * Delete value
321
+ * @param key
322
+ */
323
+ deleteValue(key: string): Promise<boolean>;
324
+ /**
325
+ * Set page to cache
326
+ * @param url https://yur.site.net
327
+ * @param headers
328
+ * @param data eny data string or Buffer
329
+ * @param expires
330
+ */
331
+ setPage(url: string, headers: Record<string, any>, data: string | Buffer, expires: number | undefined | null): Promise<void>;
332
+ /**
333
+ * Get Page and headers
334
+ * @param url https://your.site.net
335
+ * @returns {data, headers}
336
+ */
337
+ getPage(url: string): Promise<null | {
338
+ data: Buffer;
339
+ headers: Record<string, any>;
340
+ }>;
341
+ /**
342
+ * Keys to lower case in Object
343
+ * @param o
344
+ * @private
345
+ */
346
+ private objectKeysToLower;
348
347
  }
349
348
 
350
- /**
351
- * Reed static files
352
- * @param req
353
- * @param res
354
- * @param base
355
- */
349
+ /**
350
+ * Reed static files
351
+ * @param req
352
+ * @param res
353
+ * @param base
354
+ */
356
355
  declare function staticBody(res: HttpResponse, req: HttpRequest, base: string): Promise<void>;
357
356
 
358
- interface OptionsSsr {
359
- readonly manifest: Record<string, any>;
360
- readonly memcached?: Memcached;
361
- readonly [key: string]: any;
362
- }
363
- declare type EntryFunction = (url: string, opt: Record<string, any>) => Promise<any>;
364
-
365
- /**
366
- * Ssr handler for production
367
- */
368
- declare class Ssr {
369
- res: HttpResponse;
370
- req: HttpRequest;
371
- context: OptionsSsr;
372
- entry: EntryFunction | any;
373
- /**
374
- * @constructor
375
- * @param res response
376
- * @param req request
377
- * @param context params
378
- * @param entry - entry point function
379
- */
380
- constructor(res: HttpResponse, req: HttpRequest, context: OptionsSsr, entry: EntryFunction | any);
381
- /**
382
- * @param request addition request params
383
- */
384
- request(request?: Record<string, any>): Promise<void>;
357
+ interface OptionsSsr {
358
+ readonly manifest: Record<string, any>;
359
+ readonly memcached?: Memcached;
360
+ readonly [key: string]: any;
385
361
  }
362
+ declare type EntryFunction = (url: string, opt: Record<string, any>) => Promise<any>;
386
363
 
387
- declare type method$2 = 'any' | 'connect' | 'del' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
388
- declare module "uWebSockets.js" {
389
- interface HttpRequest {
390
- cookies: Record<string, any>;
391
- }
392
- }
393
- interface Route$1 {
394
- name: string;
395
- method?: method$2 | Array<method$2>;
396
- component: any;
397
- }
398
- interface Config$1 {
399
- server: Record<string, any>;
400
- db: Record<string, any>;
401
- [key: string]: any;
364
+ /**
365
+ * Ssr handler for production
366
+ */
367
+ declare class Ssr {
368
+ res: HttpResponse;
369
+ req: HttpRequest;
370
+ context: OptionsSsr;
371
+ entry: EntryFunction | any;
372
+ /**
373
+ * @constructor
374
+ * @param res response
375
+ * @param req request
376
+ * @param context params
377
+ * @param entry - entry point function
378
+ */
379
+ constructor(res: HttpResponse, req: HttpRequest, context: OptionsSsr, entry: EntryFunction | any);
380
+ /**
381
+ * @param request addition request params
382
+ */
383
+ request(request?: Record<string, any>): Promise<void>;
402
384
  }
403
385
 
404
- /**
405
- * Select controller params from json file
406
- * And check permissions and method
407
- */
408
-
409
- interface Schema$1 {
410
- controllers: Array<{
411
- id?: number;
412
- name: string;
413
- isActive?: boolean;
414
- isSitemap?: boolean;
415
- subactions: Array<{
416
- id?: number;
417
- action: string;
418
- name: string;
419
- isPermission?: boolean;
420
- isCheckMethod?: boolean;
421
- isLog?: boolean;
422
- isActive?: boolean;
423
- }>;
424
- }>;
425
- actions: Array<{
426
- id?: number;
427
- name: string;
428
- isActive?: boolean;
429
- method?: method$2 | string;
430
- }>;
386
+ declare type method$2 = 'any' | 'connect' | 'del' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
387
+ declare module "uWebSockets.js" {
388
+ interface HttpRequest {
389
+ cookies: Record<string, any>;
390
+ }
391
+ }
392
+ interface Route$1 {
393
+ name: string;
394
+ method?: method$2 | Array<method$2>;
395
+ component: any;
431
396
  }
397
+ interface Config$1 {
398
+ server: Record<string, any>;
399
+ db: Record<string, any>;
400
+ [key: string]: any;
401
+ }
402
+
403
+ /**
404
+ * Select controller params from json file
405
+ * And check permissions and method
406
+ */
432
407
 
433
- declare type method$1 = 'any' | 'connect' | 'del' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
434
- declare module "uWebSockets.js" {
435
- interface HttpRequest {
436
- cookies: Record<string, any>;
437
- }
438
- }
439
- interface Route {
440
- name: string;
441
- method?: method$1 | Array<method$1>;
442
- component: any;
443
- }
444
- interface OptionsWeb {
445
- readonly routes: Array<Route>;
446
- readonly config: Config;
447
- readonly db: Record<string, Query>;
448
- readonly schema?: Schema$1;
449
- readonly stack?: {
450
- memcached?: Memcached;
451
- memcachedPrefix?: string;
452
- memcachedExpiry?: number;
453
- redis?: any;
454
- [key: string]: any;
455
- };
456
- readonly [key: string]: any;
457
- }
458
- interface Response$1 {
459
- statusCode: number;
460
- headers: Record<string, any>;
461
- body: any;
462
- }
463
- interface Config {
464
- server: Record<string, any>;
465
- db: Record<string, any>;
466
- [key: string]: any;
467
- }
468
- interface ActionsParmas {
469
- controller: {
470
- id?: number;
471
- name: string;
472
- isActive: boolean;
473
- isSitemap: boolean;
474
- };
475
- subaction: {
476
- id?: number;
477
- name: string;
478
- isPermission: boolean;
479
- isCheckMethod: boolean;
480
- isLog: boolean;
481
- isActive: boolean;
482
- };
483
- action: {
484
- id?: number;
485
- name: string;
486
- isActive: boolean;
487
- method: method$1;
488
- };
489
- }
490
- interface ContextWeb extends ActionsParmas {
491
- readonly config: Config;
492
- readonly db: Record<string, Query>;
493
- readonly stack: {
494
- memcached?: Memcached;
495
- redis?: any;
496
- [key: string]: any;
497
- };
498
- [key: string]: any;
499
- }
500
- interface ContextWebController extends ContextWeb {
501
- method: string;
502
- cookies: Record<string, any>;
503
- hostname: string;
504
- protocol: string;
505
- url: string;
506
- headers: Record<string, any>;
507
- getRequest: () => Record<string, any>;
508
- db: Record<string, Query>;
509
- $stream?: Stream;
510
- $body?: any;
511
- $route?: Route;
512
- }
513
- /**
514
- * Entry point for /web api
515
- * handler for api request
516
- */
517
- declare class Web {
518
- res: HttpResponse;
519
- req: HttpRequest;
520
- context: OptionsWeb;
521
- defaultRequest: {
522
- controller: string;
523
- subaction: string;
524
- lang: string;
525
- };
526
- defaultResponse: {
527
- statusCode: number;
528
- headers: {
529
- "content-type": string;
530
- };
531
- body: {};
532
- };
533
- route: Route;
534
- contextWeb: ContextWeb;
535
- /**
536
- * @constructor
537
- * @param res response
538
- * @param req request
539
- * @param context params
540
- */
541
- constructor(res: HttpResponse, req: HttpRequest, context: OptionsWeb);
542
- request(request?: Record<string, any>): Promise<void>;
543
- /**
544
- * Import controller class
545
- * @param request params
546
- * @private
547
- */
548
- private importController;
549
- /**
550
- * Find route in api routers
551
- * @private
552
- */
553
- private findRoute;
554
- /**
555
- * Inject app context
556
- * @param obj
557
- * @private
558
- */
559
- private injectContext;
560
- /**
561
- * Initing component if init method exists
562
- * @param obj
563
- * @returns
564
- * @private
565
- */
566
- private initComponent;
567
- /**
568
- * Success response
569
- */
570
- success(response: Response$1): void;
571
- /**
572
- * Error response
573
- */
574
- error(e: ApiError | Error): void;
408
+ interface Schema$1 {
409
+ controllers: Array<{
410
+ id?: number;
411
+ name: string;
412
+ isActive?: boolean;
413
+ isSitemap?: boolean;
414
+ subactions: Array<{
415
+ id?: number;
416
+ action: string;
417
+ name: string;
418
+ isPermission?: boolean;
419
+ isCheckMethod?: boolean;
420
+ isLog?: boolean;
421
+ isActive?: boolean;
422
+ }>;
423
+ }>;
424
+ actions: Array<{
425
+ id?: number;
426
+ name: string;
427
+ isActive?: boolean;
428
+ method?: method$2 | string;
429
+ }>;
575
430
  }
576
431
 
577
- interface TestContext {
578
- readonly config?: Config$1;
579
- readonly db?: Record<string, Query>;
580
- controller?: {
581
- id: number;
582
- name: string;
583
- isActive: boolean;
584
- isSitemap: boolean;
585
- };
586
- subaction?: {
587
- id: number;
588
- name: string;
589
- isPermission: boolean;
590
- isCheckMethod: boolean;
591
- isLog: boolean;
592
- isActive: boolean;
593
- };
594
- action?: {
595
- id: number;
596
- name: string;
597
- isActive: boolean;
598
- method: method$2;
599
- };
600
- method?: method$2;
601
- cookies?: Record<string, any>;
602
- hostname?: string;
603
- protocol?: string;
604
- url?: string;
605
- headers?: Record<string, any>;
606
- getRequest?: () => Record<string, any>;
607
- $stream?: Stream;
608
- $body?: any;
609
- $route?: Route$1;
610
- [key: string]: any;
611
- }
612
- /**
613
- * Create class with inject context
614
- */
432
+ declare type method$1 = 'any' | 'connect' | 'del' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
433
+ declare module "uWebSockets.js" {
434
+ interface HttpRequest {
435
+ cookies: Record<string, any>;
436
+ }
437
+ }
438
+ interface Route {
439
+ name: string;
440
+ method?: method$1 | Array<method$1>;
441
+ component: any;
442
+ }
443
+ interface OptionsWeb {
444
+ readonly routes: Array<Route>;
445
+ readonly config: Config;
446
+ readonly db: Record<string, Query>;
447
+ readonly schema?: Schema$1;
448
+ readonly stack?: {
449
+ memcached?: Memcached;
450
+ memcachedPrefix?: string;
451
+ memcachedExpiry?: number;
452
+ redis?: any;
453
+ [key: string]: any;
454
+ };
455
+ readonly [key: string]: any;
456
+ }
457
+ interface Response$1 {
458
+ statusCode: number;
459
+ headers: Record<string, any>;
460
+ body: any;
461
+ }
462
+ interface Config {
463
+ server: Record<string, any>;
464
+ db: Record<string, any>;
465
+ [key: string]: any;
466
+ }
467
+ interface ActionsParmas {
468
+ controller: {
469
+ id?: number;
470
+ name: string;
471
+ isActive: boolean;
472
+ isSitemap: boolean;
473
+ };
474
+ subaction: {
475
+ id?: number;
476
+ name: string;
477
+ isPermission: boolean;
478
+ isCheckMethod: boolean;
479
+ isLog: boolean;
480
+ isActive: boolean;
481
+ };
482
+ action: {
483
+ id?: number;
484
+ name: string;
485
+ isActive: boolean;
486
+ method: method$1;
487
+ };
488
+ }
489
+ interface ContextWeb extends ActionsParmas {
490
+ readonly config: Config;
491
+ readonly db: Record<string, Query>;
492
+ readonly stack: {
493
+ memcached?: Memcached;
494
+ redis?: any;
495
+ [key: string]: any;
496
+ };
497
+ [key: string]: any;
498
+ }
499
+ interface ContextWebController extends ContextWeb {
500
+ method: string;
501
+ cookies: Record<string, any>;
502
+ hostname: string;
503
+ protocol: string;
504
+ url: string;
505
+ headers: Record<string, any>;
506
+ getRequest: () => Record<string, any>;
507
+ db: Record<string, Query>;
508
+ $stream?: Stream;
509
+ $body?: any;
510
+ $route?: Route;
511
+ }
512
+ /**
513
+ * Entry point for /web api
514
+ * handler for api request
515
+ */
516
+ declare class Web {
517
+ res: HttpResponse;
518
+ req: HttpRequest;
519
+ context: OptionsWeb;
520
+ defaultRequest: {
521
+ controller: string;
522
+ subaction: string;
523
+ lang: string;
524
+ };
525
+ defaultResponse: {
526
+ statusCode: number;
527
+ headers: {
528
+ "content-type": string;
529
+ };
530
+ body: {};
531
+ };
532
+ route: Route;
533
+ contextWeb: ContextWeb;
534
+ /**
535
+ * @constructor
536
+ * @param res response
537
+ * @param req request
538
+ * @param context params
539
+ */
540
+ constructor(res: HttpResponse, req: HttpRequest, context: OptionsWeb);
541
+ request(request?: Record<string, any>): Promise<void>;
542
+ /**
543
+ * Import controller class
544
+ * @param request params
545
+ * @private
546
+ */
547
+ private importController;
548
+ /**
549
+ * Find route in api routers
550
+ * @private
551
+ */
552
+ private findRoute;
553
+ /**
554
+ * Inject app context
555
+ * @param obj
556
+ * @private
557
+ */
558
+ private injectContext;
559
+ /**
560
+ * Initing component if init method exists
561
+ * @param obj
562
+ * @returns
563
+ * @private
564
+ */
565
+ private initComponent;
566
+ /**
567
+ * Success response
568
+ */
569
+ success(response: Response$1): void;
570
+ /**
571
+ * Error response
572
+ */
573
+ error(e: ApiError | Error): void;
574
+ }
575
+
576
+ interface TestContext {
577
+ readonly config?: Config$1;
578
+ readonly db?: Record<string, Query>;
579
+ controller?: {
580
+ id: number;
581
+ name: string;
582
+ isActive: boolean;
583
+ isSitemap: boolean;
584
+ };
585
+ subaction?: {
586
+ id: number;
587
+ name: string;
588
+ isPermission: boolean;
589
+ isCheckMethod: boolean;
590
+ isLog: boolean;
591
+ isActive: boolean;
592
+ };
593
+ action?: {
594
+ id: number;
595
+ name: string;
596
+ isActive: boolean;
597
+ method: method$2;
598
+ };
599
+ method?: method$2;
600
+ cookies?: Record<string, any>;
601
+ hostname?: string;
602
+ protocol?: string;
603
+ url?: string;
604
+ headers?: Record<string, any>;
605
+ getRequest?: () => Record<string, any>;
606
+ $stream?: Stream;
607
+ $body?: any;
608
+ $route?: Route$1;
609
+ [key: string]: any;
610
+ }
611
+ /**
612
+ * Create class with inject context
613
+ */
615
614
  declare const mountWithContext: <T>($class: new () => T, $context: TestContext, request?: Record<string, any>) => Promise<T>;
616
615
 
617
- interface Context extends ContextWeb {
618
- method: string;
619
- getRequest: () => Record<string, any>;
620
- db: Record<string, any>;
621
- headers: Record<string, any>;
622
- }
623
- /**
624
- * Base model
625
- */
626
- declare class Model {
627
- protected $context: Context;
628
- /**
629
- * Create model
630
- * @param model
631
- * @param args
632
- */
633
- protected $create<T extends Model | Record<string, any>, A extends Array<any>>(model: {
634
- new (...args: [...A]): T;
635
- }, ...args: [...A]): Promise<T>;
636
- /**
637
- * Inject app context
638
- * @param context
639
- */
640
- $inject(context: any): void;
641
- getContext(): Context;
642
- getRequest(): Record<string, any>;
643
- getConfig(): Record<string, any>;
644
- getMethod(): method$1;
645
- getHeaders(): Record<string, any>;
646
- getCookies(): Record<string, any>;
647
- getController(): Context["controller"];
648
- getAction(): Context["action"];
649
- getSubaction(): Context["subaction"];
650
- getDb(): Record<string, Query>;
651
- getHome(): Query;
652
- getPool(key?: string): Query;
653
- setResponseHeader(key: string, value: string): any;
654
- setCookieHeader(name: string, value: any, options?: Record<string, any>): any;
616
+ interface Context extends ContextWeb {
617
+ method: string;
618
+ getRequest: () => Record<string, any>;
619
+ db: Record<string, any>;
620
+ headers: Record<string, any>;
621
+ }
622
+ /**
623
+ * Base model
624
+ */
625
+ declare class Model {
626
+ protected $context: Context;
627
+ /**
628
+ * Create model
629
+ * @param model
630
+ * @param args
631
+ */
632
+ protected $create<T extends Model | Record<string, any>, A extends Array<any>>(model: {
633
+ new (...args: [...A]): T;
634
+ }, ...args: [...A]): Promise<T>;
635
+ /**
636
+ * Inject app context
637
+ * @param context
638
+ */
639
+ $inject(context: any): void;
640
+ getContext(): Context;
641
+ getRequest(): Record<string, any>;
642
+ getConfig(): Record<string, any>;
643
+ getMethod(): method$1;
644
+ getHeaders(): Record<string, any>;
645
+ getCookies(): Record<string, any>;
646
+ getController(): Context["controller"];
647
+ getAction(): Context["action"];
648
+ getSubaction(): Context["subaction"];
649
+ getDb(): Record<string, Query>;
650
+ getHome(): Query;
651
+ getPool(key?: string): Query;
652
+ setResponseHeader(key: string, value: string): any;
653
+ setCookieHeader(name: string, value: any, options?: Record<string, any>): any;
655
654
  }
656
655
 
657
- interface ResponseOptions {
658
- memcache?: number | null;
659
- headers?: Record<string, any>;
660
- statusCode?: number;
661
- }
662
- /**
663
- * Base Controller
664
- */
665
- declare class Controller {
666
- private responseHeaders;
667
- $context: ContextWebController;
668
- /**
669
- * Set cookies
670
- * @param name
671
- * @param value
672
- * @param options
673
- */
674
- setCookieHeader(name: string, value: any, options?: Record<string, any>): string;
675
- /**
676
- * Success request
677
- * @param data response params
678
- * @param options
679
- * @returns
680
- */
681
- success(data?: {}, options?: ResponseOptions | any): {
682
- headers: any;
683
- body: {
684
- isError: boolean;
685
- data: {};
686
- };
687
- memcache: any;
688
- statusCode: any;
689
- };
690
- /**
691
- * Error response
692
- * @param err
693
- */
694
- error(err: unknown | Error | ApiError): {
695
- headers: {
696
- "content-type": string;
697
- } & Record<string, string>;
698
- body: {
699
- isError: boolean;
700
- error: string;
701
- code: number;
702
- data: Record<string, unknown>;
703
- stack: string | undefined;
704
- response: {
705
- status: any;
706
- headers: any;
707
- config: {
708
- url: any;
709
- method: any;
710
- params: any;
711
- headers: any;
712
- };
713
- data: any;
714
- } | {
715
- status?: undefined;
716
- headers?: undefined;
717
- config?: undefined;
718
- data?: undefined;
719
- };
720
- };
721
- statusCode: number;
722
- };
723
- /**
724
- * Xml response
725
- * @param data response params
726
- * @param options addition options
727
- */
728
- successXml(data?: {}, options?: ResponseOptions): {
729
- headers: {
730
- "content-type": string;
731
- } & Record<string, string | string[]> & Record<string, any>;
732
- body: string;
733
- memcache: any;
734
- };
735
- /**
736
- * Error xml response
737
- * @param err error object
738
- */
739
- errorXml(err: unknown | Error | ApiError): {
740
- headers: {
741
- "content-type": string;
742
- } & Record<string, string>;
743
- body: string;
744
- statusCode: number;
745
- };
746
- /**
747
- * Create model
748
- * @param model
749
- * @param args
750
- */
751
- $create<T extends Model | Record<string, any>, A extends Array<any>>(model: {
752
- new (...args: [...A]): T;
753
- }, ...args: [...A]): Promise<T>;
754
- /**
755
- * Inject app context
756
- * @param context
757
- */
758
- $inject(context: ContextWebController): void;
759
- getContext(): ContextWebController;
760
- getRequest(): Record<string, any>;
761
- getBody(): Buffer;
762
- getStream(): Stream;
763
- getConfig(): Record<string, any>;
764
- getMethod(): method$1;
765
- getCookies(): Record<string, any>;
766
- getHostname(): string;
767
- getUrl(): string;
768
- getProtocol(): "http" | "https";
769
- getDb(): Record<string, Query>;
770
- getHeaders(): Record<string, any>;
771
- getController(): ContextWebController["controller"];
772
- getAction(): ContextWebController["action"];
773
- getSubaction(): ContextWebController["subaction"];
774
- getHome(): Query;
775
- getPool(key?: string): Query;
776
- getStack(): {
777
- [key: string]: any;
778
- memcached?: __.Memcached | undefined;
779
- redis?: any;
780
- };
781
- setResponseHeader(key: string, value: string): void;
656
+ interface ResponseOptions {
657
+ memcache?: number | null;
658
+ headers?: Record<string, any>;
659
+ statusCode?: number;
660
+ }
661
+ /**
662
+ * Base Controller
663
+ */
664
+ declare class Controller {
665
+ private responseHeaders;
666
+ $context: ContextWebController;
667
+ /**
668
+ * Set cookies
669
+ * @param name
670
+ * @param value
671
+ * @param options
672
+ */
673
+ setCookieHeader(name: string, value: any, options?: Record<string, any>): string;
674
+ /**
675
+ * Success request
676
+ * @param data response params
677
+ * @param options
678
+ * @returns
679
+ */
680
+ success(data?: {}, options?: ResponseOptions | any): {
681
+ headers: any;
682
+ body: {
683
+ isError: boolean;
684
+ data: {};
685
+ };
686
+ memcache: any;
687
+ statusCode: any;
688
+ };
689
+ /**
690
+ * Error response
691
+ * @param err
692
+ */
693
+ error(err: unknown | Error | ApiError): {
694
+ headers: {
695
+ "content-type": string;
696
+ } & Record<string, string>;
697
+ body: {
698
+ isError: boolean;
699
+ error: string;
700
+ code: number;
701
+ data: Record<string, unknown>;
702
+ stack: string | undefined;
703
+ response: {
704
+ status: any;
705
+ headers: any;
706
+ config: {
707
+ url: any;
708
+ method: any;
709
+ params: any;
710
+ headers: any;
711
+ };
712
+ data: any;
713
+ } | {
714
+ status?: undefined;
715
+ headers?: undefined;
716
+ config?: undefined;
717
+ data?: undefined;
718
+ };
719
+ };
720
+ statusCode: number;
721
+ };
722
+ /**
723
+ * Xml response
724
+ * @param data response params
725
+ * @param options addition options
726
+ */
727
+ successXml(data?: {}, options?: ResponseOptions): {
728
+ headers: {
729
+ "content-type": string;
730
+ } & Record<string, string | string[]> & Record<string, any>;
731
+ body: string;
732
+ memcache: any;
733
+ };
734
+ /**
735
+ * Error xml response
736
+ * @param err error object
737
+ */
738
+ errorXml(err: unknown | Error | ApiError): {
739
+ headers: {
740
+ "content-type": string;
741
+ } & Record<string, string>;
742
+ body: string;
743
+ statusCode: number;
744
+ };
745
+ /**
746
+ * Create model
747
+ * @param model
748
+ * @param args
749
+ */
750
+ $create<T extends Model | Record<string, any>, A extends Array<any>>(model: {
751
+ new (...args: [...A]): T;
752
+ }, ...args: [...A]): Promise<T>;
753
+ /**
754
+ * Inject app context
755
+ * @param context
756
+ */
757
+ $inject(context: ContextWebController): void;
758
+ getContext(): ContextWebController;
759
+ getRequest(): Record<string, any>;
760
+ getBody(): Buffer;
761
+ getStream(): Stream;
762
+ getConfig(): Record<string, any>;
763
+ getMethod(): method$1;
764
+ getCookies(): Record<string, any>;
765
+ getHostname(): string;
766
+ getUrl(): string;
767
+ getProtocol(): "http" | "https";
768
+ getDb(): Record<string, Query>;
769
+ getHeaders(): Record<string, any>;
770
+ getController(): ContextWebController["controller"];
771
+ getAction(): ContextWebController["action"];
772
+ getSubaction(): ContextWebController["subaction"];
773
+ getHome(): Query;
774
+ getPool(key?: string): Query;
775
+ getStack(): {
776
+ [key: string]: any;
777
+ memcached?: Memcached | undefined;
778
+ redis?: any;
779
+ };
780
+ setResponseHeader(key: string, value: string): void;
782
781
  }
783
782
 
784
- /**
785
- * Select controller params from json file
786
- * And check permissions and method
787
- */
788
-
789
- interface Schema {
790
- controllers: Array<{
791
- id?: number;
792
- name: string;
793
- isActive?: boolean;
794
- isSitemap?: boolean;
795
- subactions: Array<{
796
- id?: number;
797
- action: string;
798
- name: string;
799
- isPermission?: boolean;
800
- isCheckMethod?: boolean;
801
- isLog?: boolean;
802
- isActive?: boolean;
803
- }>;
804
- }>;
805
- actions: Array<{
806
- id?: number;
807
- name: string;
808
- isActive?: boolean;
809
- method?: method$2 | string;
810
- }>;
783
+ /**
784
+ * Select controller params from json file
785
+ * And check permissions and method
786
+ */
787
+
788
+ interface Schema {
789
+ controllers: Array<{
790
+ id?: number;
791
+ name: string;
792
+ isActive?: boolean;
793
+ isSitemap?: boolean;
794
+ subactions: Array<{
795
+ id?: number;
796
+ action: string;
797
+ name: string;
798
+ isPermission?: boolean;
799
+ isCheckMethod?: boolean;
800
+ isLog?: boolean;
801
+ isActive?: boolean;
802
+ }>;
803
+ }>;
804
+ actions: Array<{
805
+ id?: number;
806
+ name: string;
807
+ isActive?: boolean;
808
+ method?: method$2 | string;
809
+ }>;
811
810
  }
812
811
 
813
- /**
814
- * Response interface
815
- */
816
- interface Response {
817
- memcache?: number | null;
818
- headers?: Record<string, any>;
819
- statusCode?: number;
820
- }
821
- declare type CallbackFunctionAny = (...args: any[]) => any;
822
- /**
823
- * Mixin helper for decorators
824
- * @param behaviour
825
- * @param sharedBehaviour
826
- * http://raganwald.com/2015/06/26/decorators-in-es7.html
827
- * http://raganwald.com/2015/06/17/functional-mixins.html
828
- * https://habr.com/ru/post/277021/
829
- */
830
- declare function mixin<T extends Record<string, any>>(behaviour: T, sharedBehaviour?: {}): (clazz: any) => any;
831
- /**
832
- * @request() decorator
833
- */
834
- declare function request(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
835
- /**
836
- * @context() decorator
837
- */
838
- declare function context(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
839
- /**
840
- * @config() decorator
841
- */
842
- declare function config(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
843
- /**
844
- * @method() decorator
845
- */
846
- declare function method(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
847
- /**
848
- * @cookies() decorator
849
- */
850
- declare function cookies(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
851
- /**
852
- * @hostname() decorator
853
- */
854
- declare function hostname(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
855
- /**
856
- * @url() decorator
857
- */
858
- declare function url(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
859
- /**
860
- * @protocol() decorator
861
- */
862
- declare function protocol(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
863
- /**
864
- * @db() decorator
865
- */
866
- declare function db(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
867
- /**
868
- * @headers() decorator
869
- */
870
- declare function headers(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
871
- /**
872
- * @controller() decorator
873
- */
874
- declare function controller(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
875
- /**
876
- * @action() decorator
877
- */
878
- declare function action(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
879
- /**
880
- * @subaction() decorator
881
- */
882
- declare function subaction(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
883
- /**
884
- * @body() decorator
885
- */
886
- declare function body(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
887
- /**
888
- * @stream() decorator
889
- */
890
- declare function stream(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
891
- /**
892
- * @home() decorator
893
- */
894
- declare function home(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
895
- /**
896
- * @pool() decorator
897
- */
898
- declare function pool(name?: string): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
899
- /**
900
- * @connection() decorator
901
- */
902
- declare function connection(name?: string): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
903
- /**
904
- * Json response
905
- * @param opt response options
906
- */
907
- declare function json(opt?: Response): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
908
- /**
909
- * Xml response
910
- * @param opt response options
911
- */
912
- declare function xml(opt?: Response): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
913
- /**
914
- * Logger
915
- * @param name logger name
916
- */
917
- declare function logerror(name: string): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
918
- /**
919
- * Subaction method decorator
920
- * @http() decorator
921
- */
922
- declare function http(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
923
- /**
924
- * @init decorator
925
- */
812
+ /**
813
+ * Response interface
814
+ */
815
+ interface Response {
816
+ memcache?: number | null;
817
+ headers?: Record<string, any>;
818
+ statusCode?: number;
819
+ }
820
+ declare type CallbackFunctionAny = (...args: any[]) => any;
821
+ /**
822
+ * Mixin helper for decorators
823
+ * @param behaviour
824
+ * @param sharedBehaviour
825
+ * http://raganwald.com/2015/06/26/decorators-in-es7.html
826
+ * http://raganwald.com/2015/06/17/functional-mixins.html
827
+ * https://habr.com/ru/post/277021/
828
+ */
829
+ declare function mixin<T extends Record<string, any>>(behaviour: T, sharedBehaviour?: {}): (clazz: any) => any;
830
+ /**
831
+ * @request() decorator
832
+ */
833
+ declare function request(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
834
+ /**
835
+ * @context() decorator
836
+ */
837
+ declare function context(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
838
+ /**
839
+ * @config() decorator
840
+ */
841
+ declare function config(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
842
+ /**
843
+ * @method() decorator
844
+ */
845
+ declare function method(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
846
+ /**
847
+ * @cookies() decorator
848
+ */
849
+ declare function cookies(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
850
+ /**
851
+ * @hostname() decorator
852
+ */
853
+ declare function hostname(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
854
+ /**
855
+ * @url() decorator
856
+ */
857
+ declare function url(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
858
+ /**
859
+ * @protocol() decorator
860
+ */
861
+ declare function protocol(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
862
+ /**
863
+ * @db() decorator
864
+ */
865
+ declare function db(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
866
+ /**
867
+ * @headers() decorator
868
+ */
869
+ declare function headers(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
870
+ /**
871
+ * @controller() decorator
872
+ */
873
+ declare function controller(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
874
+ /**
875
+ * @action() decorator
876
+ */
877
+ declare function action(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
878
+ /**
879
+ * @subaction() decorator
880
+ */
881
+ declare function subaction(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
882
+ /**
883
+ * @body() decorator
884
+ */
885
+ declare function body(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
886
+ /**
887
+ * @stream() decorator
888
+ */
889
+ declare function stream(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
890
+ /**
891
+ * @home() decorator
892
+ */
893
+ declare function home(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
894
+ /**
895
+ * @pool() decorator
896
+ */
897
+ declare function pool(name?: string): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
898
+ /**
899
+ * @connection() decorator
900
+ */
901
+ declare function connection(name?: string): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
902
+ /**
903
+ * Json response
904
+ * @param opt response options
905
+ */
906
+ declare function json(opt?: Response): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
907
+ /**
908
+ * Xml response
909
+ * @param opt response options
910
+ */
911
+ declare function xml(opt?: Response): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
912
+ /**
913
+ * Logger
914
+ * @param name logger name
915
+ */
916
+ declare function logerror(name: string): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
917
+ /**
918
+ * Subaction method decorator
919
+ * @http() decorator
920
+ */
921
+ declare function http(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
922
+ /**
923
+ * @init decorator
924
+ */
926
925
  declare function init(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
927
926
 
928
- declare const helpers: {
929
- cookieParse: (str: string) => Record<string, any>;
930
- cookieString: (name: string, value: any, options?: Record<string, any>) => string;
931
- jsonBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest) => Promise<any>;
932
- rawBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest) => Promise<Buffer>;
933
- streamBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest) => stream$1.Stream;
934
- urlencodedBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest) => Promise<any>;
935
- multipartBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest, options?: formidable.Options) => Promise<any>;
936
- readConfig: (jsonfile: string) => Promise<any>;
937
- readConfigSync: (jsonfile: string) => any;
938
- staticBody: typeof staticBody;
939
- extensions: string[];
940
- getExt: (path: string) => string;
941
- jwtDecode: (jwt: string) => {
942
- head: any;
943
- body: any;
944
- };
927
+ declare const helpers: {
928
+ cookieParse: (str: string) => Record<string, any>;
929
+ cookieString: (name: string, value: any, options?: Record<string, any>) => string;
930
+ jsonBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest) => Promise<any>;
931
+ rawBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest) => Promise<Buffer>;
932
+ streamBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest) => stream$1.Stream;
933
+ urlencodedBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest) => Promise<any>;
934
+ multipartBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest, options?: formidable.Options) => Promise<any>;
935
+ readConfig: (jsonfile: string) => Promise<any>;
936
+ readConfigSync: (jsonfile: string) => any;
937
+ staticBody: typeof staticBody;
938
+ extensions: string[];
939
+ getExt: (path: string) => string;
940
+ jwtDecode: (jwt: string) => {
941
+ head: any;
942
+ body: any;
943
+ };
945
944
  };
946
945
 
947
946
  export { ApiError, ApiErrorMessage, AsyncJwt, ContextWeb, Controller, Jwt, Memcached, Model, OptionsSsr, OptionsWeb, Route, Schema, Server, Handler as ServerHandler, Options as ServerOptions, Routes as ServerRoutes, WebSocket as ServerWebsocket, Ssr, Web, action, body, codeToStatus, config, connection, context, controller, cookies, db, headers, helpers, home, hostname, http, init, json, logerror, method, mixin, mountWithContext as mount, pool, protocol, request, stream, subaction, url, xml };