@jwn-js/common 1.2.2 → 1.3.4
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/ApiError.d.ts +1 -1
- package/docs/assets/js/search.js +1 -1
- package/docs/classes/ApiError.html +11 -38
- package/docs/classes/Controller.html +951 -0
- package/docs/classes/Jwt.html +7 -34
- package/docs/classes/Memcached.html +7 -34
- package/docs/classes/Model.html +514 -0
- package/docs/classes/Server.html +7 -34
- package/docs/classes/Ssr.html +310 -0
- package/docs/classes/Web.html +440 -0
- package/docs/index.html +103 -4
- package/docs/interfaces/ApiErrorMessage.html +7 -34
- package/docs/interfaces/ContextSsr.html +327 -0
- package/docs/interfaces/ContextWeb.html +283 -0
- package/docs/interfaces/OptionsSsr.html +184 -0
- package/docs/interfaces/OptionsWeb.html +198 -0
- package/docs/interfaces/ServerHandler.html +7 -34
- package/docs/interfaces/ServerOptions.html +7 -34
- package/docs/interfaces/ServerWebsocket.html +7 -34
- package/docs/modules.html +1341 -10
- package/index.d.ts +617 -3
- package/index.js +838 -15
- package/package.json +12 -10
package/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import * as formidable from 'formidable';
|
|
2
|
-
import * as stream from 'stream';
|
|
2
|
+
import * as stream$1 from 'stream';
|
|
3
|
+
import { Stream } from 'stream';
|
|
3
4
|
import * as uWebSockets_js from 'uWebSockets.js';
|
|
4
5
|
import { HttpResponse, HttpRequest } from 'uWebSockets.js';
|
|
5
6
|
export { ApiError, ApiErrorMessage } from './ApiError';
|
|
6
7
|
export { Server, Handler as ServerHandler, Options as ServerOptions, Routes as ServerRoutes, WebSocket as ServerWebsocket, codeToStatus } from './Server';
|
|
7
8
|
export { Jwt } from './Jwt';
|
|
8
9
|
import { Client } from 'memjs';
|
|
10
|
+
import { Query } from 'buildmsql';
|
|
11
|
+
export { Context as ContextSsr } from 'vite-ssr-vue';
|
|
9
12
|
|
|
10
13
|
declare class Memcached {
|
|
11
14
|
memjs: Client;
|
|
@@ -55,12 +58,623 @@ declare class Memcached {
|
|
|
55
58
|
*/
|
|
56
59
|
declare function staticBody(res: HttpResponse, req: HttpRequest, base: string): Promise<void>;
|
|
57
60
|
|
|
61
|
+
interface OptionsSsr {
|
|
62
|
+
readonly manifest: Record<string, any>;
|
|
63
|
+
readonly memcached: Memcached;
|
|
64
|
+
readonly [key: string]: any;
|
|
65
|
+
}
|
|
66
|
+
declare type EntryFunction = (url: string, opt: Record<string, any>) => Promise<any>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Ssr handler for production
|
|
70
|
+
*/
|
|
71
|
+
declare class Ssr {
|
|
72
|
+
res: HttpResponse;
|
|
73
|
+
req: HttpRequest;
|
|
74
|
+
context: OptionsSsr;
|
|
75
|
+
entry: EntryFunction | any;
|
|
76
|
+
/**
|
|
77
|
+
* @constructor
|
|
78
|
+
* @param res response
|
|
79
|
+
* @param req request
|
|
80
|
+
* @param context params
|
|
81
|
+
* @param entry - entry point function
|
|
82
|
+
*/
|
|
83
|
+
constructor(res: HttpResponse, req: HttpRequest, context: OptionsSsr, entry: EntryFunction | any);
|
|
84
|
+
/**
|
|
85
|
+
* @param request addition request params
|
|
86
|
+
*/
|
|
87
|
+
request(request?: Record<string, any>): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Input params of error
|
|
92
|
+
*/
|
|
93
|
+
interface ApiErrorMessage {
|
|
94
|
+
message?: string;
|
|
95
|
+
code?: number;
|
|
96
|
+
statusCode?: number;
|
|
97
|
+
data?: Record<string, unknown>;
|
|
98
|
+
headers?: Record<string, string>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @class Api Error
|
|
102
|
+
* @description Base error class for @jwn-js
|
|
103
|
+
*/
|
|
104
|
+
declare class ApiError extends Error {
|
|
105
|
+
statusCode: number;
|
|
106
|
+
code: number;
|
|
107
|
+
data: Record<string, unknown>;
|
|
108
|
+
headers: Record<string, string>;
|
|
109
|
+
/**
|
|
110
|
+
* @constructor
|
|
111
|
+
* @param message
|
|
112
|
+
* @param code
|
|
113
|
+
* @param statusCode
|
|
114
|
+
*/
|
|
115
|
+
constructor(message?: string, code?: number, statusCode?: number);
|
|
116
|
+
constructor(params: ApiErrorMessage | string, code?: number, statusCode?: number);
|
|
117
|
+
/**
|
|
118
|
+
* Get error message
|
|
119
|
+
*/
|
|
120
|
+
getMessage(): string;
|
|
121
|
+
/**
|
|
122
|
+
* Get internal status code
|
|
123
|
+
*/
|
|
124
|
+
getStatusCode(): number;
|
|
125
|
+
/**
|
|
126
|
+
* Get internal error code
|
|
127
|
+
*/
|
|
128
|
+
getCode(): number;
|
|
129
|
+
/**
|
|
130
|
+
* Get error data
|
|
131
|
+
*/
|
|
132
|
+
getData(): Record<string, unknown>;
|
|
133
|
+
/**
|
|
134
|
+
* Get error headers
|
|
135
|
+
*/
|
|
136
|
+
getHeaders(): Record<string, string>;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
declare type method$2 = 'any' | 'connect' | 'del' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
|
|
140
|
+
declare module "uWebSockets.js" {
|
|
141
|
+
interface HttpRequest {
|
|
142
|
+
cookies: Record<string, any>;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
interface Route$1 {
|
|
146
|
+
name: string;
|
|
147
|
+
method?: method$2 | Array<method$2>;
|
|
148
|
+
component: any;
|
|
149
|
+
}
|
|
150
|
+
interface OptionsWeb {
|
|
151
|
+
readonly routes: Array<Route$1>;
|
|
152
|
+
readonly config: Config$1;
|
|
153
|
+
readonly db: Record<string, Query>;
|
|
154
|
+
readonly [key: string]: any;
|
|
155
|
+
}
|
|
156
|
+
interface Response$1 {
|
|
157
|
+
statusCode: number;
|
|
158
|
+
headers: Record<string, any>;
|
|
159
|
+
body: any;
|
|
160
|
+
}
|
|
161
|
+
interface Config$1 {
|
|
162
|
+
server: Record<string, any>;
|
|
163
|
+
db: Record<string, any>;
|
|
164
|
+
[key: string]: any;
|
|
165
|
+
}
|
|
166
|
+
interface ContextWeb {
|
|
167
|
+
readonly config: Config$1;
|
|
168
|
+
readonly db: Record<string, Query>;
|
|
169
|
+
controller: {
|
|
170
|
+
id: number;
|
|
171
|
+
name: string;
|
|
172
|
+
isActive: boolean;
|
|
173
|
+
isSitemap: boolean;
|
|
174
|
+
};
|
|
175
|
+
subaction: {
|
|
176
|
+
id: number;
|
|
177
|
+
name: string;
|
|
178
|
+
isPermission: boolean;
|
|
179
|
+
isCheckMethod: boolean;
|
|
180
|
+
isLog: boolean;
|
|
181
|
+
isActive: boolean;
|
|
182
|
+
};
|
|
183
|
+
action: {
|
|
184
|
+
id: number;
|
|
185
|
+
name: string;
|
|
186
|
+
isActive: boolean;
|
|
187
|
+
method: method$2;
|
|
188
|
+
};
|
|
189
|
+
[key: string]: any;
|
|
190
|
+
}
|
|
191
|
+
interface ContextWebController extends ContextWeb {
|
|
192
|
+
method: string;
|
|
193
|
+
cookies: Record<string, any>;
|
|
194
|
+
hostname: string;
|
|
195
|
+
protocol: string;
|
|
196
|
+
url: string;
|
|
197
|
+
headers: Record<string, any>;
|
|
198
|
+
getRequest: () => Record<string, any>;
|
|
199
|
+
db: Record<string, Query>;
|
|
200
|
+
$stream?: Stream;
|
|
201
|
+
$body?: any;
|
|
202
|
+
$route?: Route$1;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Entry point for /web api
|
|
206
|
+
* handler for api request
|
|
207
|
+
*/
|
|
208
|
+
declare class Web {
|
|
209
|
+
res: HttpResponse;
|
|
210
|
+
req: HttpRequest;
|
|
211
|
+
context: OptionsWeb;
|
|
212
|
+
defaultRequest: {
|
|
213
|
+
controller: string;
|
|
214
|
+
subaction: string;
|
|
215
|
+
lang: string;
|
|
216
|
+
};
|
|
217
|
+
defaultResponse: {
|
|
218
|
+
statusCode: number;
|
|
219
|
+
headers: {
|
|
220
|
+
"content-type": string;
|
|
221
|
+
};
|
|
222
|
+
body: {};
|
|
223
|
+
};
|
|
224
|
+
route: Route$1;
|
|
225
|
+
contextWeb: ContextWeb;
|
|
226
|
+
/**
|
|
227
|
+
* @constructor
|
|
228
|
+
* @param res response
|
|
229
|
+
* @param req request
|
|
230
|
+
* @param context params
|
|
231
|
+
*/
|
|
232
|
+
constructor(res: HttpResponse, req: HttpRequest, context: OptionsWeb);
|
|
233
|
+
request(request?: Record<string, any>): Promise<void>;
|
|
234
|
+
/**
|
|
235
|
+
* Import controller class
|
|
236
|
+
* @param request params
|
|
237
|
+
* @private
|
|
238
|
+
*/
|
|
239
|
+
private importController;
|
|
240
|
+
/**
|
|
241
|
+
* Find route in api routers
|
|
242
|
+
* @private
|
|
243
|
+
*/
|
|
244
|
+
private findRoute;
|
|
245
|
+
/**
|
|
246
|
+
* Inject app context
|
|
247
|
+
* @param obj
|
|
248
|
+
* @private
|
|
249
|
+
*/
|
|
250
|
+
private injectContext;
|
|
251
|
+
/**
|
|
252
|
+
* Initing component if init method exists
|
|
253
|
+
* @param obj
|
|
254
|
+
* @returns
|
|
255
|
+
* @private
|
|
256
|
+
*/
|
|
257
|
+
private initComponent;
|
|
258
|
+
/**
|
|
259
|
+
* Success response
|
|
260
|
+
*/
|
|
261
|
+
success(response: Response$1): void;
|
|
262
|
+
/**
|
|
263
|
+
* Error response
|
|
264
|
+
*/
|
|
265
|
+
error(e: ApiError | Error): void;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
declare type method$1 = 'any' | 'connect' | 'del' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
|
|
269
|
+
declare module "uWebSockets.js" {
|
|
270
|
+
interface HttpRequest {
|
|
271
|
+
cookies: Record<string, any>;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
interface Route {
|
|
275
|
+
name: string;
|
|
276
|
+
method?: method$1 | Array<method$1>;
|
|
277
|
+
component: any;
|
|
278
|
+
}
|
|
279
|
+
interface Config {
|
|
280
|
+
server: Record<string, any>;
|
|
281
|
+
db: Record<string, any>;
|
|
282
|
+
[key: string]: any;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
interface TestContext {
|
|
286
|
+
readonly config?: Config;
|
|
287
|
+
readonly db?: Record<string, Query>;
|
|
288
|
+
controller?: {
|
|
289
|
+
id: number;
|
|
290
|
+
name: string;
|
|
291
|
+
isActive: boolean;
|
|
292
|
+
isSitemap: boolean;
|
|
293
|
+
};
|
|
294
|
+
subaction?: {
|
|
295
|
+
id: number;
|
|
296
|
+
name: string;
|
|
297
|
+
isPermission: boolean;
|
|
298
|
+
isCheckMethod: boolean;
|
|
299
|
+
isLog: boolean;
|
|
300
|
+
isActive: boolean;
|
|
301
|
+
};
|
|
302
|
+
action?: {
|
|
303
|
+
id: number;
|
|
304
|
+
name: string;
|
|
305
|
+
isActive: boolean;
|
|
306
|
+
method: method$1;
|
|
307
|
+
};
|
|
308
|
+
method?: method$1;
|
|
309
|
+
cookies?: Record<string, any>;
|
|
310
|
+
hostname?: string;
|
|
311
|
+
protocol?: string;
|
|
312
|
+
url?: string;
|
|
313
|
+
headers?: Record<string, any>;
|
|
314
|
+
getRequest?: () => Record<string, any>;
|
|
315
|
+
$stream?: Stream;
|
|
316
|
+
$body?: any;
|
|
317
|
+
$route?: Route;
|
|
318
|
+
[key: string]: any;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Create class with inject context
|
|
322
|
+
*/
|
|
323
|
+
declare const mountWithContext: <T>($class: new () => T, $context: TestContext, request?: Record<string, any>) => Promise<T>;
|
|
324
|
+
|
|
325
|
+
interface Context$1 extends ContextWeb {
|
|
326
|
+
method: string;
|
|
327
|
+
getRequest: () => Record<string, any>;
|
|
328
|
+
db: Record<string, any>;
|
|
329
|
+
headers: Record<string, any>;
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Base model
|
|
333
|
+
*/
|
|
334
|
+
declare class Model$1 {
|
|
335
|
+
protected $context: Context$1;
|
|
336
|
+
/**
|
|
337
|
+
* Create model
|
|
338
|
+
* @param model
|
|
339
|
+
* @param args
|
|
340
|
+
*/
|
|
341
|
+
protected $create<T extends Model$1 | Record<string, any>, A extends Array<any>>(model: {
|
|
342
|
+
new (...args: [...A]): T;
|
|
343
|
+
}, ...args: [...A]): Promise<T>;
|
|
344
|
+
/**
|
|
345
|
+
* Inject app context
|
|
346
|
+
* @param context
|
|
347
|
+
*/
|
|
348
|
+
$inject(context: any): void;
|
|
349
|
+
getContext(): Context$1;
|
|
350
|
+
getRequest(): Record<string, any>;
|
|
351
|
+
getConfig(): Config$1;
|
|
352
|
+
getMethod(): string;
|
|
353
|
+
getHeaders(): Record<string, any>;
|
|
354
|
+
getController(): {
|
|
355
|
+
id: number;
|
|
356
|
+
name: string;
|
|
357
|
+
isActive: boolean;
|
|
358
|
+
isSitemap: boolean;
|
|
359
|
+
};
|
|
360
|
+
getAction(): {
|
|
361
|
+
id: number;
|
|
362
|
+
name: string;
|
|
363
|
+
isActive: boolean;
|
|
364
|
+
method: method$2;
|
|
365
|
+
};
|
|
366
|
+
getSubaction(): {
|
|
367
|
+
id: number;
|
|
368
|
+
name: string;
|
|
369
|
+
isPermission: boolean;
|
|
370
|
+
isCheckMethod: boolean;
|
|
371
|
+
isLog: boolean;
|
|
372
|
+
isActive: boolean;
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
interface ResponseOptions {
|
|
377
|
+
memcache?: number | null;
|
|
378
|
+
headers?: Record<string, any>;
|
|
379
|
+
statusCode?: number;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Base Controller
|
|
383
|
+
*/
|
|
384
|
+
declare class Controller {
|
|
385
|
+
$context: ContextWebController;
|
|
386
|
+
/**
|
|
387
|
+
* Set cookies
|
|
388
|
+
* @param name
|
|
389
|
+
* @param value
|
|
390
|
+
* @param options
|
|
391
|
+
*/
|
|
392
|
+
setCookieHeader(name: string, value: any, options?: Record<string, any>): string;
|
|
393
|
+
/**
|
|
394
|
+
* Success request
|
|
395
|
+
* @param data response params
|
|
396
|
+
* @param options
|
|
397
|
+
* @returns
|
|
398
|
+
*/
|
|
399
|
+
success(data?: {}, options?: ResponseOptions | any): {
|
|
400
|
+
headers: any;
|
|
401
|
+
body: {
|
|
402
|
+
isError: boolean;
|
|
403
|
+
data: {};
|
|
404
|
+
};
|
|
405
|
+
memcache: any;
|
|
406
|
+
statusCode: any;
|
|
407
|
+
};
|
|
408
|
+
/**
|
|
409
|
+
* Error response
|
|
410
|
+
* @param err
|
|
411
|
+
*/
|
|
412
|
+
error(err: unknown | Error | ApiError): {
|
|
413
|
+
headers: {
|
|
414
|
+
"content-type": string;
|
|
415
|
+
} & Record<string, string>;
|
|
416
|
+
body: {
|
|
417
|
+
isError: boolean;
|
|
418
|
+
error: string;
|
|
419
|
+
code: number;
|
|
420
|
+
data: Record<string, unknown>;
|
|
421
|
+
stack: string | undefined;
|
|
422
|
+
response: {
|
|
423
|
+
status: any;
|
|
424
|
+
headers: any;
|
|
425
|
+
config: {
|
|
426
|
+
url: any;
|
|
427
|
+
method: any;
|
|
428
|
+
params: any;
|
|
429
|
+
headers: any;
|
|
430
|
+
};
|
|
431
|
+
data: any;
|
|
432
|
+
} | {
|
|
433
|
+
status?: undefined;
|
|
434
|
+
headers?: undefined;
|
|
435
|
+
config?: undefined;
|
|
436
|
+
data?: undefined;
|
|
437
|
+
};
|
|
438
|
+
};
|
|
439
|
+
statusCode: number;
|
|
440
|
+
};
|
|
441
|
+
/**
|
|
442
|
+
* Xml response
|
|
443
|
+
* @param data response params
|
|
444
|
+
* @param options addition options
|
|
445
|
+
*/
|
|
446
|
+
successXml(data?: {}, options?: ResponseOptions): {
|
|
447
|
+
headers: Record<string, any>;
|
|
448
|
+
body: string;
|
|
449
|
+
memcache: any;
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Error xml response
|
|
453
|
+
* @param err error object
|
|
454
|
+
*/
|
|
455
|
+
errorXml(err: unknown | Error | ApiError): {
|
|
456
|
+
headers: {
|
|
457
|
+
"content-type": string;
|
|
458
|
+
} & Record<string, string>;
|
|
459
|
+
body: string;
|
|
460
|
+
statusCode: number;
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* Create model
|
|
464
|
+
* @param model
|
|
465
|
+
* @param args
|
|
466
|
+
*/
|
|
467
|
+
$create<T extends Model$1 | Record<string, any>, A extends Array<any>>(model: {
|
|
468
|
+
new (...args: [...A]): T;
|
|
469
|
+
}, ...args: [...A]): Promise<T>;
|
|
470
|
+
/**
|
|
471
|
+
* Inject app context
|
|
472
|
+
* @param context
|
|
473
|
+
*/
|
|
474
|
+
$inject(context: ContextWebController): void;
|
|
475
|
+
getContext(): ContextWebController;
|
|
476
|
+
getRequest(): Record<string, any>;
|
|
477
|
+
getBody(): Buffer;
|
|
478
|
+
getStream(): Stream;
|
|
479
|
+
getConfig(): Config$1;
|
|
480
|
+
getMethod(): string;
|
|
481
|
+
getCookies(): Record<string, any>;
|
|
482
|
+
getHostname(): string;
|
|
483
|
+
getUrl(): string;
|
|
484
|
+
getProtocol(): string;
|
|
485
|
+
getDb(): Record<string, Query>;
|
|
486
|
+
getHeaders(): Record<string, any>;
|
|
487
|
+
getController(): {
|
|
488
|
+
id: number;
|
|
489
|
+
name: string;
|
|
490
|
+
isActive: boolean;
|
|
491
|
+
isSitemap: boolean;
|
|
492
|
+
};
|
|
493
|
+
getAction(): {
|
|
494
|
+
id: number;
|
|
495
|
+
name: string;
|
|
496
|
+
isActive: boolean;
|
|
497
|
+
method: method$2;
|
|
498
|
+
};
|
|
499
|
+
getSubaction(): {
|
|
500
|
+
id: number;
|
|
501
|
+
name: string;
|
|
502
|
+
isPermission: boolean;
|
|
503
|
+
isCheckMethod: boolean;
|
|
504
|
+
isLog: boolean;
|
|
505
|
+
isActive: boolean;
|
|
506
|
+
};
|
|
507
|
+
getHome(): Query;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
interface Context extends ContextWeb {
|
|
511
|
+
method: string;
|
|
512
|
+
getRequest: () => Record<string, any>;
|
|
513
|
+
db: Record<string, any>;
|
|
514
|
+
headers: Record<string, any>;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Base model
|
|
518
|
+
*/
|
|
519
|
+
declare class Model {
|
|
520
|
+
protected $context: Context;
|
|
521
|
+
/**
|
|
522
|
+
* Create model
|
|
523
|
+
* @param model
|
|
524
|
+
* @param args
|
|
525
|
+
*/
|
|
526
|
+
protected $create<T extends Model | Record<string, any>, A extends Array<any>>(model: {
|
|
527
|
+
new (...args: [...A]): T;
|
|
528
|
+
}, ...args: [...A]): Promise<T>;
|
|
529
|
+
/**
|
|
530
|
+
* Inject app context
|
|
531
|
+
* @param context
|
|
532
|
+
*/
|
|
533
|
+
$inject(context: any): void;
|
|
534
|
+
getContext(): Context;
|
|
535
|
+
getRequest(): Record<string, any>;
|
|
536
|
+
getConfig(): Config$1;
|
|
537
|
+
getMethod(): string;
|
|
538
|
+
getHeaders(): Record<string, any>;
|
|
539
|
+
getController(): {
|
|
540
|
+
id: number;
|
|
541
|
+
name: string;
|
|
542
|
+
isActive: boolean;
|
|
543
|
+
isSitemap: boolean;
|
|
544
|
+
};
|
|
545
|
+
getAction(): {
|
|
546
|
+
id: number;
|
|
547
|
+
name: string;
|
|
548
|
+
isActive: boolean;
|
|
549
|
+
method: method$2;
|
|
550
|
+
};
|
|
551
|
+
getSubaction(): {
|
|
552
|
+
id: number;
|
|
553
|
+
name: string;
|
|
554
|
+
isPermission: boolean;
|
|
555
|
+
isCheckMethod: boolean;
|
|
556
|
+
isLog: boolean;
|
|
557
|
+
isActive: boolean;
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Response interface
|
|
563
|
+
*/
|
|
564
|
+
interface Response {
|
|
565
|
+
memcache?: number | null;
|
|
566
|
+
headers?: Record<string, any>;
|
|
567
|
+
statusCode?: number;
|
|
568
|
+
}
|
|
569
|
+
declare type CallbackFunctionAny = (...args: any[]) => any;
|
|
570
|
+
/**
|
|
571
|
+
* Mixin helper for decorators
|
|
572
|
+
* @param behaviour
|
|
573
|
+
* @param sharedBehaviour
|
|
574
|
+
* http://raganwald.com/2015/06/26/decorators-in-es7.html
|
|
575
|
+
* http://raganwald.com/2015/06/17/functional-mixins.html
|
|
576
|
+
* https://habr.com/ru/post/277021/
|
|
577
|
+
*/
|
|
578
|
+
declare function mixin<T extends Record<string, any>>(behaviour: T, sharedBehaviour?: {}): (clazz: any) => any;
|
|
579
|
+
/**
|
|
580
|
+
* @request() decorator
|
|
581
|
+
*/
|
|
582
|
+
declare function request(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
583
|
+
/**
|
|
584
|
+
* @context() decorator
|
|
585
|
+
*/
|
|
586
|
+
declare function context(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
587
|
+
/**
|
|
588
|
+
* @config() decorator
|
|
589
|
+
*/
|
|
590
|
+
declare function config(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
591
|
+
/**
|
|
592
|
+
* @method() decorator
|
|
593
|
+
*/
|
|
594
|
+
declare function method(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
595
|
+
/**
|
|
596
|
+
* @cookies() decorator
|
|
597
|
+
*/
|
|
598
|
+
declare function cookies(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
599
|
+
/**
|
|
600
|
+
* @hostname() decorator
|
|
601
|
+
*/
|
|
602
|
+
declare function hostname(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
603
|
+
/**
|
|
604
|
+
* @url() decorator
|
|
605
|
+
*/
|
|
606
|
+
declare function url(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
607
|
+
/**
|
|
608
|
+
* @protocol() decorator
|
|
609
|
+
*/
|
|
610
|
+
declare function protocol(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
611
|
+
/**
|
|
612
|
+
* @db() decorator
|
|
613
|
+
*/
|
|
614
|
+
declare function db(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
615
|
+
/**
|
|
616
|
+
* @headers() decorator
|
|
617
|
+
*/
|
|
618
|
+
declare function headers(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
619
|
+
/**
|
|
620
|
+
* @controller() decorator
|
|
621
|
+
*/
|
|
622
|
+
declare function controller(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
623
|
+
/**
|
|
624
|
+
* @action() decorator
|
|
625
|
+
*/
|
|
626
|
+
declare function action(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
627
|
+
/**
|
|
628
|
+
* @subaction() decorator
|
|
629
|
+
*/
|
|
630
|
+
declare function subaction(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
631
|
+
/**
|
|
632
|
+
* @body() decorator
|
|
633
|
+
*/
|
|
634
|
+
declare function body(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
635
|
+
/**
|
|
636
|
+
* @stream() decorator
|
|
637
|
+
*/
|
|
638
|
+
declare function stream(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
639
|
+
/**
|
|
640
|
+
* @home() decorator
|
|
641
|
+
*/
|
|
642
|
+
declare function home(): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
643
|
+
/**
|
|
644
|
+
* @connection() decorator
|
|
645
|
+
*/
|
|
646
|
+
declare function connection(name?: string): (target: any, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
647
|
+
/**
|
|
648
|
+
* Json response
|
|
649
|
+
* @param opt response options
|
|
650
|
+
*/
|
|
651
|
+
declare function json(opt?: Response): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
|
|
652
|
+
/**
|
|
653
|
+
* Xml response
|
|
654
|
+
* @param opt response options
|
|
655
|
+
*/
|
|
656
|
+
declare function xml(opt?: Response): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
|
|
657
|
+
/**
|
|
658
|
+
* Logger
|
|
659
|
+
* @param name logger name
|
|
660
|
+
*/
|
|
661
|
+
declare function logerror(name: string): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
|
|
662
|
+
/**
|
|
663
|
+
* Subaction method decorator
|
|
664
|
+
* @http() decorator
|
|
665
|
+
*/
|
|
666
|
+
declare function http(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
|
|
667
|
+
/**
|
|
668
|
+
* @init decorator
|
|
669
|
+
*/
|
|
670
|
+
declare function init(): (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<CallbackFunctionAny>) => void;
|
|
671
|
+
|
|
58
672
|
declare const helpers: {
|
|
59
673
|
cookieParse: (str: string) => Record<string, any>;
|
|
60
674
|
cookieString: (name: string, value: any, options?: Record<string, any>) => string;
|
|
61
675
|
jsonBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest) => Promise<any>;
|
|
62
676
|
rawBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest) => Promise<Buffer>;
|
|
63
|
-
streamBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest) => stream.Stream;
|
|
677
|
+
streamBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest) => stream$1.Stream;
|
|
64
678
|
urlencodedBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest) => Promise<any>;
|
|
65
679
|
multipartBody: (res: uWebSockets_js.HttpResponse, req: uWebSockets_js.HttpRequest, options?: formidable.Options) => Promise<any>;
|
|
66
680
|
readConfig: (jsonfile: string) => Promise<any>;
|
|
@@ -70,4 +684,4 @@ declare const helpers: {
|
|
|
70
684
|
getExt: (path: string) => string;
|
|
71
685
|
};
|
|
72
686
|
|
|
73
|
-
export { Memcached, helpers };
|
|
687
|
+
export { ContextWeb, Controller, Memcached, Model, OptionsSsr, OptionsWeb, Ssr, Web, action, body, config, connection, context, controller, cookies, db, headers, helpers, home, hostname, http, init, json, logerror, method, mixin, mountWithContext as mount, protocol, request, stream, subaction, url, xml };
|