@extk/expressive 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +166 -18
- package/dist/index.d.ts +166 -18
- package/dist/index.js +39 -18
- package/dist/index.mjs +39 -18
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -34,9 +34,61 @@ type Container = {
|
|
|
34
34
|
alertHandler?: AlertHandler;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
type
|
|
37
|
+
type NumericConfigs = {
|
|
38
|
+
minimum?: number;
|
|
39
|
+
maximum?: number;
|
|
40
|
+
exclusiveMinimum?: boolean;
|
|
41
|
+
exclusiveMaximum?: boolean;
|
|
42
|
+
multipleOf?: number;
|
|
43
|
+
};
|
|
44
|
+
type NumberType = {
|
|
45
|
+
type: 'number';
|
|
46
|
+
format?: 'float' | 'double';
|
|
47
|
+
} & NumericConfigs;
|
|
48
|
+
type IntegerType = {
|
|
49
|
+
type: 'integer';
|
|
50
|
+
format?: 'int32' | 'int64';
|
|
51
|
+
} & NumericConfigs;
|
|
52
|
+
type StringType = {
|
|
53
|
+
type: 'string';
|
|
54
|
+
minLength?: number;
|
|
55
|
+
maxLength?: number;
|
|
56
|
+
format?: 'date' | 'date-time' | 'password' | 'byte' | 'binary' | 'email' | 'uuid' | 'uri' | 'hostname' | 'ipv4' | 'ipv6';
|
|
57
|
+
pattern?: string;
|
|
58
|
+
};
|
|
59
|
+
type BooleanType = {
|
|
60
|
+
type: 'boolean';
|
|
61
|
+
};
|
|
62
|
+
type ArrayType = {
|
|
63
|
+
type: 'array';
|
|
64
|
+
items: Partial<Schema>;
|
|
65
|
+
minItems?: number;
|
|
66
|
+
maxItems?: number;
|
|
67
|
+
uniqueItems?: boolean;
|
|
68
|
+
};
|
|
69
|
+
type ObjectType = {
|
|
70
|
+
type: 'object';
|
|
71
|
+
properties?: Record<string, Schema>;
|
|
72
|
+
required?: string[];
|
|
73
|
+
additionalProperties?: boolean | Schema;
|
|
74
|
+
minProperties?: number;
|
|
75
|
+
maxProperties?: number;
|
|
76
|
+
};
|
|
77
|
+
type BaseSchema = ({
|
|
78
|
+
nullable?: boolean;
|
|
79
|
+
enum?: unknown[];
|
|
80
|
+
description?: string;
|
|
81
|
+
default?: unknown;
|
|
82
|
+
} & (StringType | NumberType | IntegerType | BooleanType | ArrayType | ObjectType)) | {
|
|
38
83
|
$ref: string;
|
|
39
84
|
};
|
|
85
|
+
type Schema = BaseSchema | {
|
|
86
|
+
allOf: BaseSchema[];
|
|
87
|
+
} | {
|
|
88
|
+
anyOf: BaseSchema[];
|
|
89
|
+
} | {
|
|
90
|
+
oneOf: BaseSchema[];
|
|
91
|
+
};
|
|
40
92
|
type Content = {
|
|
41
93
|
description?: string;
|
|
42
94
|
content?: Partial<Record<ContentType, {
|
|
@@ -217,27 +269,123 @@ declare function bootstrap(container: Container): {
|
|
|
217
269
|
silently: (fn: () => Promise<void>, reqSnapshot?: ReqSnapshot) => void;
|
|
218
270
|
getErrorHandlerMiddleware: (errorMapper?: (err: Error & Record<string, unknown>) => ApiError | null | undefined) => (err: Error & Record<string, unknown>, req: express.Request, res: express.Response, _next: express.NextFunction) => Promise<void>;
|
|
219
271
|
swaggerBuilder: () => {
|
|
220
|
-
withInfo(info: SwaggerConfig["info"])
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
272
|
+
readonly withInfo: (info: SwaggerConfig["info"]) => {
|
|
273
|
+
readonly withInfo: /*elided*/ any;
|
|
274
|
+
readonly withServers: (servers: Servers) => /*elided*/ any;
|
|
275
|
+
readonly withSecuritySchemes: (schemes: Record<string, SecurityScheme>) => /*elided*/ any;
|
|
276
|
+
readonly withSchemas: (schemas: Record<string, Schema>) => /*elided*/ any;
|
|
277
|
+
readonly withDefaultSecurity: (globalAuthMethods: AuthMethod[]) => /*elided*/ any;
|
|
278
|
+
readonly get: () => SwaggerConfig;
|
|
279
|
+
};
|
|
280
|
+
readonly withServers: (servers: Servers) => {
|
|
281
|
+
readonly withInfo: (info: SwaggerConfig["info"]) => /*elided*/ any;
|
|
282
|
+
readonly withServers: /*elided*/ any;
|
|
283
|
+
readonly withSecuritySchemes: (schemes: Record<string, SecurityScheme>) => /*elided*/ any;
|
|
284
|
+
readonly withSchemas: (schemas: Record<string, Schema>) => /*elided*/ any;
|
|
285
|
+
readonly withDefaultSecurity: (globalAuthMethods: AuthMethod[]) => /*elided*/ any;
|
|
286
|
+
readonly get: () => SwaggerConfig;
|
|
287
|
+
};
|
|
288
|
+
readonly withSecuritySchemes: (schemes: Record<string, SecurityScheme>) => {
|
|
289
|
+
readonly withInfo: (info: SwaggerConfig["info"]) => /*elided*/ any;
|
|
290
|
+
readonly withServers: (servers: Servers) => /*elided*/ any;
|
|
291
|
+
readonly withSecuritySchemes: /*elided*/ any;
|
|
292
|
+
readonly withSchemas: (schemas: Record<string, Schema>) => /*elided*/ any;
|
|
293
|
+
readonly withDefaultSecurity: (globalAuthMethods: AuthMethod[]) => /*elided*/ any;
|
|
294
|
+
readonly get: () => SwaggerConfig;
|
|
295
|
+
};
|
|
296
|
+
readonly withSchemas: (schemas: Record<string, Schema>) => {
|
|
297
|
+
readonly withInfo: (info: SwaggerConfig["info"]) => /*elided*/ any;
|
|
298
|
+
readonly withServers: (servers: Servers) => /*elided*/ any;
|
|
299
|
+
readonly withSecuritySchemes: (schemes: Record<string, SecurityScheme>) => /*elided*/ any;
|
|
300
|
+
readonly withSchemas: /*elided*/ any;
|
|
301
|
+
readonly withDefaultSecurity: (globalAuthMethods: AuthMethod[]) => /*elided*/ any;
|
|
302
|
+
readonly get: () => SwaggerConfig;
|
|
303
|
+
};
|
|
304
|
+
readonly withDefaultSecurity: (globalAuthMethods: AuthMethod[]) => {
|
|
305
|
+
readonly withInfo: (info: SwaggerConfig["info"]) => /*elided*/ any;
|
|
306
|
+
readonly withServers: (servers: Servers) => /*elided*/ any;
|
|
307
|
+
readonly withSecuritySchemes: (schemes: Record<string, SecurityScheme>) => /*elided*/ any;
|
|
308
|
+
readonly withSchemas: (schemas: Record<string, Schema>) => /*elided*/ any;
|
|
309
|
+
readonly withDefaultSecurity: /*elided*/ any;
|
|
310
|
+
readonly get: () => SwaggerConfig;
|
|
311
|
+
};
|
|
312
|
+
readonly get: () => SwaggerConfig;
|
|
226
313
|
};
|
|
227
|
-
expressiveServer(configs
|
|
228
|
-
|
|
229
|
-
|
|
314
|
+
expressiveServer(configs?: {
|
|
315
|
+
app?: express.Express;
|
|
316
|
+
}): {
|
|
317
|
+
readonly get: () => express.Express;
|
|
318
|
+
readonly withHelmet: (options?: Readonly<helmet.HelmetOptions>) => {
|
|
319
|
+
readonly get: () => express.Express;
|
|
320
|
+
readonly withHelmet: /*elided*/ any;
|
|
321
|
+
readonly withQs: () => /*elided*/ any;
|
|
322
|
+
readonly withMorgan: (format?: string, options?: Parameters<typeof morgan>[1]) => /*elided*/ any;
|
|
323
|
+
readonly withSwagger: (swagger: {
|
|
324
|
+
path?: ExpressRoute;
|
|
325
|
+
doc: SwaggerConfig;
|
|
326
|
+
}, ...handlers: ExpressHandler[]) => /*elided*/ any;
|
|
327
|
+
readonly defaults: {
|
|
328
|
+
readonly get: (swagger: {
|
|
329
|
+
path?: ExpressRoute;
|
|
330
|
+
doc: SwaggerConfig;
|
|
331
|
+
}) => express.Express;
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
readonly withQs: () => {
|
|
335
|
+
readonly get: () => express.Express;
|
|
336
|
+
readonly withHelmet: (options?: Readonly<helmet.HelmetOptions>) => /*elided*/ any;
|
|
337
|
+
readonly withQs: /*elided*/ any;
|
|
338
|
+
readonly withMorgan: (format?: string, options?: Parameters<typeof morgan>[1]) => /*elided*/ any;
|
|
339
|
+
readonly withSwagger: (swagger: {
|
|
340
|
+
path?: ExpressRoute;
|
|
341
|
+
doc: SwaggerConfig;
|
|
342
|
+
}, ...handlers: ExpressHandler[]) => /*elided*/ any;
|
|
343
|
+
readonly defaults: {
|
|
344
|
+
readonly get: (swagger: {
|
|
345
|
+
path?: ExpressRoute;
|
|
346
|
+
doc: SwaggerConfig;
|
|
347
|
+
}) => express.Express;
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
readonly withMorgan: (format?: string, options?: Parameters<typeof morgan>[1]) => {
|
|
351
|
+
readonly get: () => express.Express;
|
|
352
|
+
readonly withHelmet: (options?: Readonly<helmet.HelmetOptions>) => /*elided*/ any;
|
|
353
|
+
readonly withQs: () => /*elided*/ any;
|
|
354
|
+
readonly withMorgan: /*elided*/ any;
|
|
355
|
+
readonly withSwagger: (swagger: {
|
|
356
|
+
path?: ExpressRoute;
|
|
357
|
+
doc: SwaggerConfig;
|
|
358
|
+
}, ...handlers: ExpressHandler[]) => /*elided*/ any;
|
|
359
|
+
readonly defaults: {
|
|
360
|
+
readonly get: (swagger: {
|
|
361
|
+
path?: ExpressRoute;
|
|
362
|
+
doc: SwaggerConfig;
|
|
363
|
+
}) => express.Express;
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
readonly withSwagger: (swagger: {
|
|
367
|
+
path?: ExpressRoute;
|
|
230
368
|
doc: SwaggerConfig;
|
|
369
|
+
}, ...handlers: ExpressHandler[]) => {
|
|
370
|
+
readonly get: () => express.Express;
|
|
371
|
+
readonly withHelmet: (options?: Readonly<helmet.HelmetOptions>) => /*elided*/ any;
|
|
372
|
+
readonly withQs: () => /*elided*/ any;
|
|
373
|
+
readonly withMorgan: (format?: string, options?: Parameters<typeof morgan>[1]) => /*elided*/ any;
|
|
374
|
+
readonly withSwagger: /*elided*/ any;
|
|
375
|
+
readonly defaults: {
|
|
376
|
+
readonly get: (swagger: {
|
|
377
|
+
path?: ExpressRoute;
|
|
378
|
+
doc: SwaggerConfig;
|
|
379
|
+
}) => express.Express;
|
|
380
|
+
};
|
|
231
381
|
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}>;
|
|
382
|
+
readonly defaults: {
|
|
383
|
+
readonly get: (swagger: {
|
|
384
|
+
path?: ExpressRoute;
|
|
385
|
+
doc: SwaggerConfig;
|
|
386
|
+
}) => express.Express;
|
|
238
387
|
};
|
|
239
|
-
|
|
240
|
-
}): express.Express;
|
|
388
|
+
};
|
|
241
389
|
expressiveRouter(configs: {
|
|
242
390
|
oapi?: {
|
|
243
391
|
tags?: string[];
|
package/dist/index.d.ts
CHANGED
|
@@ -34,9 +34,61 @@ type Container = {
|
|
|
34
34
|
alertHandler?: AlertHandler;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
type
|
|
37
|
+
type NumericConfigs = {
|
|
38
|
+
minimum?: number;
|
|
39
|
+
maximum?: number;
|
|
40
|
+
exclusiveMinimum?: boolean;
|
|
41
|
+
exclusiveMaximum?: boolean;
|
|
42
|
+
multipleOf?: number;
|
|
43
|
+
};
|
|
44
|
+
type NumberType = {
|
|
45
|
+
type: 'number';
|
|
46
|
+
format?: 'float' | 'double';
|
|
47
|
+
} & NumericConfigs;
|
|
48
|
+
type IntegerType = {
|
|
49
|
+
type: 'integer';
|
|
50
|
+
format?: 'int32' | 'int64';
|
|
51
|
+
} & NumericConfigs;
|
|
52
|
+
type StringType = {
|
|
53
|
+
type: 'string';
|
|
54
|
+
minLength?: number;
|
|
55
|
+
maxLength?: number;
|
|
56
|
+
format?: 'date' | 'date-time' | 'password' | 'byte' | 'binary' | 'email' | 'uuid' | 'uri' | 'hostname' | 'ipv4' | 'ipv6';
|
|
57
|
+
pattern?: string;
|
|
58
|
+
};
|
|
59
|
+
type BooleanType = {
|
|
60
|
+
type: 'boolean';
|
|
61
|
+
};
|
|
62
|
+
type ArrayType = {
|
|
63
|
+
type: 'array';
|
|
64
|
+
items: Partial<Schema>;
|
|
65
|
+
minItems?: number;
|
|
66
|
+
maxItems?: number;
|
|
67
|
+
uniqueItems?: boolean;
|
|
68
|
+
};
|
|
69
|
+
type ObjectType = {
|
|
70
|
+
type: 'object';
|
|
71
|
+
properties?: Record<string, Schema>;
|
|
72
|
+
required?: string[];
|
|
73
|
+
additionalProperties?: boolean | Schema;
|
|
74
|
+
minProperties?: number;
|
|
75
|
+
maxProperties?: number;
|
|
76
|
+
};
|
|
77
|
+
type BaseSchema = ({
|
|
78
|
+
nullable?: boolean;
|
|
79
|
+
enum?: unknown[];
|
|
80
|
+
description?: string;
|
|
81
|
+
default?: unknown;
|
|
82
|
+
} & (StringType | NumberType | IntegerType | BooleanType | ArrayType | ObjectType)) | {
|
|
38
83
|
$ref: string;
|
|
39
84
|
};
|
|
85
|
+
type Schema = BaseSchema | {
|
|
86
|
+
allOf: BaseSchema[];
|
|
87
|
+
} | {
|
|
88
|
+
anyOf: BaseSchema[];
|
|
89
|
+
} | {
|
|
90
|
+
oneOf: BaseSchema[];
|
|
91
|
+
};
|
|
40
92
|
type Content = {
|
|
41
93
|
description?: string;
|
|
42
94
|
content?: Partial<Record<ContentType, {
|
|
@@ -217,27 +269,123 @@ declare function bootstrap(container: Container): {
|
|
|
217
269
|
silently: (fn: () => Promise<void>, reqSnapshot?: ReqSnapshot) => void;
|
|
218
270
|
getErrorHandlerMiddleware: (errorMapper?: (err: Error & Record<string, unknown>) => ApiError | null | undefined) => (err: Error & Record<string, unknown>, req: express.Request, res: express.Response, _next: express.NextFunction) => Promise<void>;
|
|
219
271
|
swaggerBuilder: () => {
|
|
220
|
-
withInfo(info: SwaggerConfig["info"])
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
272
|
+
readonly withInfo: (info: SwaggerConfig["info"]) => {
|
|
273
|
+
readonly withInfo: /*elided*/ any;
|
|
274
|
+
readonly withServers: (servers: Servers) => /*elided*/ any;
|
|
275
|
+
readonly withSecuritySchemes: (schemes: Record<string, SecurityScheme>) => /*elided*/ any;
|
|
276
|
+
readonly withSchemas: (schemas: Record<string, Schema>) => /*elided*/ any;
|
|
277
|
+
readonly withDefaultSecurity: (globalAuthMethods: AuthMethod[]) => /*elided*/ any;
|
|
278
|
+
readonly get: () => SwaggerConfig;
|
|
279
|
+
};
|
|
280
|
+
readonly withServers: (servers: Servers) => {
|
|
281
|
+
readonly withInfo: (info: SwaggerConfig["info"]) => /*elided*/ any;
|
|
282
|
+
readonly withServers: /*elided*/ any;
|
|
283
|
+
readonly withSecuritySchemes: (schemes: Record<string, SecurityScheme>) => /*elided*/ any;
|
|
284
|
+
readonly withSchemas: (schemas: Record<string, Schema>) => /*elided*/ any;
|
|
285
|
+
readonly withDefaultSecurity: (globalAuthMethods: AuthMethod[]) => /*elided*/ any;
|
|
286
|
+
readonly get: () => SwaggerConfig;
|
|
287
|
+
};
|
|
288
|
+
readonly withSecuritySchemes: (schemes: Record<string, SecurityScheme>) => {
|
|
289
|
+
readonly withInfo: (info: SwaggerConfig["info"]) => /*elided*/ any;
|
|
290
|
+
readonly withServers: (servers: Servers) => /*elided*/ any;
|
|
291
|
+
readonly withSecuritySchemes: /*elided*/ any;
|
|
292
|
+
readonly withSchemas: (schemas: Record<string, Schema>) => /*elided*/ any;
|
|
293
|
+
readonly withDefaultSecurity: (globalAuthMethods: AuthMethod[]) => /*elided*/ any;
|
|
294
|
+
readonly get: () => SwaggerConfig;
|
|
295
|
+
};
|
|
296
|
+
readonly withSchemas: (schemas: Record<string, Schema>) => {
|
|
297
|
+
readonly withInfo: (info: SwaggerConfig["info"]) => /*elided*/ any;
|
|
298
|
+
readonly withServers: (servers: Servers) => /*elided*/ any;
|
|
299
|
+
readonly withSecuritySchemes: (schemes: Record<string, SecurityScheme>) => /*elided*/ any;
|
|
300
|
+
readonly withSchemas: /*elided*/ any;
|
|
301
|
+
readonly withDefaultSecurity: (globalAuthMethods: AuthMethod[]) => /*elided*/ any;
|
|
302
|
+
readonly get: () => SwaggerConfig;
|
|
303
|
+
};
|
|
304
|
+
readonly withDefaultSecurity: (globalAuthMethods: AuthMethod[]) => {
|
|
305
|
+
readonly withInfo: (info: SwaggerConfig["info"]) => /*elided*/ any;
|
|
306
|
+
readonly withServers: (servers: Servers) => /*elided*/ any;
|
|
307
|
+
readonly withSecuritySchemes: (schemes: Record<string, SecurityScheme>) => /*elided*/ any;
|
|
308
|
+
readonly withSchemas: (schemas: Record<string, Schema>) => /*elided*/ any;
|
|
309
|
+
readonly withDefaultSecurity: /*elided*/ any;
|
|
310
|
+
readonly get: () => SwaggerConfig;
|
|
311
|
+
};
|
|
312
|
+
readonly get: () => SwaggerConfig;
|
|
226
313
|
};
|
|
227
|
-
expressiveServer(configs
|
|
228
|
-
|
|
229
|
-
|
|
314
|
+
expressiveServer(configs?: {
|
|
315
|
+
app?: express.Express;
|
|
316
|
+
}): {
|
|
317
|
+
readonly get: () => express.Express;
|
|
318
|
+
readonly withHelmet: (options?: Readonly<helmet.HelmetOptions>) => {
|
|
319
|
+
readonly get: () => express.Express;
|
|
320
|
+
readonly withHelmet: /*elided*/ any;
|
|
321
|
+
readonly withQs: () => /*elided*/ any;
|
|
322
|
+
readonly withMorgan: (format?: string, options?: Parameters<typeof morgan>[1]) => /*elided*/ any;
|
|
323
|
+
readonly withSwagger: (swagger: {
|
|
324
|
+
path?: ExpressRoute;
|
|
325
|
+
doc: SwaggerConfig;
|
|
326
|
+
}, ...handlers: ExpressHandler[]) => /*elided*/ any;
|
|
327
|
+
readonly defaults: {
|
|
328
|
+
readonly get: (swagger: {
|
|
329
|
+
path?: ExpressRoute;
|
|
330
|
+
doc: SwaggerConfig;
|
|
331
|
+
}) => express.Express;
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
readonly withQs: () => {
|
|
335
|
+
readonly get: () => express.Express;
|
|
336
|
+
readonly withHelmet: (options?: Readonly<helmet.HelmetOptions>) => /*elided*/ any;
|
|
337
|
+
readonly withQs: /*elided*/ any;
|
|
338
|
+
readonly withMorgan: (format?: string, options?: Parameters<typeof morgan>[1]) => /*elided*/ any;
|
|
339
|
+
readonly withSwagger: (swagger: {
|
|
340
|
+
path?: ExpressRoute;
|
|
341
|
+
doc: SwaggerConfig;
|
|
342
|
+
}, ...handlers: ExpressHandler[]) => /*elided*/ any;
|
|
343
|
+
readonly defaults: {
|
|
344
|
+
readonly get: (swagger: {
|
|
345
|
+
path?: ExpressRoute;
|
|
346
|
+
doc: SwaggerConfig;
|
|
347
|
+
}) => express.Express;
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
readonly withMorgan: (format?: string, options?: Parameters<typeof morgan>[1]) => {
|
|
351
|
+
readonly get: () => express.Express;
|
|
352
|
+
readonly withHelmet: (options?: Readonly<helmet.HelmetOptions>) => /*elided*/ any;
|
|
353
|
+
readonly withQs: () => /*elided*/ any;
|
|
354
|
+
readonly withMorgan: /*elided*/ any;
|
|
355
|
+
readonly withSwagger: (swagger: {
|
|
356
|
+
path?: ExpressRoute;
|
|
357
|
+
doc: SwaggerConfig;
|
|
358
|
+
}, ...handlers: ExpressHandler[]) => /*elided*/ any;
|
|
359
|
+
readonly defaults: {
|
|
360
|
+
readonly get: (swagger: {
|
|
361
|
+
path?: ExpressRoute;
|
|
362
|
+
doc: SwaggerConfig;
|
|
363
|
+
}) => express.Express;
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
readonly withSwagger: (swagger: {
|
|
367
|
+
path?: ExpressRoute;
|
|
230
368
|
doc: SwaggerConfig;
|
|
369
|
+
}, ...handlers: ExpressHandler[]) => {
|
|
370
|
+
readonly get: () => express.Express;
|
|
371
|
+
readonly withHelmet: (options?: Readonly<helmet.HelmetOptions>) => /*elided*/ any;
|
|
372
|
+
readonly withQs: () => /*elided*/ any;
|
|
373
|
+
readonly withMorgan: (format?: string, options?: Parameters<typeof morgan>[1]) => /*elided*/ any;
|
|
374
|
+
readonly withSwagger: /*elided*/ any;
|
|
375
|
+
readonly defaults: {
|
|
376
|
+
readonly get: (swagger: {
|
|
377
|
+
path?: ExpressRoute;
|
|
378
|
+
doc: SwaggerConfig;
|
|
379
|
+
}) => express.Express;
|
|
380
|
+
};
|
|
231
381
|
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
}>;
|
|
382
|
+
readonly defaults: {
|
|
383
|
+
readonly get: (swagger: {
|
|
384
|
+
path?: ExpressRoute;
|
|
385
|
+
doc: SwaggerConfig;
|
|
386
|
+
}) => express.Express;
|
|
238
387
|
};
|
|
239
|
-
|
|
240
|
-
}): express.Express;
|
|
388
|
+
};
|
|
241
389
|
expressiveRouter(configs: {
|
|
242
390
|
oapi?: {
|
|
243
391
|
tags?: string[];
|
package/dist/index.js
CHANGED
|
@@ -193,24 +193,45 @@ var SWG = {
|
|
|
193
193
|
function buildExpressive(container, swaggerDoc) {
|
|
194
194
|
return {
|
|
195
195
|
expressiveServer(configs) {
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
196
|
+
const app = configs?.app ?? (0, import_express.default)();
|
|
197
|
+
const result = {
|
|
198
|
+
get() {
|
|
199
|
+
return app;
|
|
200
|
+
},
|
|
201
|
+
withHelmet(options) {
|
|
202
|
+
app.use((0, import_helmet.default)(options ?? {}));
|
|
203
|
+
return this;
|
|
204
|
+
},
|
|
205
|
+
withQs() {
|
|
206
|
+
app.set("query parser", function(str) {
|
|
207
|
+
return import_qs.default.parse(str, { decoder(s) {
|
|
208
|
+
return decodeURIComponent(s);
|
|
209
|
+
} });
|
|
210
|
+
});
|
|
211
|
+
return this;
|
|
212
|
+
},
|
|
213
|
+
withMorgan(format, options) {
|
|
214
|
+
app.use((0, import_morgan.default)(
|
|
215
|
+
format ?? ":req[x-real-ip] :method :url :status :res[content-length] - :response-time ms",
|
|
216
|
+
options ?? { stream: { write(message) {
|
|
217
|
+
container.logger.info(message.trim());
|
|
218
|
+
} } }
|
|
219
|
+
));
|
|
220
|
+
return this;
|
|
221
|
+
},
|
|
222
|
+
withSwagger(swagger, ...handlers) {
|
|
223
|
+
app.use(swagger.path ?? "/api-docs", ...handlers, import_swagger_ui_express.default.serve, import_swagger_ui_express.default.setup(swagger.doc, {
|
|
224
|
+
customSiteTitle: swagger.doc.info?.title
|
|
225
|
+
}));
|
|
226
|
+
return this;
|
|
227
|
+
},
|
|
228
|
+
defaults: {
|
|
229
|
+
get(swagger) {
|
|
230
|
+
return result.withHelmet().withQs().withMorgan().withSwagger(swagger).get();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
return result;
|
|
214
235
|
},
|
|
215
236
|
expressiveRouter(configs) {
|
|
216
237
|
const router = import_express.default.Router();
|
package/dist/index.mjs
CHANGED
|
@@ -128,24 +128,45 @@ var SWG = {
|
|
|
128
128
|
function buildExpressive(container, swaggerDoc) {
|
|
129
129
|
return {
|
|
130
130
|
expressiveServer(configs) {
|
|
131
|
-
const
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
131
|
+
const app = configs?.app ?? express();
|
|
132
|
+
const result = {
|
|
133
|
+
get() {
|
|
134
|
+
return app;
|
|
135
|
+
},
|
|
136
|
+
withHelmet(options) {
|
|
137
|
+
app.use(helmet(options ?? {}));
|
|
138
|
+
return this;
|
|
139
|
+
},
|
|
140
|
+
withQs() {
|
|
141
|
+
app.set("query parser", function(str) {
|
|
142
|
+
return qs.parse(str, { decoder(s) {
|
|
143
|
+
return decodeURIComponent(s);
|
|
144
|
+
} });
|
|
145
|
+
});
|
|
146
|
+
return this;
|
|
147
|
+
},
|
|
148
|
+
withMorgan(format, options) {
|
|
149
|
+
app.use(morgan(
|
|
150
|
+
format ?? ":req[x-real-ip] :method :url :status :res[content-length] - :response-time ms",
|
|
151
|
+
options ?? { stream: { write(message) {
|
|
152
|
+
container.logger.info(message.trim());
|
|
153
|
+
} } }
|
|
154
|
+
));
|
|
155
|
+
return this;
|
|
156
|
+
},
|
|
157
|
+
withSwagger(swagger, ...handlers) {
|
|
158
|
+
app.use(swagger.path ?? "/api-docs", ...handlers, swaggerUi.serve, swaggerUi.setup(swagger.doc, {
|
|
159
|
+
customSiteTitle: swagger.doc.info?.title
|
|
160
|
+
}));
|
|
161
|
+
return this;
|
|
162
|
+
},
|
|
163
|
+
defaults: {
|
|
164
|
+
get(swagger) {
|
|
165
|
+
return result.withHelmet().withQs().withMorgan().withSwagger(swagger).get();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
return result;
|
|
149
170
|
},
|
|
150
171
|
expressiveRouter(configs) {
|
|
151
172
|
const router = express.Router();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@extk/expressive",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"lint": "eslint ./"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@extk/eslint-config": "^0.2.
|
|
28
|
+
"@extk/eslint-config": "^0.2.1",
|
|
29
29
|
"@extk/tsconfig": "0.1.1",
|
|
30
30
|
"@types/chance": "^1.1.7",
|
|
31
31
|
"@types/express": "^5.0.1",
|