expresso-macchiato 1.0.0-dev.7 → 1.0.0-dev.9
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 +68 -456
- package/dist/index.d.ts +68 -456
- package/dist/index.js +126 -306
- package/dist/index.mjs +111 -291
- package/package.json +2 -3
- package/types/db.sptypes.ts +6 -4
- package/types/router.sptypes.ts +10 -7
- package/types/swagger.sptypes.ts +0 -375
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Request, Response
|
|
1
|
+
import { Request, Response, Router, RequestHandler, Express } from 'express';
|
|
2
|
+
import { ParamDefinition, ExpressoSwagger, HttpMethod, ExpressoSwaggerDocument, ExpressoSwaggerModel } from 'expresso-swagger';
|
|
2
3
|
import { BaseEntity, MixedList, EntitySchema } from 'typeorm';
|
|
3
|
-
import { Socket, Namespace, Server
|
|
4
|
+
import { Socket, Namespace, Server, ServerOptions } from 'socket.io';
|
|
4
5
|
import http from 'http';
|
|
5
6
|
import * as utils_logger_av from 'utils-logger-av';
|
|
6
7
|
import { Logger } from 'utils-logger-av';
|
|
@@ -16,6 +17,38 @@ declare class BackgroundService {
|
|
|
16
17
|
constructor(data: BackgroundServiceConstructor);
|
|
17
18
|
}
|
|
18
19
|
|
|
20
|
+
type CustomSwaggerParameter = ParamDefinition & {
|
|
21
|
+
in: 'path' | 'query';
|
|
22
|
+
name: string;
|
|
23
|
+
like?: boolean;
|
|
24
|
+
};
|
|
25
|
+
declare class MySwagger extends ExpressoSwagger {
|
|
26
|
+
constructor();
|
|
27
|
+
private fromExpressParamsToSwagger;
|
|
28
|
+
setBaseUrl(url: string): void;
|
|
29
|
+
addSchema(name: string, schema: any): void;
|
|
30
|
+
/**
|
|
31
|
+
* Adds a single API path by accumulating it into the internal list.
|
|
32
|
+
*/
|
|
33
|
+
addSingleApiPath(group: string, basePath: string, _path: string, method: HttpMethod, options: {
|
|
34
|
+
name?: string;
|
|
35
|
+
description?: string;
|
|
36
|
+
parameters?: Array<CustomSwaggerParameter>;
|
|
37
|
+
body?: any;
|
|
38
|
+
responses?: Record<string | number, {
|
|
39
|
+
description: string;
|
|
40
|
+
body?: any;
|
|
41
|
+
}>;
|
|
42
|
+
}): void;
|
|
43
|
+
static getIdParam: (name?: string) => any;
|
|
44
|
+
static getPaginationParams: () => any[];
|
|
45
|
+
/**
|
|
46
|
+
* Instantiates ExpressoSwagger and generates the final document.
|
|
47
|
+
*/
|
|
48
|
+
generateDocument(): ExpressoSwaggerDocument;
|
|
49
|
+
}
|
|
50
|
+
declare const Swagger: MySwagger;
|
|
51
|
+
|
|
19
52
|
type ErrorsMapping = Record<string, {
|
|
20
53
|
status?: number;
|
|
21
54
|
responseMessage?: string;
|
|
@@ -50,346 +83,6 @@ type ListOptions = {
|
|
|
50
83
|
order?: 'ASC' | 'DESC';
|
|
51
84
|
} & SearchQuery;
|
|
52
85
|
|
|
53
|
-
interface Info {
|
|
54
|
-
title: string;
|
|
55
|
-
version: string;
|
|
56
|
-
description?: string | undefined;
|
|
57
|
-
termsOfService?: string | undefined;
|
|
58
|
-
contact?: Contact | undefined;
|
|
59
|
-
license?: License | undefined;
|
|
60
|
-
}
|
|
61
|
-
interface Contact {
|
|
62
|
-
name?: string | undefined;
|
|
63
|
-
email?: string | undefined;
|
|
64
|
-
url?: string | undefined;
|
|
65
|
-
}
|
|
66
|
-
interface License {
|
|
67
|
-
name: string;
|
|
68
|
-
url?: string | undefined;
|
|
69
|
-
}
|
|
70
|
-
interface ExternalDocs {
|
|
71
|
-
url: string;
|
|
72
|
-
description?: string | undefined;
|
|
73
|
-
}
|
|
74
|
-
interface Tag {
|
|
75
|
-
name: string;
|
|
76
|
-
description?: string | undefined;
|
|
77
|
-
externalDocs?: ExternalDocs | undefined;
|
|
78
|
-
}
|
|
79
|
-
interface Header extends BaseSchema {
|
|
80
|
-
type: ParameterType;
|
|
81
|
-
}
|
|
82
|
-
type ParameterType = "string" | "number" | "integer" | "boolean" | "array" | "object" | "file" | "date";
|
|
83
|
-
type BaseParameter = {
|
|
84
|
-
name: string;
|
|
85
|
-
in: "body" | "query" | "path" | "header" | "formData";
|
|
86
|
-
required?: boolean | undefined;
|
|
87
|
-
description?: string | undefined;
|
|
88
|
-
};
|
|
89
|
-
type BodyParameter = BaseParameter & {
|
|
90
|
-
in: "body";
|
|
91
|
-
schema?: Schema | undefined;
|
|
92
|
-
};
|
|
93
|
-
type GenericFormat = {
|
|
94
|
-
type?: ParameterType | undefined;
|
|
95
|
-
format?: string | undefined;
|
|
96
|
-
};
|
|
97
|
-
type IntegerFormat = {
|
|
98
|
-
type: "integer";
|
|
99
|
-
format?: "int32" | "int64" | undefined;
|
|
100
|
-
};
|
|
101
|
-
type NumberFormat = {
|
|
102
|
-
type: "number";
|
|
103
|
-
format?: "float" | "double" | undefined;
|
|
104
|
-
};
|
|
105
|
-
type StringFormat = {
|
|
106
|
-
type: "string";
|
|
107
|
-
format?: "" | "byte" | "binary" | "date" | "date-time" | "password" | undefined;
|
|
108
|
-
};
|
|
109
|
-
type SchemaFormatConstraints = GenericFormat | IntegerFormat | NumberFormat | StringFormat;
|
|
110
|
-
type BaseFormatContrainedParameter = BaseParameter & SchemaFormatConstraints;
|
|
111
|
-
type ParameterCollectionFormat = "csv" | "ssv" | "tsv" | "pipes" | "multi";
|
|
112
|
-
type QueryParameter = BaseFormatContrainedParameter & BaseSchema & {
|
|
113
|
-
in: "query";
|
|
114
|
-
allowEmptyValue?: boolean | undefined;
|
|
115
|
-
collectionFormat?: ParameterCollectionFormat | undefined;
|
|
116
|
-
};
|
|
117
|
-
type PathParameter = BaseFormatContrainedParameter & BaseSchema & {
|
|
118
|
-
in: "path";
|
|
119
|
-
required: boolean;
|
|
120
|
-
};
|
|
121
|
-
type HeaderParameter = BaseFormatContrainedParameter & BaseSchema & {
|
|
122
|
-
in: "header";
|
|
123
|
-
};
|
|
124
|
-
type FormDataParameter = BaseFormatContrainedParameter & BaseSchema & {
|
|
125
|
-
in: "formData";
|
|
126
|
-
type: ParameterType | "file";
|
|
127
|
-
allowEmptyValue?: boolean | undefined;
|
|
128
|
-
collectionFormat?: ParameterCollectionFormat | undefined;
|
|
129
|
-
};
|
|
130
|
-
type Parameter = {
|
|
131
|
-
like?: boolean;
|
|
132
|
-
} & (BodyParameter | FormDataParameter | QueryParameter | PathParameter | HeaderParameter);
|
|
133
|
-
interface Path {
|
|
134
|
-
$ref?: string | undefined;
|
|
135
|
-
get?: Operation | undefined;
|
|
136
|
-
put?: Operation | undefined;
|
|
137
|
-
post?: Operation | undefined;
|
|
138
|
-
delete?: Operation | undefined;
|
|
139
|
-
options?: Operation | undefined;
|
|
140
|
-
head?: Operation | undefined;
|
|
141
|
-
patch?: Operation | undefined;
|
|
142
|
-
parameters?: Array<Parameter | Reference> | undefined;
|
|
143
|
-
}
|
|
144
|
-
interface DynamicSwaggerPath {
|
|
145
|
-
$ref?: string | undefined;
|
|
146
|
-
get?: DynamicSwaggerOperation | undefined;
|
|
147
|
-
put?: DynamicSwaggerOperationBody | undefined;
|
|
148
|
-
post?: DynamicSwaggerOperationBody | undefined;
|
|
149
|
-
delete?: DynamicSwaggerOperationBody | undefined;
|
|
150
|
-
options?: DynamicSwaggerOperation | undefined;
|
|
151
|
-
head?: DynamicSwaggerOperation | undefined;
|
|
152
|
-
patch?: DynamicSwaggerOperation | undefined;
|
|
153
|
-
parameters?: Array<Parameter | Reference> | undefined;
|
|
154
|
-
}
|
|
155
|
-
interface Components {
|
|
156
|
-
schemas?: {
|
|
157
|
-
[schemaName: string]: SchemaV3;
|
|
158
|
-
};
|
|
159
|
-
parameters?: {
|
|
160
|
-
[parameterName: string]: Parameter;
|
|
161
|
-
};
|
|
162
|
-
securitySchemes?: Record<string, {
|
|
163
|
-
type: 'http';
|
|
164
|
-
scheme: 'bearer';
|
|
165
|
-
bearerFormat?: 'JWT';
|
|
166
|
-
}>;
|
|
167
|
-
}
|
|
168
|
-
interface Operation {
|
|
169
|
-
responses: {
|
|
170
|
-
[responseName: string]: Response | Reference;
|
|
171
|
-
};
|
|
172
|
-
summary?: string | undefined;
|
|
173
|
-
description?: string | undefined;
|
|
174
|
-
externalDocs?: ExternalDocs | undefined;
|
|
175
|
-
operationId?: string | undefined;
|
|
176
|
-
produces?: string[] | undefined;
|
|
177
|
-
consumes?: string[] | undefined;
|
|
178
|
-
parameters?: Array<Parameter | Reference> | undefined;
|
|
179
|
-
schemes?: string[] | undefined;
|
|
180
|
-
deprecated?: boolean | undefined;
|
|
181
|
-
security?: Array<{
|
|
182
|
-
[securityDefinitionName: string]: string[];
|
|
183
|
-
}> | undefined;
|
|
184
|
-
tags?: string[] | undefined;
|
|
185
|
-
requestBody?: RequestBodyOperation;
|
|
186
|
-
}
|
|
187
|
-
interface DynamicSwaggerOperation {
|
|
188
|
-
responses: {
|
|
189
|
-
[responseName: string]: Response | Reference;
|
|
190
|
-
};
|
|
191
|
-
summary?: string | undefined;
|
|
192
|
-
description?: string | undefined;
|
|
193
|
-
operationId?: string | undefined;
|
|
194
|
-
parameters?: Array<Parameter | Reference> | undefined;
|
|
195
|
-
deprecated?: boolean | undefined;
|
|
196
|
-
security?: Array<{
|
|
197
|
-
[securityDefinitionName: string]: string[];
|
|
198
|
-
}> | undefined;
|
|
199
|
-
tags?: string[] | undefined;
|
|
200
|
-
}
|
|
201
|
-
interface DynamicSwaggerOperationBody {
|
|
202
|
-
responses: {
|
|
203
|
-
[responseName: string]: Response | Reference;
|
|
204
|
-
};
|
|
205
|
-
summary?: string | undefined;
|
|
206
|
-
description?: string | undefined;
|
|
207
|
-
operationId?: string | undefined;
|
|
208
|
-
parameters?: Array<Parameter | Reference> | undefined;
|
|
209
|
-
deprecated?: boolean | undefined;
|
|
210
|
-
security?: Array<{
|
|
211
|
-
[securityDefinitionName: string]: string[];
|
|
212
|
-
}> | undefined;
|
|
213
|
-
tags?: string[] | undefined;
|
|
214
|
-
requestBody?: {
|
|
215
|
-
required: boolean;
|
|
216
|
-
description?: string;
|
|
217
|
-
schemaName: string;
|
|
218
|
-
schema?: {
|
|
219
|
-
[key: string]: SchemaV3;
|
|
220
|
-
};
|
|
221
|
-
comType?: 'multipart/form-data' | 'application/json' | undefined;
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
type RequestBodyOperation = {
|
|
225
|
-
description?: string;
|
|
226
|
-
required: boolean;
|
|
227
|
-
content: {
|
|
228
|
-
"application/json": {
|
|
229
|
-
schema: {
|
|
230
|
-
$ref: string;
|
|
231
|
-
};
|
|
232
|
-
};
|
|
233
|
-
} | {
|
|
234
|
-
"multipart/form-data": {
|
|
235
|
-
schema: {
|
|
236
|
-
$ref: string;
|
|
237
|
-
};
|
|
238
|
-
};
|
|
239
|
-
};
|
|
240
|
-
};
|
|
241
|
-
type DynamicSwaggerRequestBodyOperation = {
|
|
242
|
-
description?: string;
|
|
243
|
-
required: boolean;
|
|
244
|
-
content: {
|
|
245
|
-
"application/json": {
|
|
246
|
-
schema: {
|
|
247
|
-
$ref: string;
|
|
248
|
-
};
|
|
249
|
-
};
|
|
250
|
-
};
|
|
251
|
-
};
|
|
252
|
-
interface Reference {
|
|
253
|
-
$ref: string;
|
|
254
|
-
}
|
|
255
|
-
interface Response {
|
|
256
|
-
description: string;
|
|
257
|
-
schema?: Schema | undefined;
|
|
258
|
-
headers?: {
|
|
259
|
-
[headerName: string]: Header;
|
|
260
|
-
} | undefined;
|
|
261
|
-
examples?: {
|
|
262
|
-
[exampleName: string]: {};
|
|
263
|
-
} | undefined;
|
|
264
|
-
}
|
|
265
|
-
type BaseSchema = {
|
|
266
|
-
type?: ParameterType | undefined;
|
|
267
|
-
format?: string | undefined;
|
|
268
|
-
title?: string | undefined;
|
|
269
|
-
description?: string | undefined;
|
|
270
|
-
default?: any;
|
|
271
|
-
multipleOf?: number | undefined;
|
|
272
|
-
maximum?: number | undefined;
|
|
273
|
-
exclusiveMaximum?: boolean | undefined;
|
|
274
|
-
minimum?: number | undefined;
|
|
275
|
-
exclusiveMinimum?: boolean | undefined;
|
|
276
|
-
maxLength?: number | undefined;
|
|
277
|
-
minLength?: number | undefined;
|
|
278
|
-
pattern?: string | undefined;
|
|
279
|
-
maxItems?: number | undefined;
|
|
280
|
-
minItems?: number | undefined;
|
|
281
|
-
uniqueItems?: boolean | undefined;
|
|
282
|
-
maxProperties?: number | undefined;
|
|
283
|
-
minProperties?: number | undefined;
|
|
284
|
-
enum?: any[] | undefined;
|
|
285
|
-
items?: Schema | Schema[] | undefined;
|
|
286
|
-
};
|
|
287
|
-
interface Schema extends BaseSchema {
|
|
288
|
-
$ref?: string | undefined;
|
|
289
|
-
allOf?: Schema[] | undefined;
|
|
290
|
-
additionalProperties?: Schema | boolean | undefined;
|
|
291
|
-
properties?: {
|
|
292
|
-
[propertyName: string]: Schema;
|
|
293
|
-
} | undefined;
|
|
294
|
-
discriminator?: string | undefined;
|
|
295
|
-
readOnly?: boolean | undefined;
|
|
296
|
-
xml?: XML | undefined;
|
|
297
|
-
externalDocs?: ExternalDocs | undefined;
|
|
298
|
-
example?: any;
|
|
299
|
-
required?: boolean;
|
|
300
|
-
}
|
|
301
|
-
interface SchemaV3 extends BaseSchema {
|
|
302
|
-
type: "object";
|
|
303
|
-
properties?: {
|
|
304
|
-
[propertyName: string]: Schema;
|
|
305
|
-
} | undefined;
|
|
306
|
-
required?: boolean;
|
|
307
|
-
}
|
|
308
|
-
interface XML {
|
|
309
|
-
name?: string | undefined;
|
|
310
|
-
namespace?: string | undefined;
|
|
311
|
-
prefix?: string | undefined;
|
|
312
|
-
attribute?: boolean | undefined;
|
|
313
|
-
wrapped?: boolean | undefined;
|
|
314
|
-
}
|
|
315
|
-
interface BaseSecurity {
|
|
316
|
-
type: "basic" | "apiKey" | "oauth2";
|
|
317
|
-
description?: string | undefined;
|
|
318
|
-
}
|
|
319
|
-
interface BasicAuthenticationSecurity extends BaseSecurity {
|
|
320
|
-
type: "basic";
|
|
321
|
-
}
|
|
322
|
-
interface ApiKeySecurity extends BaseSecurity {
|
|
323
|
-
type: "apiKey";
|
|
324
|
-
name: string;
|
|
325
|
-
in: "query" | "header";
|
|
326
|
-
}
|
|
327
|
-
interface BaseOAuthSecurity extends BaseSecurity {
|
|
328
|
-
type: "oauth2";
|
|
329
|
-
flow: "accessCode" | "application" | "implicit" | "password";
|
|
330
|
-
scopes?: OAuthScope | undefined;
|
|
331
|
-
}
|
|
332
|
-
interface OAuth2ImplicitSecurity extends BaseOAuthSecurity {
|
|
333
|
-
type: "oauth2";
|
|
334
|
-
flow: "implicit";
|
|
335
|
-
authorizationUrl: string;
|
|
336
|
-
}
|
|
337
|
-
interface OAuth2PasswordSecurity extends BaseOAuthSecurity {
|
|
338
|
-
type: "oauth2";
|
|
339
|
-
flow: "password";
|
|
340
|
-
tokenUrl: string;
|
|
341
|
-
}
|
|
342
|
-
interface OAuth2ApplicationSecurity extends BaseOAuthSecurity {
|
|
343
|
-
type: "oauth2";
|
|
344
|
-
flow: "application";
|
|
345
|
-
tokenUrl: string;
|
|
346
|
-
}
|
|
347
|
-
interface OAuth2AccessCodeSecurity extends BaseOAuthSecurity {
|
|
348
|
-
type: "oauth2";
|
|
349
|
-
flow: "accessCode";
|
|
350
|
-
tokenUrl: string;
|
|
351
|
-
authorizationUrl: string;
|
|
352
|
-
}
|
|
353
|
-
interface OAuthScope {
|
|
354
|
-
[scopeName: string]: string;
|
|
355
|
-
}
|
|
356
|
-
type Security = BasicAuthenticationSecurity | OAuth2AccessCodeSecurity | OAuth2ApplicationSecurity | OAuth2ImplicitSecurity | OAuth2PasswordSecurity | ApiKeySecurity;
|
|
357
|
-
type Server = {
|
|
358
|
-
url: string;
|
|
359
|
-
description?: string;
|
|
360
|
-
};
|
|
361
|
-
interface Spec {
|
|
362
|
-
openapi: "3.0.4";
|
|
363
|
-
info: Info;
|
|
364
|
-
servers: Server[];
|
|
365
|
-
paths: {
|
|
366
|
-
[pathName: string]: Path;
|
|
367
|
-
};
|
|
368
|
-
tags?: Tag[];
|
|
369
|
-
components?: Components;
|
|
370
|
-
externalDocs?: ExternalDocs | undefined;
|
|
371
|
-
host?: string | undefined;
|
|
372
|
-
basePath?: string | undefined;
|
|
373
|
-
schemes?: string[] | undefined;
|
|
374
|
-
consumes?: string[] | undefined;
|
|
375
|
-
produces?: string[] | undefined;
|
|
376
|
-
definitions?: {
|
|
377
|
-
[definitionsName: string]: Schema;
|
|
378
|
-
} | undefined;
|
|
379
|
-
parameters?: {
|
|
380
|
-
[parameterName: string]: BodyParameter | QueryParameter;
|
|
381
|
-
} | undefined;
|
|
382
|
-
responses?: {
|
|
383
|
-
[responseName: string]: Response;
|
|
384
|
-
} | undefined;
|
|
385
|
-
security?: Array<{
|
|
386
|
-
[securityDefinitionName: string]: string[];
|
|
387
|
-
}> | undefined;
|
|
388
|
-
securityDefinitions?: {
|
|
389
|
-
[securityDefinitionName: string]: Security;
|
|
390
|
-
} | undefined;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
86
|
type DefaultTokenPayload = {
|
|
394
87
|
id: string;
|
|
395
88
|
[key: string]: any;
|
|
@@ -409,23 +102,44 @@ type TokenConstructor = {
|
|
|
409
102
|
};
|
|
410
103
|
type TokenApiOptions = {
|
|
411
104
|
path?: string;
|
|
412
|
-
callback: (req: Request, res: Response
|
|
105
|
+
callback: (req: Request, res: Response) => Promise<void>;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
type DynamicDbRouterOptions<T extends typeof BaseEntity> = {
|
|
109
|
+
router: Router;
|
|
110
|
+
entity: T;
|
|
111
|
+
primaryKey?: string;
|
|
112
|
+
tag: string;
|
|
113
|
+
basePath: string;
|
|
114
|
+
getParameters?: Array<CustomSwaggerParameter>;
|
|
115
|
+
bodyParameters?: ExpressoSwaggerModel;
|
|
116
|
+
avoid?: Array<Methods | 'LIST'>;
|
|
117
|
+
secure?: SecureTokenConfig;
|
|
118
|
+
returningProps?: string[];
|
|
119
|
+
responses?: Record<string | number, {
|
|
120
|
+
description: string;
|
|
121
|
+
body?: any;
|
|
122
|
+
}>;
|
|
413
123
|
};
|
|
414
124
|
|
|
415
125
|
interface RouterWrapperInterface<T extends typeof BaseEntity = typeof BaseEntity> {
|
|
416
126
|
basePath: string;
|
|
417
127
|
tag: string;
|
|
418
128
|
swaggerNewSchemas?: {
|
|
419
|
-
[schema: string]:
|
|
129
|
+
[schema: string]: ExpressoSwaggerModel;
|
|
420
130
|
};
|
|
421
131
|
dbRouting?: {
|
|
422
132
|
entity: T;
|
|
423
133
|
primaryKey?: string;
|
|
424
|
-
getParameters?: Array<
|
|
425
|
-
bodyParameters?:
|
|
134
|
+
getParameters?: Array<CustomSwaggerParameter>;
|
|
135
|
+
bodyParameters?: ExpressoSwaggerModel;
|
|
426
136
|
avoid?: Array<Methods | 'LIST'>;
|
|
427
137
|
secure?: SecureTokenConfig;
|
|
428
138
|
returningProps?: string[];
|
|
139
|
+
responses?: Record<string | number, {
|
|
140
|
+
description: string;
|
|
141
|
+
body?: any;
|
|
142
|
+
}>;
|
|
429
143
|
};
|
|
430
144
|
apis?: Record<string, {
|
|
431
145
|
'GET'?: MethodPathHandling;
|
|
@@ -441,10 +155,10 @@ type MethodPathHandling = {
|
|
|
441
155
|
description?: string;
|
|
442
156
|
comType?: 'application/json' | 'multipart/form-data';
|
|
443
157
|
};
|
|
444
|
-
swaggerResponses?:
|
|
445
|
-
swaggerParameters?: Array<
|
|
158
|
+
swaggerResponses?: DynamicDbRouterOptions<any>['responses'];
|
|
159
|
+
swaggerParameters?: Array<CustomSwaggerParameter>;
|
|
446
160
|
middlewares?: RequestHandler[];
|
|
447
|
-
handler: (req: Request, res: Response
|
|
161
|
+
handler: (req: Request, res: Response) => Promise<ExpressReturn>;
|
|
448
162
|
};
|
|
449
163
|
|
|
450
164
|
declare class RouterWrapper {
|
|
@@ -483,7 +197,7 @@ declare class SocketWrapper<Metadata extends Record<string, any> = any> {
|
|
|
483
197
|
protected readonly data: SocketWrapperConstructor<Metadata>;
|
|
484
198
|
protected namespace?: Namespace;
|
|
485
199
|
constructor(data: SocketWrapperConstructor<Metadata>);
|
|
486
|
-
setupConnection: (io: Server
|
|
200
|
+
setupConnection: (io: Server) => void;
|
|
487
201
|
protected handleDisconnection: (clientId: string) => void;
|
|
488
202
|
broadcast: (eventName: string, data: any) => void;
|
|
489
203
|
broadcastExceptClient: (clientId: string, eventName: string, data: any) => void;
|
|
@@ -503,7 +217,7 @@ declare class Token<Payload extends Record<string, any> = DefaultTokenPayload> {
|
|
|
503
217
|
private keyStore;
|
|
504
218
|
constructor(tokenPayload: TokenConstructor);
|
|
505
219
|
private getKey;
|
|
506
|
-
authorize(req: Request): Promise<Payload>;
|
|
220
|
+
authorize(req: Request | string): Promise<Payload>;
|
|
507
221
|
private deriveEncryptionKey;
|
|
508
222
|
generateJWE(payload: Payload): Promise<string>;
|
|
509
223
|
verifyJWE(token: string): Promise<Payload>;
|
|
@@ -515,7 +229,7 @@ type StarterOptions = {
|
|
|
515
229
|
clientPath?: string;
|
|
516
230
|
swagger?: boolean;
|
|
517
231
|
projectConfig: ProjectConfigs;
|
|
518
|
-
beforeStartListening?: (app: Express, httpServer?: http.Server, socketIoServerInstance?: Server
|
|
232
|
+
beforeStartListening?: (app: Express, httpServer?: http.Server, socketIoServerInstance?: Server) => void;
|
|
519
233
|
sockets?: {
|
|
520
234
|
wrappers: Array<SocketWrapper>;
|
|
521
235
|
options?: Partial<ServerOptions>;
|
|
@@ -539,108 +253,6 @@ declare class Starter {
|
|
|
539
253
|
private initDb;
|
|
540
254
|
}
|
|
541
255
|
|
|
542
|
-
declare class Swagger {
|
|
543
|
-
private static fromExpressParamsToSwagger;
|
|
544
|
-
private static readonly restMethodToSwaggerKeyMapping;
|
|
545
|
-
static addServer: (server: {
|
|
546
|
-
url: string;
|
|
547
|
-
}) => number;
|
|
548
|
-
static generateOpenAPIDocument: () => any;
|
|
549
|
-
static apiDocument: Spec;
|
|
550
|
-
/**
|
|
551
|
-
* @Description
|
|
552
|
-
* - ❌ ROUTER-WRAPPER.
|
|
553
|
-
* - 🛠️ ADD-API-PATH
|
|
554
|
-
* - This method is not directly to insert inside the structur of addApiPath but is useful to create Schemas while not using the routerWrapper
|
|
555
|
-
*/
|
|
556
|
-
static addSchema: (schema: string, properties?: {
|
|
557
|
-
[propName: string]: Schema;
|
|
558
|
-
}) => void;
|
|
559
|
-
/**
|
|
560
|
-
* @Description
|
|
561
|
-
* - ❌ ROUTER-WRAPPER.
|
|
562
|
-
* - 🛠️ ADD-API-PATH
|
|
563
|
-
* - This method is thought to reduce the code in the addApiPath method
|
|
564
|
-
* - You can create a schema while declaring it and associating to the path calling this method
|
|
565
|
-
*/
|
|
566
|
-
static getBasicPost: (schema: string, required: boolean, parameters?: Parameter[], properties?: {
|
|
567
|
-
[propName: string]: Schema;
|
|
568
|
-
}, description?: string) => DynamicSwaggerOperationBody;
|
|
569
|
-
/**
|
|
570
|
-
* @Description
|
|
571
|
-
* - ❌ **ROUTER-WRAPPER.**
|
|
572
|
-
* - 🛠️ **ADD-API-PATH**
|
|
573
|
-
* - This method is thought to reduce the code in the addApiPath method
|
|
574
|
-
*/
|
|
575
|
-
static getBasicGet: (parameters?: Array<Parameter>) => DynamicSwaggerOperation;
|
|
576
|
-
/**
|
|
577
|
-
* @Description
|
|
578
|
-
* - ❌ ROUTER-WRAPPER.
|
|
579
|
-
* - This method is useful if you don't want to use the router wrapper but add your swagger schema anyway.
|
|
580
|
-
* - **It is thought to be used inside the library**, iterating through the paths of the router wrapper.
|
|
581
|
-
* - **Devs can't use inside the parameters of a RouterWrapper constructor**
|
|
582
|
-
* - You can create the structure of a specified path and method, with a schema name that should be created elsewhere
|
|
583
|
-
*/
|
|
584
|
-
static addSingleApiPath: (tag: string, basePath: string, _path: string, method: "GET" | "POST" | "PUT" | "DELETE", parameters?: Array<Parameter>, bodyObj?: {
|
|
585
|
-
schema: string;
|
|
586
|
-
required?: boolean;
|
|
587
|
-
description?: string;
|
|
588
|
-
comType?: "application/json" | "multipart/form-data";
|
|
589
|
-
}, responses?: Record<string, Reference | Response>) => void;
|
|
590
|
-
/**
|
|
591
|
-
* @Description
|
|
592
|
-
* - ❌ ROUTER-WRAPPER.
|
|
593
|
-
* - 🛠️ ADD-API-PATH
|
|
594
|
-
* - **This method is useful if you don't want to use the router wrapper but add your swagger schema anyway**.
|
|
595
|
-
* - You can use other other methods of this class to ease the writing
|
|
596
|
-
* - It is thought to create a full section of apis (hypotetically under one single tag) **while you create the schema in the meanwhile**
|
|
597
|
-
*/
|
|
598
|
-
static _addApiPath: (tag: string, basePath: string, options: {
|
|
599
|
-
[key: string]: DynamicSwaggerPath;
|
|
600
|
-
}) => void;
|
|
601
|
-
/**
|
|
602
|
-
* @Description
|
|
603
|
-
* - ✅ ROUTER-WRAPPER
|
|
604
|
-
* - Returns the tipical /:id parameter
|
|
605
|
-
*/
|
|
606
|
-
static getIdParam: (pkLabel?: string) => Parameter;
|
|
607
|
-
/**
|
|
608
|
-
* @Description
|
|
609
|
-
* - ✅ ROUTER-WRAPPER
|
|
610
|
-
* - Returns the tipical list pagination parameters
|
|
611
|
-
*/
|
|
612
|
-
static getPaginationParams: (options?: ListOptions) => Parameter[];
|
|
613
|
-
/**
|
|
614
|
-
* @Description
|
|
615
|
-
* - ✅ ROUTER-WRAPPER
|
|
616
|
-
* - Creates the swagger schema expected by your api
|
|
617
|
-
*/
|
|
618
|
-
static createMultipartSchema: (name?: string, props?: {
|
|
619
|
-
[prop: string]: Schema;
|
|
620
|
-
}) => SchemaV3;
|
|
621
|
-
/**
|
|
622
|
-
* @Description
|
|
623
|
-
* - ✅ ROUTER-WRAPPER
|
|
624
|
-
* - Creates the swagger schema expected by your api
|
|
625
|
-
*/
|
|
626
|
-
static createSchema: (props: {
|
|
627
|
-
[prop: string]: Schema | ParameterType;
|
|
628
|
-
}, required?: boolean) => SchemaV3;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
type DynamicDbRouterOptions<T extends typeof BaseEntity> = {
|
|
632
|
-
router: Router;
|
|
633
|
-
entity: T;
|
|
634
|
-
primaryKey?: string;
|
|
635
|
-
tag: string;
|
|
636
|
-
basePath: string;
|
|
637
|
-
getParameters?: Array<Parameter>;
|
|
638
|
-
bodyParameters?: SchemaV3;
|
|
639
|
-
avoid?: Array<Methods | 'LIST'>;
|
|
640
|
-
secure?: SecureTokenConfig;
|
|
641
|
-
returningProps?: string[];
|
|
642
|
-
};
|
|
643
|
-
|
|
644
256
|
declare class MyLogger extends Logger {
|
|
645
257
|
setFilePath: (filePath?: string) => void;
|
|
646
258
|
fullLogOk: (service: string, message: string) => void;
|
|
@@ -653,10 +265,10 @@ declare const fullLogOk: (service: string, message: string) => void;
|
|
|
653
265
|
declare const fullLogNok: (service: string, ...args: any[]) => void;
|
|
654
266
|
declare const apiOk: (res: any, status?: number, contentType?: string) => ExpressReturn;
|
|
655
267
|
declare const apiNok: (err: any, status?: number) => ExpressReturn;
|
|
656
|
-
declare const errorCatcher: (res: Response
|
|
268
|
+
declare const errorCatcher: (res: Response, err: unknown, errorsList?: ErrorsMapping, errorString?: string) => void;
|
|
657
269
|
declare const socketOk: <T extends Record<string, any> = any>(newMetadata?: T) => SocketConnectionOk;
|
|
658
270
|
declare const socketNok: (message: string) => SocketConnectionNok;
|
|
659
271
|
declare const sleep: (ms: number) => Promise<unknown>;
|
|
660
272
|
declare const getCompiledPath: (__filename: string, __dirname: string, pathsWithoutExtension: string[]) => string[];
|
|
661
273
|
|
|
662
|
-
export {
|
|
274
|
+
export { BackgroundService, type ConnectedSocketClient, type DefaultTokenPayload, type DynamicDbRouterOptions, type ErrorsMapping, type ExpressReturn, type ListOptions, type MethodPathHandling, type Methods, type ProjectConfigs, RouterWrapper, type RouterWrapperInterface, type SearchQuery, type SecureTokenConfig, type SocketConnectionMiddleware, type SocketConnectionNok, type SocketConnectionOk, SocketWrapper, type SocketWrapperConstructor, Starter, type StarterOptions, Swagger, type SwaggerMetadataInterface, Token, type TokenApiOptions, type TokenConstructor, apiNok, apiOk, c, errorCatcher, fullLogNok, fullLogOk, getCompiledPath, i, log, sleep, socketNok, socketOk };
|