-
Notifications
You must be signed in to change notification settings - Fork 121
/
index.d.ts
754 lines (687 loc) · 23.6 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
declare module "moleculer-web" {
import { IncomingMessage, ServerResponse } from "http";
import type {
ActionEndpoint,
ActionSchema,
CallingOptions,
Context,
LogLevels,
Service,
ServiceBroker,
ServiceSchema,
} from "moleculer";
import { Errors } from "moleculer";
import { IParseOptions } from 'qs';
import type { Server as NetServer } from 'net';
import type { Server as TLSServer } from 'tls';
import type { Server as HttpServer } from 'http';
import type { Server as HttpsServer } from 'https';
import type { Http2SecureServer, Http2Server } from 'http2';
// RateLimit
export type generateRateLimitKey = (req: IncomingMessage) => string;
export interface RateLimitSettings {
/**
* How long to keep record of requests in memory (in milliseconds).
* @default 60000 (1 min)
*/
window?: number;
/**
* Max number of requests during window.
* @default 30
*/
limit?: number;
/**
* Set rate limit headers to response.
* @default false
*/
headers?: boolean;
/**
* Function used to generate keys.
* @default req => req.headers["x-forwarded-for"] || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket.remoteAddress
*/
key?: generateRateLimitKey;
/**
* use rate limit Custom Store
* @default MemoryStore
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Custom-Store-example
*/
StoreFactory?: typeof RateLimitStore;
}
export abstract class RateLimitStore {
resetTime: number;
constructor(clearPeriod: number, opts?: RateLimitSettings, broker?: ServiceBroker);
inc(key: string): number | Promise<number>;
}
interface RateLimitStores {
MemoryStore: typeof MemoryStore;
}
class MemoryStore extends RateLimitStore {
constructor(clearPeriod: number, opts?: RateLimitSettings, broker?: ServiceBroker);
/**
* Increment the counter by key
*/
inc(key: string): number;
/**
* Reset all counters
*/
reset(): void;
}
// bodyParserOptions
/**
* DefinitelyTyped body-parser
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/body-parser/index.d.ts#L24
*/
namespace BodyParser {
interface Options {
/** When set to true, then deflated (compressed) bodies will be inflated; when false, deflated bodies are rejected. Defaults to true. */
inflate?: boolean | undefined;
/**
* Controls the maximum request body size. If this is a number,
* then the value specifies the number of bytes; if it is a string,
* the value is passed to the bytes library for parsing. Defaults to '100kb'.
*/
limit?: number | string | undefined;
/**
* The type option is used to determine what media type the middleware will parse
*/
type?: string | string[] | ((req: IncomingMessage) => any) | undefined;
/**
* The verify option, if supplied, is called as verify(req, res, buf, encoding),
* where buf is a Buffer of the raw request body and encoding is the encoding of the request.
*/
verify?(req: IncomingMessage, res: ServerResponse, buf: Buffer, encoding: string): void;
}
interface OptionsJson extends Options {
/**
*
* The reviver option is passed directly to JSON.parse as the second argument.
*/
reviver?(key: string, value: any): any;
/**
* When set to `true`, will only accept arrays and objects;
* when `false` will accept anything JSON.parse accepts. Defaults to `true`.
*/
strict?: boolean | undefined;
}
interface OptionsText extends Options {
/**
* Specify the default character set for the text content if the charset
* is not specified in the Content-Type header of the request.
* Defaults to `utf-8`.
*/
defaultCharset?: string | undefined;
}
interface OptionsUrlencoded extends Options {
/**
* The extended option allows to choose between parsing the URL-encoded data
* with the querystring library (when `false`) or the qs library (when `true`).
*/
extended?: boolean | undefined;
/**
* The parameterLimit option controls the maximum number of parameters
* that are allowed in the URL-encoded data. If a request contains more parameters than this value,
* a 413 will be returned to the client. Defaults to 1000.
*/
parameterLimit?: number | undefined;
}
}
type bodyParserOptions = {
json?: BodyParser.OptionsJson | boolean;
urlencoded?: BodyParser.OptionsUrlencoded | boolean;
text?: BodyParser.OptionsText | boolean;
raw?: BodyParser.Options | boolean;
};
// BusboyConfig
namespace busboy {
interface BusboyConfig {
headers?: any;
highWaterMark?: number | undefined;
fileHwm?: number | undefined;
defCharset?: string | undefined;
preservePath?: boolean | undefined;
limits?:
| {
fieldNameSize?: number | undefined;
fieldSize?: number | undefined;
fields?: number | undefined;
fileSize?: number | undefined;
files?: number | undefined;
parts?: number | undefined;
headerPairs?: number | undefined;
}
| undefined;
}
interface Busboy extends NodeJS.WritableStream {
on(
event: "field",
listener: (
fieldname: string,
val: any,
fieldnameTruncated: boolean,
valTruncated: boolean,
encoding: string,
mimetype: string,
) => void,
): this;
on(
event: "file",
listener: (
fieldname: string,
file: NodeJS.ReadableStream,
filename: string,
encoding: string,
mimetype: string,
) => void,
): this;
on(event: "finish", callback: () => void): this;
on(event: "partsLimit", callback: () => void): this;
on(event: "filesLimit", callback: () => void): this;
on(event: "fieldsLimit", callback: () => void): this;
on(event: string, listener: Function): this;
}
}
type onEventBusboyConfig<T> = (busboy: busboy.Busboy, alias: T, service: Service) => void;
type BusboyConfig<T> = busboy.BusboyConfig & {
onFieldsLimit?: T;
onFilesLimit?: T;
onPartsLimit?: T;
};
// AssetsConfig
// From: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/serve-static/index.d.ts
interface ServeStaticOptions {
/**
* Enable or disable setting Cache-Control response header, defaults to true.
* Disabling this will ignore the immutable and maxAge options.
*/
cacheControl?: boolean | undefined;
/**
* Set how "dotfiles" are treated when encountered. A dotfile is a file or directory that begins with a dot (".").
* Note this check is done on the path itself without checking if the path actually exists on the disk.
* If root is specified, only the dotfiles above the root are checked (i.e. the root itself can be within a dotfile when when set to "deny").
* The default value is 'ignore'.
* 'allow' No special treatment for dotfiles
* 'deny' Send a 403 for any request for a dotfile
* 'ignore' Pretend like the dotfile does not exist and call next()
*/
dotfiles?: string | undefined;
/**
* Enable or disable etag generation, defaults to true.
*/
etag?: boolean | undefined;
/**
* Set file extension fallbacks. When set, if a file is not found, the given extensions will be added to the file name and search for.
* The first that exists will be served. Example: ['html', 'htm'].
* The default value is false.
*/
extensions?: string[] | false | undefined;
/**
* Let client errors fall-through as unhandled requests, otherwise forward a client error.
* The default value is true.
*/
fallthrough?: boolean | undefined;
/**
* Enable or disable the immutable directive in the Cache-Control response header.
* If enabled, the maxAge option should also be specified to enable caching. The immutable directive will prevent supported clients from making conditional requests during the life of the maxAge option to check if the file has changed.
*/
immutable?: boolean | undefined;
/**
* By default this module will send "index.html" files in response to a request on a directory.
* To disable this set false or to supply a new index pass a string or an array in preferred order.
*/
index?: boolean | string | string[] | undefined;
/**
* Enable or disable Last-Modified header, defaults to true. Uses the file system's last modified value.
*/
lastModified?: boolean | undefined;
/**
* Provide a max-age in milliseconds for http caching, defaults to 0. This can also be a string accepted by the ms module.
*/
maxAge?: number | string | undefined;
/**
* Redirect to trailing "/" when the pathname is a dir. Defaults to true.
*/
redirect?: boolean | undefined;
/**
* Function to set custom headers on response. Alterations to the headers need to occur synchronously.
* The function is called as fn(res, path, stat), where the arguments are:
* res the response object
* path the file path that is being sent
* stat the stat object of the file that is being sent
*/
setHeaders?: ((res: ServerResponse, path: string, stat: any) => any) | undefined;
}
type AssetsConfig = {
/**
* Root folder of assets
*/
folder: string;
/**
* Further options to `server-static` module
*/
options?: ServeStaticOptions;
};
// CorsOptions
// From: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/cors/index.d.ts
type CustomOrigin = (origin: string) => boolean;
export interface CorsOptions {
origin?: boolean | string | RegExp | (string | RegExp)[] | CustomOrigin;
methods?: string | string[];
allowedHeaders?: string | string[];
exposedHeaders?: string | string[];
credentials?: boolean;
maxAge?: number;
preflightContinue?: boolean;
optionsSuccessStatus?: number;
}
class InvalidRequestBodyError extends Errors.MoleculerError {
constructor(body: any, error: any);
}
class InvalidResponseTypeError extends Errors.MoleculerError {
constructor(dataType: string);
}
class UnAuthorizedError extends Errors.MoleculerError {
constructor(type: string | null | undefined, data: any);
}
class ForbiddenError extends Errors.MoleculerError {
constructor(type: string, data: any);
}
class BadRequestError extends Errors.MoleculerError {
constructor(type: string, data: any);
}
class RateLimitExceeded extends Errors.MoleculerClientError {
constructor(type: string, data: any);
}
class NotFoundError extends Errors.MoleculerClientError {
constructor(type: string, data: any);
}
class ServiceUnavailableError extends Errors.MoleculerError {
constructor(type: string, data: any);
}
interface ApiGatewayErrors {
InvalidRequestBodyError: typeof InvalidRequestBodyError;
InvalidResponseTypeError: typeof InvalidResponseTypeError;
UnAuthorizedError: typeof UnAuthorizedError;
ForbiddenError: typeof ForbiddenError;
BadRequestError: typeof BadRequestError;
RateLimitExceeded: typeof RateLimitExceeded;
NotFoundError: typeof NotFoundError;
ServiceUnavailableError: typeof ServiceUnavailableError;
ERR_NO_TOKEN: "ERR_NO_TOKEN";
ERR_INVALID_TOKEN: "ERR_INVALID_TOKEN";
ERR_UNABLE_DECODE_PARAM: "ERR_UNABLE_DECODE_PARAM";
ERR_ORIGIN_NOT_FOUND: "ORIGIN_NOT_FOUND";
}
export class Alias {
_generated: boolean;
service: Service;
route: Route;
type: string;
method: string;
path: string;
handler: null | Function[];
action: string;
}
export class Route {
callOptions: any;
cors: CorsOptions;
etag: boolean | "weak" | "strong" | Function;
hasWhitelist: boolean;
logging: boolean;
mappingPolicy: string;
middlewares: Function[];
onBeforeCall?: onBeforeCall;
onAfterCall?: onAfterCall;
opts: any;
path: string;
whitelist: string[];
}
type onBeforeCall = (
ctx: Context,
route: Route,
req: IncomingRequest,
res: GatewayResponse,
) => void;
type onAfterCall = (
ctx: Context,
route: Route,
req: IncomingRequest,
res: GatewayResponse,
data: any,
) => any;
/**
* Expressjs next function<br>
* /@types/express-serve-static-core/index.d.ts:36
* @see https://www.npmjs.com/package/@types/express-serve-static-core
*/
interface NextFunction {
(err?: any): void;
/**
* "Break-out" of a router by calling {next('router')};
* @see https://expressjs.com/en/guide/using-middleware.html#middleware.router
*/
(deferToNext: "router"): void;
/**
* "Break-out" of a route by calling {next('route')};
* @see https://expressjs.com/en/guide/using-middleware.html#middleware.application
*/
(deferToNext: "route"): void;
}
type routeMiddleware = (req: IncomingRequest, res: GatewayResponse, next: NextFunction) => void;
type routeMiddlewareError = (
err: any,
req: IncomingRequest,
res: GatewayResponse,
next: NextFunction,
) => void;
type ETagFunction = (body: any) => string;
type AliasFunction = (
req: IncomingRequest,
res: GatewayResponse,
next?: (err?: any) => void,
) => void;
type AliasRouteSchema = {
type?: "call" | "multipart" | "stream" | string;
method?: "GET" | "POST" | "PUT" | "DELETE" | "*" | "HEAD" | "OPTIONS" | "PATCH" | string;
path?: string;
handler?: AliasFunction;
action?: string;
busboyConfig?: BusboyConfig<onEventBusboyConfig<Alias>>;
[k: string]: any;
};
type CommonSettingSchema = {
/**
* Cross-origin resource sharing configuration (using module [cors](https://www.npmjs.com/package/cors))<br>
* @example {
// Configures the Access-Control-Allow-Origin CORS header.
origin: "*", // ["http://localhost:3000", "https://localhost:4000"],
// Configures the Access-Control-Allow-Methods CORS header.
methods: ["GET", "OPTIONS", "POST", "PUT", "DELETE"],
// Configures the Access-Control-Allow-Headers CORS header.
allowedHeaders: [],
// Configures the Access-Control-Expose-Headers CORS header.
exposedHeaders: [],
// Configures the Access-Control-Allow-Credentials CORS header.
credentials: false,
// Configures the Access-Control-Max-Age CORS header.
maxAge: 3600
}
* @see https://moleculer.services/docs/0.14/moleculer-web.html#CORS-headers
*/
cors?: CorsOptions;
/**
* The etag option value can be `false`, `true`, `weak`, `strong`, or a custom `Function`
* @default settings.etag (null)
* @see https://moleculer.services/docs/0.14/moleculer-web.html#ETag
*/
etag?: boolean | "weak" | "strong" | ETagFunction;
/**
* You can add route-level & global-level custom error handlers.<br>
* In handlers, you must call the `res.end`. Otherwise, the request is unhandled.
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Error-handlers
*/
onError?: (req: IncomingRequest, res: ServerResponse, error: Error) => void;
/**
* The Moleculer-Web has a built-in rate limiter with a memory store.
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Rate-limiter
*/
rateLimit?: RateLimitSettings;
/**
* It supports Connect-like middlewares in global-level, route-level & alias-level.<br>
* Signature: function (req, res, next) {...}.<br>
* Signature: function (err, req, res, next) {...}.<br>
* For more info check [express middleware](https://expressjs.com/en/guide/using-middleware.html)
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Middlewares
*/
use?: (routeMiddleware | routeMiddlewareError)[];
};
export interface ApiRouteSchema extends CommonSettingSchema {
/**
* You can use alias names instead of action names. You can also specify the method. Otherwise it will handle every method types.<br>
* Using named parameters in aliases is possible. Named parameters are defined by prefixing a colon to the parameter name (:name).
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Aliases
*/
aliases?: {
[k: string]: string | AliasFunction | (AliasFunction | string)[] | AliasRouteSchema;
};
/**
* To enable the support for authentication, you need to do something similar to what is describe in the Authorization paragraph.<br>
* Also in this case you have to:
* 1. Set `authentication: true` in your routes
* 2. Define your custom authenticate method in your service
* 3. The returned value will be set to the `ctx.meta.user` property. You can use it in your actions to get the logged in user entity.
* <br>`From v0.10.3`: You can define custom `authentication` and `authorization` methods for every routes.
* In this case you should set `the method name` instead of `true` value.
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Authentication
*/
authentication?: boolean | string;
/**
* You can implement authorization. Do 2 things to enable it.
* 1. Set authorization: true in your routes.
* 2. Define the authorize method in service.
* <br>`From v0.10.3`: You can define custom `authentication` and `authorization` methods for every routes.
* In this case you should set `the method name` instead of `true` value.
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Authorization
*/
authorization?: boolean | string;
/**
* The auto-alias feature allows you to declare your route alias directly in your services.<br>
* The gateway will dynamically build the full routes from service schema.
* Gateway will regenerate the routes every time a service joins or leaves the network.<br>
* Use `whitelist` parameter to specify services that the Gateway should track and build the routes.
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Auto-alias
*/
autoAliases?: boolean;
/**
* Parse incoming request bodies, available under the `ctx.params` property
* @see https://www.npmjs.com/package/body-parser
*/
bodyParsers?: bodyParserOptions | boolean;
/**
* API Gateway has implemented file uploads.<br>
* You can upload files as a multipart form data (thanks to [busboy](https://github.com/mscdex/busboy) library) or as a raw request body.<br>
* In both cases, the file is transferred to an action as a Stream.<br>
* In multipart form data mode you can upload multiple files, as well.<br>
* `Please note`: you have to disable other body parsers in order to accept files.
*/
busboyConfig?: BusboyConfig<onEventBusboyConfig<Alias>>;
/**
* The route has a callOptions property which is passed to broker.call. So you can set timeout, retries or fallbackResponse options for routes.
* @see https://moleculer.services/docs/0.14/actions.html#Call-services
*/
callOptions?: CallingOptions;
/**
* If alias handler not found, `api` will try to call service by action name<br>
* This option will convert request url to camelCase before call action
* @example `/math/sum-all` => `math.sumAll`
* @default: null
*/
camelCaseNames?: boolean;
/**
* Debounce wait time before call to regenerated aliases when got event "$services.changed"
* @default 500
*/
debounceTime?: number;
/**
* Enable/disable logging
* @default true
*/
logging?: boolean;
/**
* The route has a `mappingPolicy` property to handle routes without aliases.<br>
* Available options:<br>
* `all` - enable to request all routes with or without aliases (default)<br>
* `restrict` - enable to request only the routes with aliases.
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Mapping-policy
*/
mappingPolicy?: "all" | "restrict";
/**
* To disable parameter merging set `mergeParams: false` in route settings.<br>
* Default is `true`
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Disable-merging
*/
mergeParams?: boolean;
/**
* `From v0.10.2`
* <br>Support multiple routes with the same path.
* <br>You should give a unique name for the routes if they have same path.
* @see https://github.com/moleculerjs/moleculer-web/releases/tag/v0.10.2
*/
name?: string;
/**
* The route has before & after call hooks. You can use it to set `ctx.meta`, access `req.headers` or modify the response data.
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Route-hooks
*/
onBeforeCall?: onBeforeCall;
/**
* You could manipulate the data in `onAfterCall`.<br>
* `Must always return the new or original data`.
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Route-hooks
*/
onAfterCall?: onAfterCall;
/**
* Path prefix to this route
*/
path: string;
/**
* If you don’t want to publish all actions, you can filter them with whitelist option.<br>
* Use match strings or regexp in list. To enable all actions, use "**" item.<br>
* "posts.*": `Access any actions in 'posts' service`<br>
* "users.list": `Access call only the 'users.list' action`<br>
* /^math\.\w+$/: `Access any actions in 'math' service`<br>
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Whitelist
*/
whitelist?: (string | RegExp)[];
}
type APISettingServer =
| boolean
| HttpServer
| HttpsServer
| Http2Server
| Http2SecureServer
| NetServer
| TLSServer;
export interface ApiSettingsSchema extends CommonSettingSchema {
/**
* It serves assets with the [serve-static](https://github.com/expressjs/serve-static) module like ExpressJS.
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Serve-static-files
*/
assets?: AssetsConfig;
/**
* Use HTTP2 server (experimental)
* @default false
*/
http2?: boolean;
/**
* HTTP Server Timeout
* @default null
*/
httpServerTimeout?: number;
/**
* Special char for internal services<br>
* Note: `RegExp` type is not official
* @default "~"
* @example "~" => /~node/~action => /$node/~action
* @example /[0-9]+/g => /01234demo/hello2021 => /demo/hello `(not official)`
*/
internalServiceSpecialChar?: string | RegExp;
/**
* Exposed IP
* @default process.env.IP || "0.0.0.0"
*/
ip?: string;
/**
* If set to true, it will log 4xx client errors, as well
* @default false
*/
log4XXResponses?: boolean;
/**
* Log each request (default to "info" level)
* @default "info"
*/
logRequest?: LogLevels | null;
/**
* Log the request ctx.params (default to "debug" level)
* @default "debug"
*/
logRequestParams?: LogLevels | null;
/**
* Log each response (default to "info" level)
* @default "info"
*/
logResponse?: LogLevels | null;
/**
* Log the response data (default to disable)
* @default null
*/
logResponseData?: LogLevels | null;
/**
* Log the route registration/aliases related activity
* @default "info"
*/
logRouteRegistration?: LogLevels | null;
/**
* Optimize route order
* @default true
*/
optimizeOrder?: boolean;
/**
* Global path prefix
*/
path?: string;
/**
* Exposed port
* @default process.env.PORT || 3000
*/
port?: number;
/**
* Gateway routes
* @default []
*/
routes?: ApiRouteSchema[];
/**
* CallOption for the root action `api.rest`
* @default null
*/
rootCallOptions?: CallingOptions;
/**
* Used server instance. If null, it will create a new HTTP(s)(2) server<br>
* If false, it will start without server in middleware mode
* @default true
*/
server?: APISettingServer;
/**
* Options passed on to qs
* @see https://moleculer.services/docs/0.14/moleculer-web.html#Query-string-parameters
*/
qsOptions?: IParseOptions;
/**
* for extra setting's keys
*/
[k: string]: any;
}
export class IncomingRequest extends IncomingMessage {
$action: ActionSchema;
$alias: Alias;
$ctx: Context<{ req: IncomingMessage; res: ServerResponse; }>;
$endpoint: ActionEndpoint;
$next: any;
$params: any;
$route: Route;
$service: Service;
$startTime: number[];
originalUrl: string;
parsedUrl: string;
query: Record<string, string>;
}
export class GatewayResponse extends ServerResponse {
$ctx: Context;
$route: Route;
$service: Service;
locals: Record<string, unknown>;
}
const ApiGatewayService: ServiceSchema & {
Errors: ApiGatewayErrors;
RateLimitStores: RateLimitStores;
};
export default ApiGatewayService;
}