expresso-macchiato 0.3.0
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/README.md +3 -0
- package/dist/index.d.mts +603 -0
- package/dist/index.d.ts +603 -0
- package/dist/index.js +825 -0
- package/dist/index.mjs +825 -0
- package/expressojs-0.3.0.tgz +0 -0
- package/package.json +63 -0
- package/types/db.sptypes.ts +18 -0
- package/types/generic.sptypes.ts +35 -0
- package/types/router.sptypes.ts +39 -0
- package/types/starter.sptypes.ts +36 -0
- package/types/swagger.sptypes.ts +375 -0
- package/types/token.sptypes.ts +20 -0
package/README.md
ADDED
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
import { Request, Response as Response$1, RequestHandler, Router, Express } from 'express';
|
|
2
|
+
import { BaseEntity, MixedList, EntitySchema } from 'typeorm';
|
|
3
|
+
import http from 'http';
|
|
4
|
+
import { Logger } from 'utils-logger-av';
|
|
5
|
+
|
|
6
|
+
type ErrorsMapping = Record<string, {
|
|
7
|
+
status?: number;
|
|
8
|
+
responseMessage?: string;
|
|
9
|
+
}>;
|
|
10
|
+
type Methods = "GET" | "DELETE" | "PUT" | "POST";
|
|
11
|
+
type ExpressReturn = {
|
|
12
|
+
isOk: boolean;
|
|
13
|
+
result: any;
|
|
14
|
+
status: number;
|
|
15
|
+
contentType?: string;
|
|
16
|
+
};
|
|
17
|
+
type SwaggerMetadataInterface = {
|
|
18
|
+
required?: boolean;
|
|
19
|
+
hide?: boolean;
|
|
20
|
+
};
|
|
21
|
+
type ProjectConfigs = {
|
|
22
|
+
SERVER_PORT: number;
|
|
23
|
+
DB_DIALECT?: string;
|
|
24
|
+
DB_NAME?: string;
|
|
25
|
+
DB_HOST?: string;
|
|
26
|
+
DB_PORT?: number;
|
|
27
|
+
DB_USER?: string;
|
|
28
|
+
DB_PASSWORD?: string;
|
|
29
|
+
API_URL?: string;
|
|
30
|
+
ERROR_FILE_PATH?: string;
|
|
31
|
+
};
|
|
32
|
+
type SearchQuery = Record<string, string | number | boolean | undefined | null>;
|
|
33
|
+
type ListOptions = {
|
|
34
|
+
pageSize?: number;
|
|
35
|
+
page?: number;
|
|
36
|
+
orderBy?: string;
|
|
37
|
+
order?: 'ASC' | 'DESC';
|
|
38
|
+
} & SearchQuery;
|
|
39
|
+
|
|
40
|
+
interface Info {
|
|
41
|
+
title: string;
|
|
42
|
+
version: string;
|
|
43
|
+
description?: string | undefined;
|
|
44
|
+
termsOfService?: string | undefined;
|
|
45
|
+
contact?: Contact | undefined;
|
|
46
|
+
license?: License | undefined;
|
|
47
|
+
}
|
|
48
|
+
interface Contact {
|
|
49
|
+
name?: string | undefined;
|
|
50
|
+
email?: string | undefined;
|
|
51
|
+
url?: string | undefined;
|
|
52
|
+
}
|
|
53
|
+
interface License {
|
|
54
|
+
name: string;
|
|
55
|
+
url?: string | undefined;
|
|
56
|
+
}
|
|
57
|
+
interface ExternalDocs {
|
|
58
|
+
url: string;
|
|
59
|
+
description?: string | undefined;
|
|
60
|
+
}
|
|
61
|
+
interface Tag {
|
|
62
|
+
name: string;
|
|
63
|
+
description?: string | undefined;
|
|
64
|
+
externalDocs?: ExternalDocs | undefined;
|
|
65
|
+
}
|
|
66
|
+
interface Header extends BaseSchema {
|
|
67
|
+
type: ParameterType;
|
|
68
|
+
}
|
|
69
|
+
type ParameterType = "string" | "number" | "integer" | "boolean" | "array" | "object" | "file" | "date";
|
|
70
|
+
type BaseParameter = {
|
|
71
|
+
name: string;
|
|
72
|
+
in: "body" | "query" | "path" | "header" | "formData";
|
|
73
|
+
required?: boolean | undefined;
|
|
74
|
+
description?: string | undefined;
|
|
75
|
+
};
|
|
76
|
+
type BodyParameter = BaseParameter & {
|
|
77
|
+
in: "body";
|
|
78
|
+
schema?: Schema | undefined;
|
|
79
|
+
};
|
|
80
|
+
type GenericFormat = {
|
|
81
|
+
type?: ParameterType | undefined;
|
|
82
|
+
format?: string | undefined;
|
|
83
|
+
};
|
|
84
|
+
type IntegerFormat = {
|
|
85
|
+
type: "integer";
|
|
86
|
+
format?: "int32" | "int64" | undefined;
|
|
87
|
+
};
|
|
88
|
+
type NumberFormat = {
|
|
89
|
+
type: "number";
|
|
90
|
+
format?: "float" | "double" | undefined;
|
|
91
|
+
};
|
|
92
|
+
type StringFormat = {
|
|
93
|
+
type: "string";
|
|
94
|
+
format?: "" | "byte" | "binary" | "date" | "date-time" | "password" | undefined;
|
|
95
|
+
};
|
|
96
|
+
type SchemaFormatConstraints = GenericFormat | IntegerFormat | NumberFormat | StringFormat;
|
|
97
|
+
type BaseFormatContrainedParameter = BaseParameter & SchemaFormatConstraints;
|
|
98
|
+
type ParameterCollectionFormat = "csv" | "ssv" | "tsv" | "pipes" | "multi";
|
|
99
|
+
type QueryParameter = BaseFormatContrainedParameter & BaseSchema & {
|
|
100
|
+
in: "query";
|
|
101
|
+
allowEmptyValue?: boolean | undefined;
|
|
102
|
+
collectionFormat?: ParameterCollectionFormat | undefined;
|
|
103
|
+
};
|
|
104
|
+
type PathParameter = BaseFormatContrainedParameter & BaseSchema & {
|
|
105
|
+
in: "path";
|
|
106
|
+
required: boolean;
|
|
107
|
+
};
|
|
108
|
+
type HeaderParameter = BaseFormatContrainedParameter & BaseSchema & {
|
|
109
|
+
in: "header";
|
|
110
|
+
};
|
|
111
|
+
type FormDataParameter = BaseFormatContrainedParameter & BaseSchema & {
|
|
112
|
+
in: "formData";
|
|
113
|
+
type: ParameterType | "file";
|
|
114
|
+
allowEmptyValue?: boolean | undefined;
|
|
115
|
+
collectionFormat?: ParameterCollectionFormat | undefined;
|
|
116
|
+
};
|
|
117
|
+
type Parameter = {
|
|
118
|
+
like?: boolean;
|
|
119
|
+
} & (BodyParameter | FormDataParameter | QueryParameter | PathParameter | HeaderParameter);
|
|
120
|
+
interface Path {
|
|
121
|
+
$ref?: string | undefined;
|
|
122
|
+
get?: Operation | undefined;
|
|
123
|
+
put?: Operation | undefined;
|
|
124
|
+
post?: Operation | undefined;
|
|
125
|
+
delete?: Operation | undefined;
|
|
126
|
+
options?: Operation | undefined;
|
|
127
|
+
head?: Operation | undefined;
|
|
128
|
+
patch?: Operation | undefined;
|
|
129
|
+
parameters?: Array<Parameter | Reference> | undefined;
|
|
130
|
+
}
|
|
131
|
+
interface DynamicSwaggerPath {
|
|
132
|
+
$ref?: string | undefined;
|
|
133
|
+
get?: DynamicSwaggerOperation | undefined;
|
|
134
|
+
put?: DynamicSwaggerOperationBody | undefined;
|
|
135
|
+
post?: DynamicSwaggerOperationBody | undefined;
|
|
136
|
+
delete?: DynamicSwaggerOperationBody | undefined;
|
|
137
|
+
options?: DynamicSwaggerOperation | undefined;
|
|
138
|
+
head?: DynamicSwaggerOperation | undefined;
|
|
139
|
+
patch?: DynamicSwaggerOperation | undefined;
|
|
140
|
+
parameters?: Array<Parameter | Reference> | undefined;
|
|
141
|
+
}
|
|
142
|
+
interface Components {
|
|
143
|
+
schemas?: {
|
|
144
|
+
[schemaName: string]: SchemaV3;
|
|
145
|
+
};
|
|
146
|
+
parameters?: {
|
|
147
|
+
[parameterName: string]: Parameter;
|
|
148
|
+
};
|
|
149
|
+
securitySchemes?: Record<string, {
|
|
150
|
+
type: 'http';
|
|
151
|
+
scheme: 'bearer';
|
|
152
|
+
bearerFormat?: 'JWT';
|
|
153
|
+
}>;
|
|
154
|
+
}
|
|
155
|
+
interface Operation {
|
|
156
|
+
responses: {
|
|
157
|
+
[responseName: string]: Response | Reference;
|
|
158
|
+
};
|
|
159
|
+
summary?: string | undefined;
|
|
160
|
+
description?: string | undefined;
|
|
161
|
+
externalDocs?: ExternalDocs | undefined;
|
|
162
|
+
operationId?: string | undefined;
|
|
163
|
+
produces?: string[] | undefined;
|
|
164
|
+
consumes?: string[] | undefined;
|
|
165
|
+
parameters?: Array<Parameter | Reference> | undefined;
|
|
166
|
+
schemes?: string[] | undefined;
|
|
167
|
+
deprecated?: boolean | undefined;
|
|
168
|
+
security?: Array<{
|
|
169
|
+
[securityDefinitionName: string]: string[];
|
|
170
|
+
}> | undefined;
|
|
171
|
+
tags?: string[] | undefined;
|
|
172
|
+
requestBody?: RequestBodyOperation;
|
|
173
|
+
}
|
|
174
|
+
interface DynamicSwaggerOperation {
|
|
175
|
+
responses: {
|
|
176
|
+
[responseName: string]: Response | Reference;
|
|
177
|
+
};
|
|
178
|
+
summary?: string | undefined;
|
|
179
|
+
description?: string | undefined;
|
|
180
|
+
operationId?: string | undefined;
|
|
181
|
+
parameters?: Array<Parameter | Reference> | undefined;
|
|
182
|
+
deprecated?: boolean | undefined;
|
|
183
|
+
security?: Array<{
|
|
184
|
+
[securityDefinitionName: string]: string[];
|
|
185
|
+
}> | undefined;
|
|
186
|
+
tags?: string[] | undefined;
|
|
187
|
+
}
|
|
188
|
+
interface DynamicSwaggerOperationBody {
|
|
189
|
+
responses: {
|
|
190
|
+
[responseName: string]: Response | Reference;
|
|
191
|
+
};
|
|
192
|
+
summary?: string | undefined;
|
|
193
|
+
description?: string | undefined;
|
|
194
|
+
operationId?: string | undefined;
|
|
195
|
+
parameters?: Array<Parameter | Reference> | undefined;
|
|
196
|
+
deprecated?: boolean | undefined;
|
|
197
|
+
security?: Array<{
|
|
198
|
+
[securityDefinitionName: string]: string[];
|
|
199
|
+
}> | undefined;
|
|
200
|
+
tags?: string[] | undefined;
|
|
201
|
+
requestBody?: {
|
|
202
|
+
required: boolean;
|
|
203
|
+
description?: string;
|
|
204
|
+
schemaName: string;
|
|
205
|
+
schema?: {
|
|
206
|
+
[key: string]: SchemaV3;
|
|
207
|
+
};
|
|
208
|
+
comType?: 'multipart/form-data' | 'application/json' | undefined;
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
type RequestBodyOperation = {
|
|
212
|
+
description?: string;
|
|
213
|
+
required: boolean;
|
|
214
|
+
content: {
|
|
215
|
+
"application/json": {
|
|
216
|
+
schema: {
|
|
217
|
+
$ref: string;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
} | {
|
|
221
|
+
"multipart/form-data": {
|
|
222
|
+
schema: {
|
|
223
|
+
$ref: string;
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
type DynamicSwaggerRequestBodyOperation = {
|
|
229
|
+
description?: string;
|
|
230
|
+
required: boolean;
|
|
231
|
+
content: {
|
|
232
|
+
"application/json": {
|
|
233
|
+
schema: {
|
|
234
|
+
$ref: string;
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
interface Reference {
|
|
240
|
+
$ref: string;
|
|
241
|
+
}
|
|
242
|
+
interface Response {
|
|
243
|
+
description: string;
|
|
244
|
+
schema?: Schema | undefined;
|
|
245
|
+
headers?: {
|
|
246
|
+
[headerName: string]: Header;
|
|
247
|
+
} | undefined;
|
|
248
|
+
examples?: {
|
|
249
|
+
[exampleName: string]: {};
|
|
250
|
+
} | undefined;
|
|
251
|
+
}
|
|
252
|
+
type BaseSchema = {
|
|
253
|
+
type?: ParameterType | undefined;
|
|
254
|
+
format?: string | undefined;
|
|
255
|
+
title?: string | undefined;
|
|
256
|
+
description?: string | undefined;
|
|
257
|
+
default?: any;
|
|
258
|
+
multipleOf?: number | undefined;
|
|
259
|
+
maximum?: number | undefined;
|
|
260
|
+
exclusiveMaximum?: boolean | undefined;
|
|
261
|
+
minimum?: number | undefined;
|
|
262
|
+
exclusiveMinimum?: boolean | undefined;
|
|
263
|
+
maxLength?: number | undefined;
|
|
264
|
+
minLength?: number | undefined;
|
|
265
|
+
pattern?: string | undefined;
|
|
266
|
+
maxItems?: number | undefined;
|
|
267
|
+
minItems?: number | undefined;
|
|
268
|
+
uniqueItems?: boolean | undefined;
|
|
269
|
+
maxProperties?: number | undefined;
|
|
270
|
+
minProperties?: number | undefined;
|
|
271
|
+
enum?: any[] | undefined;
|
|
272
|
+
items?: Schema | Schema[] | undefined;
|
|
273
|
+
};
|
|
274
|
+
interface Schema extends BaseSchema {
|
|
275
|
+
$ref?: string | undefined;
|
|
276
|
+
allOf?: Schema[] | undefined;
|
|
277
|
+
additionalProperties?: Schema | boolean | undefined;
|
|
278
|
+
properties?: {
|
|
279
|
+
[propertyName: string]: Schema;
|
|
280
|
+
} | undefined;
|
|
281
|
+
discriminator?: string | undefined;
|
|
282
|
+
readOnly?: boolean | undefined;
|
|
283
|
+
xml?: XML | undefined;
|
|
284
|
+
externalDocs?: ExternalDocs | undefined;
|
|
285
|
+
example?: any;
|
|
286
|
+
required?: boolean;
|
|
287
|
+
}
|
|
288
|
+
interface SchemaV3 extends BaseSchema {
|
|
289
|
+
type: "object";
|
|
290
|
+
properties?: {
|
|
291
|
+
[propertyName: string]: Schema;
|
|
292
|
+
} | undefined;
|
|
293
|
+
required?: boolean;
|
|
294
|
+
}
|
|
295
|
+
interface XML {
|
|
296
|
+
name?: string | undefined;
|
|
297
|
+
namespace?: string | undefined;
|
|
298
|
+
prefix?: string | undefined;
|
|
299
|
+
attribute?: boolean | undefined;
|
|
300
|
+
wrapped?: boolean | undefined;
|
|
301
|
+
}
|
|
302
|
+
interface BaseSecurity {
|
|
303
|
+
type: "basic" | "apiKey" | "oauth2";
|
|
304
|
+
description?: string | undefined;
|
|
305
|
+
}
|
|
306
|
+
interface BasicAuthenticationSecurity extends BaseSecurity {
|
|
307
|
+
type: "basic";
|
|
308
|
+
}
|
|
309
|
+
interface ApiKeySecurity extends BaseSecurity {
|
|
310
|
+
type: "apiKey";
|
|
311
|
+
name: string;
|
|
312
|
+
in: "query" | "header";
|
|
313
|
+
}
|
|
314
|
+
interface BaseOAuthSecurity extends BaseSecurity {
|
|
315
|
+
type: "oauth2";
|
|
316
|
+
flow: "accessCode" | "application" | "implicit" | "password";
|
|
317
|
+
scopes?: OAuthScope | undefined;
|
|
318
|
+
}
|
|
319
|
+
interface OAuth2ImplicitSecurity extends BaseOAuthSecurity {
|
|
320
|
+
type: "oauth2";
|
|
321
|
+
flow: "implicit";
|
|
322
|
+
authorizationUrl: string;
|
|
323
|
+
}
|
|
324
|
+
interface OAuth2PasswordSecurity extends BaseOAuthSecurity {
|
|
325
|
+
type: "oauth2";
|
|
326
|
+
flow: "password";
|
|
327
|
+
tokenUrl: string;
|
|
328
|
+
}
|
|
329
|
+
interface OAuth2ApplicationSecurity extends BaseOAuthSecurity {
|
|
330
|
+
type: "oauth2";
|
|
331
|
+
flow: "application";
|
|
332
|
+
tokenUrl: string;
|
|
333
|
+
}
|
|
334
|
+
interface OAuth2AccessCodeSecurity extends BaseOAuthSecurity {
|
|
335
|
+
type: "oauth2";
|
|
336
|
+
flow: "accessCode";
|
|
337
|
+
tokenUrl: string;
|
|
338
|
+
authorizationUrl: string;
|
|
339
|
+
}
|
|
340
|
+
interface OAuthScope {
|
|
341
|
+
[scopeName: string]: string;
|
|
342
|
+
}
|
|
343
|
+
type Security = BasicAuthenticationSecurity | OAuth2AccessCodeSecurity | OAuth2ApplicationSecurity | OAuth2ImplicitSecurity | OAuth2PasswordSecurity | ApiKeySecurity;
|
|
344
|
+
type Server = {
|
|
345
|
+
url: string;
|
|
346
|
+
description?: string;
|
|
347
|
+
};
|
|
348
|
+
interface Spec {
|
|
349
|
+
openapi: "3.0.4";
|
|
350
|
+
info: Info;
|
|
351
|
+
servers: Server[];
|
|
352
|
+
paths: {
|
|
353
|
+
[pathName: string]: Path;
|
|
354
|
+
};
|
|
355
|
+
tags?: Tag[];
|
|
356
|
+
components?: Components;
|
|
357
|
+
externalDocs?: ExternalDocs | undefined;
|
|
358
|
+
host?: string | undefined;
|
|
359
|
+
basePath?: string | undefined;
|
|
360
|
+
schemes?: string[] | undefined;
|
|
361
|
+
consumes?: string[] | undefined;
|
|
362
|
+
produces?: string[] | undefined;
|
|
363
|
+
definitions?: {
|
|
364
|
+
[definitionsName: string]: Schema;
|
|
365
|
+
} | undefined;
|
|
366
|
+
parameters?: {
|
|
367
|
+
[parameterName: string]: BodyParameter | QueryParameter;
|
|
368
|
+
} | undefined;
|
|
369
|
+
responses?: {
|
|
370
|
+
[responseName: string]: Response;
|
|
371
|
+
} | undefined;
|
|
372
|
+
security?: Array<{
|
|
373
|
+
[securityDefinitionName: string]: string[];
|
|
374
|
+
}> | undefined;
|
|
375
|
+
securityDefinitions?: {
|
|
376
|
+
[securityDefinitionName: string]: Security;
|
|
377
|
+
} | undefined;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
type DefaultTokenPayload = {
|
|
381
|
+
id: string;
|
|
382
|
+
[key: string]: any;
|
|
383
|
+
};
|
|
384
|
+
type SecureTokenConfig = boolean | {
|
|
385
|
+
[columnName: string]: {
|
|
386
|
+
tokenKey: string;
|
|
387
|
+
methods: "*" | Array<Methods | "LIST">;
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
type TokenConstructor = {
|
|
391
|
+
SECRET_KEY: string;
|
|
392
|
+
ExpTime: number;
|
|
393
|
+
EncAlgorithm: string;
|
|
394
|
+
KeyLength: number;
|
|
395
|
+
};
|
|
396
|
+
type TokenApiOptions = {
|
|
397
|
+
path?: string;
|
|
398
|
+
callback: (req: Request, res: Response$1) => Promise<void>;
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
interface RouterWrapperInterface<T extends typeof BaseEntity = typeof BaseEntity> {
|
|
402
|
+
basePath: string;
|
|
403
|
+
tag: string;
|
|
404
|
+
swaggerNewSchemas?: {
|
|
405
|
+
[schema: string]: SchemaV3;
|
|
406
|
+
};
|
|
407
|
+
dbRouting?: {
|
|
408
|
+
entity: T;
|
|
409
|
+
primaryKey?: string;
|
|
410
|
+
getParameters?: Array<Parameter>;
|
|
411
|
+
bodyParameters?: SchemaV3;
|
|
412
|
+
avoid?: Array<Methods | 'LIST'>;
|
|
413
|
+
secure?: SecureTokenConfig;
|
|
414
|
+
returningProps?: string[];
|
|
415
|
+
};
|
|
416
|
+
apis?: Record<string, {
|
|
417
|
+
'GET'?: MethodPathHandling;
|
|
418
|
+
'POST'?: MethodPathHandling;
|
|
419
|
+
'PUT'?: MethodPathHandling;
|
|
420
|
+
'DELETE'?: MethodPathHandling;
|
|
421
|
+
}>;
|
|
422
|
+
}
|
|
423
|
+
type MethodPathHandling = {
|
|
424
|
+
swaggerBody?: {
|
|
425
|
+
schema: string;
|
|
426
|
+
required?: boolean;
|
|
427
|
+
description?: string;
|
|
428
|
+
comType?: 'application/json' | 'multipart/form-data';
|
|
429
|
+
};
|
|
430
|
+
swaggerResponses?: Record<string, Reference | Response>;
|
|
431
|
+
swaggerParameters?: Array<Parameter>;
|
|
432
|
+
middlewares?: RequestHandler[];
|
|
433
|
+
handler: (req: Request, res: Response$1) => Promise<ExpressReturn>;
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
declare class RouterWrapper {
|
|
437
|
+
readonly basePath: string;
|
|
438
|
+
private readonly data;
|
|
439
|
+
constructor(data: RouterWrapperInterface);
|
|
440
|
+
createExpressRouter: () => Router;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
declare class Token<Payload extends Record<string, any> = DefaultTokenPayload> {
|
|
444
|
+
private SECRET_KEY;
|
|
445
|
+
private ExpTime;
|
|
446
|
+
private EncAlgorithm;
|
|
447
|
+
private KeyLength;
|
|
448
|
+
private keyStore;
|
|
449
|
+
constructor(tokenPayload: TokenConstructor);
|
|
450
|
+
private getKey;
|
|
451
|
+
authorize: (req: Request) => Promise<Payload>;
|
|
452
|
+
private deriveEncryptionKey;
|
|
453
|
+
generateJWE(payload: Payload): Promise<string>;
|
|
454
|
+
verifyJWE(token: string): Promise<Payload>;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
type StarterOptions = {
|
|
458
|
+
plugins?: Array<any>;
|
|
459
|
+
routers?: Array<RouterWrapper>;
|
|
460
|
+
clientPath?: string;
|
|
461
|
+
swagger?: boolean;
|
|
462
|
+
projectConfig: ProjectConfigs;
|
|
463
|
+
beforeStartListening?: (app: Express, server?: http.Server) => void;
|
|
464
|
+
socket?: boolean;
|
|
465
|
+
tokenOptions?: {
|
|
466
|
+
tokenInstance: Token;
|
|
467
|
+
api?: TokenApiOptions;
|
|
468
|
+
};
|
|
469
|
+
db?: {
|
|
470
|
+
entities: MixedList<Function | string | EntitySchema>;
|
|
471
|
+
migrations?: string[];
|
|
472
|
+
sync?: boolean;
|
|
473
|
+
afterDbConnection?: () => Promise<void>;
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
type SocketWrapperConstructor = {
|
|
477
|
+
name: string;
|
|
478
|
+
beforeConnection?: () => Promise<void>;
|
|
479
|
+
onDisconnect?: (...params: any[]) => Promise<void>;
|
|
480
|
+
listeners?: Record<string, (...params: any[]) => Promise<void>>;
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
declare class Starter {
|
|
484
|
+
constructor(options: StarterOptions);
|
|
485
|
+
private init;
|
|
486
|
+
private initDb;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
declare class Swagger {
|
|
490
|
+
private static fromExpressParamsToSwagger;
|
|
491
|
+
private static readonly restMethodToSwaggerKeyMapping;
|
|
492
|
+
static addServer: (server: {
|
|
493
|
+
url: string;
|
|
494
|
+
}) => number;
|
|
495
|
+
static generateOpenAPIDocument: () => any;
|
|
496
|
+
static apiDocument: Spec;
|
|
497
|
+
/**
|
|
498
|
+
* @Description
|
|
499
|
+
* - ❌ ROUTER-WRAPPER.
|
|
500
|
+
* - 🛠️ ADD-API-PATH
|
|
501
|
+
* - This method is not directly to insert inside the structur of addApiPath but is useful to create Schemas while not using the routerWrapper
|
|
502
|
+
*/
|
|
503
|
+
static addSchema: (schema: string, properties?: {
|
|
504
|
+
[propName: string]: Schema;
|
|
505
|
+
}) => void;
|
|
506
|
+
/**
|
|
507
|
+
* @Description
|
|
508
|
+
* - ❌ ROUTER-WRAPPER.
|
|
509
|
+
* - 🛠️ ADD-API-PATH
|
|
510
|
+
* - This method is thought to reduce the code in the addApiPath method
|
|
511
|
+
* - You can create a schema while declaring it and associating to the path calling this method
|
|
512
|
+
*/
|
|
513
|
+
static getBasicPost: (schema: string, required: boolean, parameters?: Parameter[], properties?: {
|
|
514
|
+
[propName: string]: Schema;
|
|
515
|
+
}, description?: string) => DynamicSwaggerOperationBody;
|
|
516
|
+
/**
|
|
517
|
+
* @Description
|
|
518
|
+
* - ❌ **ROUTER-WRAPPER.**
|
|
519
|
+
* - 🛠️ **ADD-API-PATH**
|
|
520
|
+
* - This method is thought to reduce the code in the addApiPath method
|
|
521
|
+
*/
|
|
522
|
+
static getBasicGet: (parameters?: Array<Parameter>) => DynamicSwaggerOperation;
|
|
523
|
+
/**
|
|
524
|
+
* @Description
|
|
525
|
+
* - ❌ ROUTER-WRAPPER.
|
|
526
|
+
* - This method is useful if you don't want to use the router wrapper but add your swagger schema anyway.
|
|
527
|
+
* - **It is thought to be used inside the library**, iterating through the paths of the router wrapper.
|
|
528
|
+
* - **Devs can't use inside the parameters of a RouterWrapper constructor**
|
|
529
|
+
* - You can create the structure of a specified path and method, with a schema name that should be created elsewhere
|
|
530
|
+
*/
|
|
531
|
+
static addSingleApiPath: (tag: string, basePath: string, _path: string, method: "GET" | "POST" | "PUT" | "DELETE", parameters?: Array<Parameter>, bodyObj?: {
|
|
532
|
+
schema: string;
|
|
533
|
+
required?: boolean;
|
|
534
|
+
description?: string;
|
|
535
|
+
comType?: "application/json" | "multipart/form-data";
|
|
536
|
+
}, responses?: Record<string, Reference | Response>) => void;
|
|
537
|
+
/**
|
|
538
|
+
* @Description
|
|
539
|
+
* - ❌ ROUTER-WRAPPER.
|
|
540
|
+
* - 🛠️ ADD-API-PATH
|
|
541
|
+
* - **This method is useful if you don't want to use the router wrapper but add your swagger schema anyway**.
|
|
542
|
+
* - You can use other other methods of this class to ease the writing
|
|
543
|
+
* - It is thought to create a full section of apis (hypotetically under one single tag) **while you create the schema in the meanwhile**
|
|
544
|
+
*/
|
|
545
|
+
static _addApiPath: (tag: string, basePath: string, options: {
|
|
546
|
+
[key: string]: DynamicSwaggerPath;
|
|
547
|
+
}) => void;
|
|
548
|
+
/**
|
|
549
|
+
* @Description
|
|
550
|
+
* - ✅ ROUTER-WRAPPER
|
|
551
|
+
* - Returns the tipical /:id parameter
|
|
552
|
+
*/
|
|
553
|
+
static getIdParam: (pkLabel?: string) => Parameter;
|
|
554
|
+
/**
|
|
555
|
+
* @Description
|
|
556
|
+
* - ✅ ROUTER-WRAPPER
|
|
557
|
+
* - Returns the tipical list pagination parameters
|
|
558
|
+
*/
|
|
559
|
+
static getPaginationParams: (options?: ListOptions) => Parameter[];
|
|
560
|
+
/**
|
|
561
|
+
* @Description
|
|
562
|
+
* - ✅ ROUTER-WRAPPER
|
|
563
|
+
* - Creates the swagger schema expected by your api
|
|
564
|
+
*/
|
|
565
|
+
static createMultipartSchema: (name?: string, props?: {
|
|
566
|
+
[prop: string]: Schema;
|
|
567
|
+
}) => SchemaV3;
|
|
568
|
+
/**
|
|
569
|
+
* @Description
|
|
570
|
+
* - ✅ ROUTER-WRAPPER
|
|
571
|
+
* - Creates the swagger schema expected by your api
|
|
572
|
+
*/
|
|
573
|
+
static createSchema: (props: {
|
|
574
|
+
[prop: string]: Schema | ParameterType;
|
|
575
|
+
}, required?: boolean) => SchemaV3;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
type DynamicDbRouterOptions<T extends typeof BaseEntity> = {
|
|
579
|
+
router: Router;
|
|
580
|
+
entity: T;
|
|
581
|
+
primaryKey?: string;
|
|
582
|
+
tag: string;
|
|
583
|
+
basePath: string;
|
|
584
|
+
getParameters?: Array<Parameter>;
|
|
585
|
+
bodyParameters?: SchemaV3;
|
|
586
|
+
avoid?: Array<Methods | 'LIST'>;
|
|
587
|
+
secure?: SecureTokenConfig;
|
|
588
|
+
returningProps?: string[];
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
declare class MyLogger extends Logger {
|
|
592
|
+
setFilePath: (filePath?: string) => void;
|
|
593
|
+
fullLogOk: (service: string, message: string) => void;
|
|
594
|
+
fullLogNok: (service: string, error: any, ...args: any[]) => void;
|
|
595
|
+
}
|
|
596
|
+
declare const log: MyLogger;
|
|
597
|
+
declare const fullLogOk: (service: string, message: string) => void;
|
|
598
|
+
declare const fullLogNok: (service: string, error: any, ...args: any[]) => void;
|
|
599
|
+
declare const apiOk: (res: any, status?: number, contentType?: string) => ExpressReturn;
|
|
600
|
+
declare const apiNok: (err: any, status?: number) => ExpressReturn;
|
|
601
|
+
declare const errorCatcher: (res: Response$1, err: unknown, errorsList?: ErrorsMapping, errorString?: string) => void;
|
|
602
|
+
|
|
603
|
+
export { type ApiKeySecurity, type BaseFormatContrainedParameter, type BaseOAuthSecurity, type BaseParameter, type BaseSchema, type BaseSecurity, type BasicAuthenticationSecurity, type BodyParameter, type Components, type Contact, type DefaultTokenPayload, type DynamicDbRouterOptions, type DynamicSwaggerOperation, type DynamicSwaggerOperationBody, type DynamicSwaggerPath, type DynamicSwaggerRequestBodyOperation, type ErrorsMapping, type ExpressReturn, type ExternalDocs, type FormDataParameter, type GenericFormat, type Header, type HeaderParameter, type Info, type IntegerFormat, type License, type ListOptions, type MethodPathHandling, type Methods, type NumberFormat, type OAuth2AccessCodeSecurity, type OAuth2ApplicationSecurity, type OAuth2ImplicitSecurity, type OAuth2PasswordSecurity, type OAuthScope, type Operation, type Parameter, type ParameterCollectionFormat, type ParameterType, type Path, type PathParameter, type ProjectConfigs, type QueryParameter, type Reference, type RequestBodyOperation, type Response, RouterWrapper, type RouterWrapperInterface, type Schema, type SchemaFormatConstraints, type SchemaV3, type SearchQuery, type SecureTokenConfig, type Security, type Server, type SocketWrapperConstructor, type Spec, Starter, type StarterOptions, type StringFormat, Swagger, type SwaggerMetadataInterface, type Tag, Token, type TokenApiOptions, type TokenConstructor, type XML, apiNok, apiOk, errorCatcher, fullLogNok, fullLogOk, log };
|