alado 2.1.4 → 2.2.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/.husky/pre-commit +3 -0
- package/README.md +21 -3
- package/dist/alado-server/alado-server.d.ts +0 -1
- package/dist/decorators/define-request.js +2 -3
- package/dist/decorators/define-request.js.map +1 -1
- package/dist/decorators/define-response.js +1 -2
- package/dist/decorators/define-response.js.map +1 -1
- package/dist/decorators/document-property.js +1 -2
- package/dist/decorators/document-property.js.map +1 -1
- package/dist/decorators/file-upload-property.js +1 -2
- package/dist/decorators/file-upload-property.js.map +1 -1
- package/dist/decorators/http.js +6 -7
- package/dist/decorators/http.js.map +1 -1
- package/dist/decorators/initialize-application.js +18 -4
- package/dist/decorators/initialize-application.js.map +1 -1
- package/dist/decorators/initialize-injector.js +1 -2
- package/dist/decorators/initialize-injector.js.map +1 -1
- package/dist/decorators/transform-property.js +1 -2
- package/dist/decorators/transform-property.js.map +1 -1
- package/dist/decorators/validate-property.js +1 -2
- package/dist/decorators/validate-property.js.map +1 -1
- package/dist/decorators/with-auth.js +1 -2
- package/dist/decorators/with-auth.js.map +1 -1
- package/dist/dto/context.d.ts +2 -2
- package/dist/dto/property-definition.d.ts +10 -10
- package/dist/dto/request-authentication.d.ts +2 -2
- package/dist/dto/request.d.ts +0 -2
- package/dist/dto/response.d.ts +3 -2
- package/dist/dto/route.d.ts +2 -2
- package/dist/factory/http-server-factory.d.ts +2 -6
- package/dist/factory/http-server-factory.js +5 -4
- package/dist/factory/http-server-factory.js.map +1 -1
- package/dist/factory/open-api-doc-factory.js +20 -21
- package/dist/factory/open-api-doc-factory.js.map +1 -1
- package/dist/helpers/accessor/get-property.js +1 -2
- package/dist/helpers/accessor/get-property.js.map +1 -1
- package/dist/helpers/accessor/set-property.js +1 -2
- package/dist/helpers/accessor/set-property.js.map +1 -1
- package/dist/helpers/api-doc/doc-object-setter.js +1 -2
- package/dist/helpers/api-doc/doc-object-setter.js.map +1 -1
- package/dist/helpers/parser/authenticate.js +1 -2
- package/dist/helpers/parser/authenticate.js.map +1 -1
- package/dist/helpers/parser/body-parser.d.ts +0 -1
- package/dist/helpers/parser/body-parser.js +2 -3
- package/dist/helpers/parser/body-parser.js.map +1 -1
- package/dist/helpers/parser/query-parser.js +1 -2
- package/dist/helpers/parser/query-parser.js.map +1 -1
- package/dist/helpers/service/clear-route-path.js +1 -2
- package/dist/helpers/service/clear-route-path.js.map +1 -1
- package/dist/helpers/service/is-readable-stream.d.ts +0 -1
- package/dist/helpers/service/is-readable-stream.js +1 -2
- package/dist/helpers/service/is-readable-stream.js.map +1 -1
- package/dist/helpers/validate/alado-options/validate-alado-options.js +3 -3
- package/dist/helpers/validate/alado-options/validate-alado-options.js.map +1 -1
- package/dist/helpers/validate/context/validate-context.js +2 -3
- package/dist/helpers/validate/context/validate-context.js.map +1 -1
- package/dist/helpers/validate/context/validate-request-files.d.ts +2 -2
- package/dist/helpers/validate/context/validate-request-files.js +1 -2
- package/dist/helpers/validate/context/validate-request-files.js.map +1 -1
- package/dist/helpers/validate/context/validate-request-part.d.ts +1 -1
- package/dist/helpers/validate/context/validate-request-part.js +2 -3
- package/dist/helpers/validate/context/validate-request-part.js.map +1 -1
- package/dist/helpers/validate/controller/distinguish-controller-build-strategy.d.ts +1 -0
- package/dist/helpers/validate/controller/distinguish-controller-build-strategy.js +22 -0
- package/dist/helpers/validate/controller/distinguish-controller-build-strategy.js.map +1 -0
- package/dist/helpers/validate/controller/index.d.ts +1 -0
- package/dist/helpers/validate/controller/index.js +18 -0
- package/dist/helpers/validate/controller/index.js.map +1 -0
- package/dist/helpers/validate/index.d.ts +1 -0
- package/dist/helpers/validate/index.js +1 -0
- package/dist/helpers/validate/index.js.map +1 -1
- package/dist/options/alado-server-options.d.ts +0 -2
- package/dist/options/cors-options.d.ts +2 -2
- package/dist/options/initialize-application-options.d.ts +6 -1
- package/dist/request-processor/request-processor.d.ts +0 -1
- package/dist/request-processor/request-processor.js +5 -5
- package/dist/request-processor/request-processor.js.map +1 -1
- package/dist/router/router.d.ts +1 -1
- package/dist/router/router.js +9 -8
- package/dist/router/router.js.map +1 -1
- package/package.json +12 -17
package/README.md
CHANGED
|
@@ -167,7 +167,8 @@ export class UserController {
|
|
|
167
167
|
@post('/user', { tags: ['User'] })
|
|
168
168
|
@defineResponse({
|
|
169
169
|
statusCode: 201,
|
|
170
|
-
title: '
|
|
170
|
+
title: 'Created',
|
|
171
|
+
entity: 'User',
|
|
171
172
|
headers: { 'Content-Type': 'application/json' },
|
|
172
173
|
body: exampleUserDto,
|
|
173
174
|
})
|
|
@@ -186,7 +187,8 @@ export class UserController {
|
|
|
186
187
|
@withAuth(bearerAuth)
|
|
187
188
|
@defineResponse({
|
|
188
189
|
statusCode: 200,
|
|
189
|
-
title: '
|
|
190
|
+
title: 'OK',
|
|
191
|
+
enity: 'User',
|
|
190
192
|
headers: { 'Content-Type': 'application/json' },
|
|
191
193
|
body: exampleUserDto,
|
|
192
194
|
})
|
|
@@ -216,7 +218,8 @@ export class UserController {
|
|
|
216
218
|
@withAuth(bearerAuth)
|
|
217
219
|
@defineResponse({
|
|
218
220
|
statusCode: 200,
|
|
219
|
-
title: '
|
|
221
|
+
title: 'OK',
|
|
222
|
+
enity: 'User',
|
|
220
223
|
headers: { 'Content-Type': 'application/json' },
|
|
221
224
|
body: exampleUserDto,
|
|
222
225
|
})
|
|
@@ -490,6 +493,21 @@ export const app = initializeApplication({
|
|
|
490
493
|
app.start(() => console.log('Application has been successfully started'));
|
|
491
494
|
```
|
|
492
495
|
|
|
496
|
+
There's ability to pass args to controller`s constructor:
|
|
497
|
+
|
|
498
|
+
```ts
|
|
499
|
+
import { initializeApplication } from 'alado';
|
|
500
|
+
import { aladoServerOptions } from '@config';
|
|
501
|
+
import { UserController } from '@user';
|
|
502
|
+
|
|
503
|
+
export const app = initializeApplication({
|
|
504
|
+
serverOptions: aladoServerOptions,
|
|
505
|
+
controllers: [{ controller: UserController, options: [{ service: SomeService }] }],
|
|
506
|
+
});
|
|
507
|
+
|
|
508
|
+
app.start(() => console.log('Application has been successfully started'));
|
|
509
|
+
```
|
|
510
|
+
|
|
493
511
|
#### Arguments
|
|
494
512
|
|
|
495
513
|
- **initializeApplicationOptions**: Object containing:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defineRequest =
|
|
3
|
+
exports.defineRequest = defineRequest;
|
|
4
4
|
const _injector_1 = require("../injector");
|
|
5
5
|
const initialize_injector_1 = require("./initialize-injector");
|
|
6
6
|
function defineRequest(request) {
|
|
@@ -12,11 +12,10 @@ function defineRequest(request) {
|
|
|
12
12
|
const key = `${args[0].constructor.name}.${args[1]}`;
|
|
13
13
|
const r = {};
|
|
14
14
|
for (const k in request) {
|
|
15
|
-
const className = request[k]
|
|
15
|
+
const className = request[k]?.name;
|
|
16
16
|
r[k] = _injector_1.injector.injected.propertyDefinitionsMapping[className];
|
|
17
17
|
_injector_1.injector.injected.requestMapping[key] = r;
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
exports.defineRequest = defineRequest;
|
|
22
21
|
//# sourceMappingURL=define-request.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-request.js","sourceRoot":"","sources":["../../src/decorators/define-request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"define-request.js","sourceRoot":"","sources":["../../src/decorators/define-request.ts"],"names":[],"mappings":";;AAKA,sCAcC;AAlBD,yCAAqC;AAErC,+DAA2D;AAE3D,SAAgB,aAAa,CAAC,OAAiD;IAC7E,IAAA,wCAAkB,GAAE,CAAC;IACrB,OAAO,UAAU,GAAG,IAAW;QAC7B,IAAI,CAAC,oBAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;YACtC,oBAAQ,CAAC,QAAQ,CAAC,cAAc,GAAG,EAAE,CAAC;QACxC,CAAC;QACD,MAAM,GAAG,GAAW,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,MAAM,CAAC,GAAgF,EAAE,CAAC;QAC1F,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;YACxB,MAAM,SAAS,GAAW,OAAO,CAAC,CAAkB,CAAC,EAAE,IAAI,CAAC;YAC5D,CAAC,CAAC,CAAC,CAAC,GAAG,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,SAAmB,CAAC,CAAC;YACzE,oBAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defineResponse =
|
|
3
|
+
exports.defineResponse = defineResponse;
|
|
4
4
|
const _injector_1 = require("../injector");
|
|
5
5
|
const initialize_injector_1 = require("./initialize-injector");
|
|
6
6
|
function defineResponse(response) {
|
|
@@ -14,5 +14,4 @@ function defineResponse(response) {
|
|
|
14
14
|
_injector_1.injector.injected.responseMapping[key] = response;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
exports.defineResponse = defineResponse;
|
|
18
17
|
//# sourceMappingURL=define-response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-response.js","sourceRoot":"","sources":["../../src/decorators/define-response.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"define-response.js","sourceRoot":"","sources":["../../src/decorators/define-response.ts"],"names":[],"mappings":";;AAIA,wCAaC;AAjBD,yCAAqC;AAErC,+DAA2D;AAE3D,SAAgB,cAAc,CAAC,QAAuB;IACpD,IAAA,wCAAkB,GAAE,CAAC;IACrB,OAAO,UAAU,GAAG,IAAW;QAC7B,IAAI,CAAC,oBAAQ,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;YACvC,oBAAQ,CAAC,QAAQ,CAAC,eAAe,GAAG,EAAE,CAAC;QACzC,CAAC;QACD,MAAM,CACJ,UAAU,EACV,MAAM,EACP,GAAG,IAAI,CAAC;QACT,MAAM,GAAG,GAAG,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,IAAI,MAAM,EAAE,CAAC;QACvD,oBAAQ,CAAC,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC;IACpD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.documentProperty =
|
|
3
|
+
exports.documentProperty = documentProperty;
|
|
4
4
|
const _injector_1 = require("../injector");
|
|
5
5
|
const initialize_injector_1 = require("./initialize-injector");
|
|
6
6
|
function documentProperty(propertyDocumentation) {
|
|
@@ -17,5 +17,4 @@ function documentProperty(propertyDocumentation) {
|
|
|
17
17
|
propertyDefinitionsMapping[key][args[1]].openApiDoc = propertyDocumentation;
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
exports.documentProperty = documentProperty;
|
|
21
20
|
//# sourceMappingURL=document-property.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document-property.js","sourceRoot":"","sources":["../../src/decorators/document-property.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"document-property.js","sourceRoot":"","sources":["../../src/decorators/document-property.ts"],"names":[],"mappings":";;AAIA,4CAaC;AAhBD,yCAAqC;AACrC,+DAA2D;AAE3D,SAAgB,gBAAgB,CAAC,qBAA4C;IAC3E,IAAA,wCAAkB,GAAE,CAAC;IACrB,OAAO,UAAU,GAAG,IAAW;QAC7B,IAAI,CAAC,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,EAAE,CAAC;YAClD,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,GAAG,EAAE,CAAC;QACpD,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;QACrC,MAAM,EAAE,0BAA0B,EAAE,GAAG,oBAAQ,CAAC,QAAQ,CAAC;QACzD,0BAA0B,CAAC,GAAG,CAAC,GAAG,0BAA0B,CAAC,GAAG,CAAC,IAAK,EAAyC,CAAC;QAChH,0BAA0B,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAW,CAAC;YAChD,0BAA0B,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAW,CAAC,IAAK,EAAyB,CAAC;QAClF,0BAA0B,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAW,CAAwB,CAAC,UAAU,GAAG,qBAAqB,CAAC;IAChH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fileUploadProperty =
|
|
3
|
+
exports.fileUploadProperty = fileUploadProperty;
|
|
4
4
|
const _injector_1 = require("../injector");
|
|
5
5
|
const initialize_injector_1 = require("./initialize-injector");
|
|
6
6
|
function fileUploadProperty(filePropertyDefinition) {
|
|
@@ -13,5 +13,4 @@ function fileUploadProperty(filePropertyDefinition) {
|
|
|
13
13
|
_injector_1.injector.injected.propertyDefinitionsMapping[key][args[1]] = filePropertyDefinition;
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
exports.fileUploadProperty = fileUploadProperty;
|
|
17
16
|
//# sourceMappingURL=file-upload-property.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-upload-property.js","sourceRoot":"","sources":["../../src/decorators/file-upload-property.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-upload-property.js","sourceRoot":"","sources":["../../src/decorators/file-upload-property.ts"],"names":[],"mappings":";;AAIA,gDASC;AAZD,yCAAqC;AACrC,+DAA2D;AAE3D,SAAgB,kBAAkB,CAAC,sBAA8C;IAC/E,IAAA,wCAAkB,GAAE,CAAC;IACrB,OAAO,UAAU,GAAG,IAAW;QAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;QACrC,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,CAAC;YAC/C,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,CAAC;gBAChD,EAAkE,CAAC;QACtE,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAW,CAAC,GAAG,sBAAsB,CAAC;IAChG,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/decorators/http.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.get = get;
|
|
4
|
+
exports.post = post;
|
|
5
|
+
exports.put = put;
|
|
6
|
+
exports.patch = patch;
|
|
7
|
+
exports.del = del;
|
|
8
|
+
exports.head = head;
|
|
4
9
|
const _const_1 = require("../constants");
|
|
5
10
|
const _injector_1 = require("../injector");
|
|
6
11
|
const initialize_injector_1 = require("./initialize-injector");
|
|
@@ -48,25 +53,19 @@ function callHttpMethod(httpMethod, path, options = {}) {
|
|
|
48
53
|
function get(path, options = {}) {
|
|
49
54
|
return callHttpMethod(_const_1.HttpMethod.GET, path, options);
|
|
50
55
|
}
|
|
51
|
-
exports.get = get;
|
|
52
56
|
function post(path, options = {}) {
|
|
53
57
|
return callHttpMethod(_const_1.HttpMethod.POST, path, options);
|
|
54
58
|
}
|
|
55
|
-
exports.post = post;
|
|
56
59
|
function put(path, options = {}) {
|
|
57
60
|
return callHttpMethod(_const_1.HttpMethod.PUT, path, options);
|
|
58
61
|
}
|
|
59
|
-
exports.put = put;
|
|
60
62
|
function patch(path, options = {}) {
|
|
61
63
|
return callHttpMethod(_const_1.HttpMethod.PATCH, path, options);
|
|
62
64
|
}
|
|
63
|
-
exports.patch = patch;
|
|
64
65
|
function del(path, options = {}) {
|
|
65
66
|
return callHttpMethod(_const_1.HttpMethod.DELETE, path, options);
|
|
66
67
|
}
|
|
67
|
-
exports.del = del;
|
|
68
68
|
function head(path, options = {}) {
|
|
69
69
|
return callHttpMethod(_const_1.HttpMethod.HEAD, path, options);
|
|
70
70
|
}
|
|
71
|
-
exports.head = head;
|
|
72
71
|
//# sourceMappingURL=http.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/decorators/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/decorators/http.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initializeApplication =
|
|
3
|
+
exports.initializeApplication = initializeApplication;
|
|
4
4
|
const _injector_1 = require("../injector");
|
|
5
5
|
const _const_1 = require("../constants");
|
|
6
6
|
const _alado_1 = require("../alado-server");
|
|
7
7
|
const initialize_injector_1 = require("./initialize-injector");
|
|
8
|
+
const _helper_1 = require("../helpers");
|
|
8
9
|
function initializeApplication(initializeApplicationOptions) {
|
|
9
10
|
(0, initialize_injector_1.initializeInjector)();
|
|
10
11
|
const { serverOptions, controllers } = initializeApplicationOptions;
|
|
11
12
|
_injector_1.injector.injected.appMapping[serverOptions.appId || _const_1.DEFAULT_ID] =
|
|
12
13
|
_injector_1.injector.injected.appMapping[serverOptions.appId || _const_1.DEFAULT_ID] || new _alado_1.AladoServer(serverOptions);
|
|
13
14
|
const app = _injector_1.injector.injected.appMapping[serverOptions.appId || _const_1.DEFAULT_ID];
|
|
14
|
-
for (const
|
|
15
|
-
|
|
15
|
+
for (const data of controllers) {
|
|
16
|
+
const strategy = (0, _helper_1.distinguishControllerBuildStrategy)(data);
|
|
17
|
+
let controller;
|
|
18
|
+
let options = [];
|
|
19
|
+
switch (strategy) {
|
|
20
|
+
case 'simple':
|
|
21
|
+
controller = data;
|
|
22
|
+
break;
|
|
23
|
+
case 'complex':
|
|
24
|
+
controller = data.controller;
|
|
25
|
+
options = data.options;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
if (controller) {
|
|
29
|
+
new controller(...options);
|
|
30
|
+
}
|
|
16
31
|
}
|
|
17
32
|
const shadowApp = _injector_1.injector.injected.shadowAppMapping[serverOptions.appId || _const_1.DEFAULT_ID];
|
|
18
33
|
if (Array.isArray(shadowApp) && shadowApp.length) {
|
|
@@ -23,5 +38,4 @@ function initializeApplication(initializeApplicationOptions) {
|
|
|
23
38
|
}
|
|
24
39
|
return app;
|
|
25
40
|
}
|
|
26
|
-
exports.initializeApplication = initializeApplication;
|
|
27
41
|
//# sourceMappingURL=initialize-application.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize-application.js","sourceRoot":"","sources":["../../src/decorators/initialize-application.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initialize-application.js","sourceRoot":"","sources":["../../src/decorators/initialize-application.ts"],"names":[],"mappings":";;AAOA,sDA+BC;AArCD,yCAAqC;AACrC,mCAAoC;AACpC,mCAAqC;AACrC,+DAA2D;AAC3D,qCAA6D;AAE7D,SAAgB,qBAAqB,CAAC,4BAA0D;IAC9F,IAAA,wCAAkB,GAAE,CAAC;IACrB,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,4BAA4B,CAAC;IACpE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,mBAAU,CAAC;QAC7D,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,mBAAU,CAAC,IAAI,IAAI,oBAAW,CAAC,aAAa,CAAC,CAAC;IACpG,MAAM,GAAG,GAAgB,oBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,IAAI,mBAAU,CAAC,CAAC;IACzF,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;QAC/B,MAAM,QAAQ,GAAG,IAAA,4CAAkC,EAAC,IAAI,CAAC,CAAC;QAC1D,IAAI,UAAoB,CAAC;QACzB,IAAI,OAAO,GAAU,EAAE,CAAC;QACxB,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,QAAQ;gBACX,UAAU,GAAG,IAAgB,CAAC;gBAC9B,MAAM;YACR,KAAK,SAAS;gBACZ,UAAU,GAAI,IAAyC,CAAC,UAAU,CAAC;gBACnE,OAAO,GAAI,IAAyC,CAAC,OAAO,CAAC;gBAC7D,MAAM;QACV,CAAC;QACD,IAAI,UAAU,EAAE,CAAC;YACf,IAAI,UAAU,CAAC,GAAG,OAAO,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,MAAM,SAAS,GAAG,oBAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,aAAa,CAAC,KAAK,IAAI,mBAAU,CAAC,CAAC;IACxF,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;QACjD,OAAO,SAAS,CAAC,MAAM,EAAE,CAAC;YACxB,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC;YAC3B,EAAE,CAAC,GAAG,CAAC,CAAC;QACV,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initializeInjector =
|
|
3
|
+
exports.initializeInjector = initializeInjector;
|
|
4
4
|
const _injector_1 = require("../injector");
|
|
5
5
|
function initializeInjector() {
|
|
6
6
|
_injector_1.injector.inject({
|
|
@@ -13,5 +13,4 @@ function initializeInjector() {
|
|
|
13
13
|
controllers: _injector_1.injector.injected.controllers || {},
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
exports.initializeInjector = initializeInjector;
|
|
17
16
|
//# sourceMappingURL=initialize-injector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initialize-injector.js","sourceRoot":"","sources":["../../src/decorators/initialize-injector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initialize-injector.js","sourceRoot":"","sources":["../../src/decorators/initialize-injector.ts"],"names":[],"mappings":";;AAEA,gDAUC;AAZD,yCAAqC;AAErC,SAAgB,kBAAkB;IAChC,oBAAQ,CAAC,MAAM,CAAC;QACd,UAAU,EAAE,oBAAQ,CAAC,QAAQ,CAAC,UAAU,IAAI,EAAE;QAC9C,gBAAgB,EAAE,oBAAQ,CAAC,QAAQ,CAAC,gBAAgB,IAAI,EAAE;QAC1D,cAAc,EAAE,oBAAQ,CAAC,QAAQ,CAAC,cAAc,IAAI,EAAE;QACtD,eAAe,EAAE,oBAAQ,CAAC,QAAQ,CAAC,eAAe,IAAI,EAAE;QACxD,WAAW,EAAE,oBAAQ,CAAC,QAAQ,CAAC,WAAW,IAAI,EAAE;QAChD,0BAA0B,EAAE,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,IAAI,EAAE;QAC9E,WAAW,EAAE,oBAAQ,CAAC,QAAQ,CAAC,WAAW,IAAI,EAAE;KACjD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformProperty =
|
|
3
|
+
exports.transformProperty = transformProperty;
|
|
4
4
|
const _injector_1 = require("../injector");
|
|
5
5
|
const initialize_injector_1 = require("./initialize-injector");
|
|
6
6
|
function transformProperty(propertyTransformer) {
|
|
@@ -18,5 +18,4 @@ function transformProperty(propertyTransformer) {
|
|
|
18
18
|
propertyTransformer;
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
exports.transformProperty = transformProperty;
|
|
22
21
|
//# sourceMappingURL=transform-property.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-property.js","sourceRoot":"","sources":["../../src/decorators/transform-property.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transform-property.js","sourceRoot":"","sources":["../../src/decorators/transform-property.ts"],"names":[],"mappings":";;AAIA,8CAcC;AAjBD,yCAAqC;AACrC,+DAA2D;AAE3D,SAAgB,iBAAiB,CAAC,mBAAuD;IACvF,IAAA,wCAAkB,GAAE,CAAC;IACrB,OAAO,UAAU,GAAG,IAAW;QAC7B,IAAI,CAAC,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,EAAE,CAAC;YAClD,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,GAAG,EAAE,CAAC;QACpD,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;QACrC,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,CAAC;YAC/C,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,CAAC,IAAK,EAAyC,CAAC;QAClG,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAW,CAAC;YAClE,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAW,CAAC,IAAK,EAAyB,CAAC;QACpG,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAW,CAAwB,CAAC,SAAS;YACpG,mBAAmB,CAAC;IACxB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateProperty =
|
|
3
|
+
exports.validateProperty = validateProperty;
|
|
4
4
|
const _injector_1 = require("../injector");
|
|
5
5
|
const initialize_injector_1 = require("./initialize-injector");
|
|
6
6
|
function validateProperty(propertyValidation) {
|
|
@@ -18,5 +18,4 @@ function validateProperty(propertyValidation) {
|
|
|
18
18
|
propertyValidation;
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
exports.validateProperty = validateProperty;
|
|
22
21
|
//# sourceMappingURL=validate-property.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-property.js","sourceRoot":"","sources":["../../src/decorators/validate-property.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate-property.js","sourceRoot":"","sources":["../../src/decorators/validate-property.ts"],"names":[],"mappings":";;AAIA,4CAcC;AAjBD,yCAAqC;AACrC,+DAA2D;AAE3D,SAAgB,gBAAgB,CAAC,kBAAsC;IACrE,IAAA,wCAAkB,GAAE,CAAC;IACrB,OAAO,UAAU,GAAG,IAAW;QAC7B,IAAI,CAAC,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,EAAE,CAAC;YAClD,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,GAAG,EAAE,CAAC;QACpD,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC;QACrC,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,CAAC;YAC/C,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,CAAC,IAAK,EAAyC,CAAC;QAClG,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAW,CAAC;YAClE,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAW,CAAC,IAAK,EAAyB,CAAC;QACpG,oBAAQ,CAAC,QAAQ,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAW,CAAwB,CAAC,UAAU;YACrG,kBAAkB,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withAuth =
|
|
3
|
+
exports.withAuth = withAuth;
|
|
4
4
|
const _injector_1 = require("../injector");
|
|
5
5
|
const initialize_injector_1 = require("./initialize-injector");
|
|
6
6
|
function withAuth(requestAuthentication) {
|
|
@@ -11,5 +11,4 @@ function withAuth(requestAuthentication) {
|
|
|
11
11
|
_injector_1.injector.injected.authMapping[key] = requestAuthentication;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
exports.withAuth = withAuth;
|
|
15
14
|
//# sourceMappingURL=with-auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-auth.js","sourceRoot":"","sources":["../../src/decorators/with-auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"with-auth.js","sourceRoot":"","sources":["../../src/decorators/with-auth.ts"],"names":[],"mappings":";;AAIA,4BAUC;AAbD,yCAAqC;AACrC,+DAA2D;AAE3D,SAAgB,QAAQ,CAAC,qBAA4C;IACnE,IAAA,wCAAkB,GAAE,CAAC;IACrB,OAAO,UAAU,GAAG,IAAW;QAC7B,MAAM,CACJ,UAAU,EACV,MAAM,EACP,GAAG,IAAI,CAAC;QACT,MAAM,GAAG,GAAG,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,IAAI,MAAM,EAAE,CAAC;QACvD,oBAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,qBAAqB,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/dto/context.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { ContextOptions } from '../options';
|
|
|
2
2
|
import { RequestAuthentication } from './request-authentication';
|
|
3
3
|
import { Response } from './response';
|
|
4
4
|
import { ContextRequest } from './request';
|
|
5
|
-
export
|
|
5
|
+
export type Context<T> = {
|
|
6
6
|
title: string;
|
|
7
7
|
auth?: RequestAuthentication;
|
|
8
8
|
options: ContextOptions;
|
|
9
9
|
request: ContextRequest;
|
|
10
10
|
response: Response<Record<keyof T, any>>;
|
|
11
|
-
}
|
|
11
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AladoServerError } from './alado-server-error';
|
|
2
|
-
export
|
|
2
|
+
export type PropertyDefinitionSchema = {
|
|
3
3
|
type?: string;
|
|
4
4
|
format?: string;
|
|
5
5
|
default?: any;
|
|
@@ -29,28 +29,28 @@ export interface PropertyDefinitionSchema {
|
|
|
29
29
|
minItems?: number;
|
|
30
30
|
maxItems?: number;
|
|
31
31
|
uniqueItems?: boolean;
|
|
32
|
-
}
|
|
33
|
-
export
|
|
32
|
+
};
|
|
33
|
+
export type PropertyDocumentation = {
|
|
34
34
|
schema: PropertyDefinitionSchema;
|
|
35
35
|
description?: string;
|
|
36
36
|
example?: any;
|
|
37
|
-
}
|
|
38
|
-
export
|
|
37
|
+
};
|
|
38
|
+
export type PropertyValidation = {
|
|
39
39
|
required?: boolean;
|
|
40
40
|
handler: (value: any) => boolean | Promise<boolean>;
|
|
41
41
|
error: AladoServerError;
|
|
42
|
-
}
|
|
43
|
-
export
|
|
42
|
+
};
|
|
43
|
+
export type PropertyDefinition = {
|
|
44
44
|
isJSON?: boolean;
|
|
45
45
|
validation: PropertyValidation;
|
|
46
46
|
openApiDoc?: PropertyDocumentation;
|
|
47
47
|
transform?: (value: any) => any | Promise<any>;
|
|
48
|
-
}
|
|
49
|
-
export
|
|
48
|
+
};
|
|
49
|
+
export type FilePropertyDefinition = {
|
|
50
50
|
mimetypes: string[];
|
|
51
51
|
maxSize: number;
|
|
52
52
|
required: boolean;
|
|
53
53
|
mimetypeError: AladoServerError;
|
|
54
54
|
maxSizeError: AladoServerError;
|
|
55
55
|
requiredError: AladoServerError;
|
|
56
|
-
}
|
|
56
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AladoServerError } from './alado-server-error';
|
|
2
|
-
export
|
|
2
|
+
export type RequestAuthentication = {
|
|
3
3
|
inputProperty: string;
|
|
4
4
|
outputProperty: string;
|
|
5
5
|
handler: (value: any) => any | Promise<any>;
|
|
6
6
|
handlerContext?: any;
|
|
7
7
|
required: boolean;
|
|
8
8
|
error: AladoServerError;
|
|
9
|
-
}
|
|
9
|
+
};
|
package/dist/dto/request.d.ts
CHANGED
package/dist/dto/response.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export type ResponseError = {
|
|
2
2
|
message: string;
|
|
3
3
|
};
|
|
4
|
-
export
|
|
4
|
+
export type Response<T> = {
|
|
5
5
|
title?: string;
|
|
6
|
+
entity?: string;
|
|
6
7
|
description?: string;
|
|
7
8
|
statusCode: number;
|
|
8
9
|
headers?: Record<string, string>;
|
|
9
10
|
body?: T | ResponseError;
|
|
10
|
-
}
|
|
11
|
+
};
|
package/dist/dto/route.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Context } from './context';
|
|
2
2
|
import { Request } from './request';
|
|
3
|
-
export
|
|
3
|
+
export type Route<T> = {
|
|
4
4
|
route: RegExp;
|
|
5
5
|
path: Record<string, string>;
|
|
6
6
|
context: Context<T>;
|
|
7
7
|
handler: (request: Request) => any;
|
|
8
8
|
allowedMethods?: string[];
|
|
9
|
-
}
|
|
9
|
+
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
1
|
import { SecureContextOptions } from 'tls';
|
|
5
|
-
import
|
|
6
|
-
import https from 'https';
|
|
2
|
+
import { IncomingMessage, Server, ServerOptions, ServerResponse } from 'http';
|
|
7
3
|
import { RequestProcessorOptions } from '../options';
|
|
8
|
-
export declare function httpServerFactory(requestProcessorOptions: RequestProcessorOptions, options?: SecureContextOptions & ServerOptions):
|
|
4
|
+
export declare function httpServerFactory(requestProcessorOptions: RequestProcessorOptions, options?: SecureContextOptions & ServerOptions): Server<typeof IncomingMessage, typeof ServerResponse>;
|
|
@@ -3,17 +3,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.httpServerFactory =
|
|
6
|
+
exports.httpServerFactory = httpServerFactory;
|
|
7
7
|
const http_1 = __importDefault(require("http"));
|
|
8
8
|
const https_1 = __importDefault(require("https"));
|
|
9
9
|
const _request_processor_1 = require("../request-processor");
|
|
10
|
-
function
|
|
10
|
+
function verifySecureContextOptions(options) {
|
|
11
11
|
return options && typeof options === 'object' && Boolean(Object.keys(options).length);
|
|
12
12
|
}
|
|
13
13
|
function httpServerFactory(requestProcessorOptions, options) {
|
|
14
14
|
const requestProcessor = new _request_processor_1.RequestProcessor(requestProcessorOptions);
|
|
15
15
|
const handler = requestProcessor.process.bind(requestProcessor);
|
|
16
|
-
return
|
|
16
|
+
return verifySecureContextOptions(options)
|
|
17
|
+
? https_1.default.createServer(options, handler)
|
|
18
|
+
: http_1.default.createServer(handler);
|
|
17
19
|
}
|
|
18
|
-
exports.httpServerFactory = httpServerFactory;
|
|
19
20
|
//# sourceMappingURL=http-server-factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-server-factory.js","sourceRoot":"","sources":["../../src/factory/http-server-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http-server-factory.js","sourceRoot":"","sources":["../../src/factory/http-server-factory.ts"],"names":[],"mappings":";;;;;AAUA,8CASC;AAlBD,gDAAoF;AACpF,kDAA0B;AAE1B,2DAAsD;AAEtD,SAAS,0BAA0B,CAAC,OAA6C;IAC/E,OAAO,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AACxF,CAAC;AAED,SAAgB,iBAAiB,CAC/B,uBAAgD,EAChD,OAA8C;IAE9C,MAAM,gBAAgB,GAAqB,IAAI,qCAAgB,CAAC,uBAAuB,CAAC,CAAC;IACzF,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAChE,OAAO,0BAA0B,CAAC,OAA+C,CAAC;QAChF,CAAC,CAAC,eAAK,CAAC,YAAY,CAAC,OAA+C,EAAE,OAAO,CAAC;QAC9E,CAAC,CAAE,cAAI,CAAC,YAAY,CAAC,OAAO,CAA2D,CAAC;AAC5F,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.openApiDocFactory =
|
|
3
|
+
exports.openApiDocFactory = openApiDocFactory;
|
|
4
4
|
const _helper_1 = require("../helpers");
|
|
5
5
|
const nonBinResponses = [
|
|
6
6
|
'application/json',
|
|
@@ -34,9 +34,9 @@ function openApiDocFactory(openApiMethod, openApiRoute, context, openApiDocObjec
|
|
|
34
34
|
in: 'headers',
|
|
35
35
|
name: header,
|
|
36
36
|
required: headers[header].validation.required || false,
|
|
37
|
-
schema: headers[header].openApiDoc
|
|
38
|
-
description: headers[header].openApiDoc
|
|
39
|
-
example: headers[header].openApiDoc
|
|
37
|
+
schema: headers[header].openApiDoc?.schema,
|
|
38
|
+
description: headers[header].openApiDoc?.description,
|
|
39
|
+
example: headers[header].openApiDoc?.example,
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
}
|
|
@@ -45,10 +45,10 @@ function openApiDocFactory(openApiMethod, openApiRoute, context, openApiDocObjec
|
|
|
45
45
|
openApiDocObject.paths[openApiRoute][openApiMethod].parameters.push({
|
|
46
46
|
in: 'path',
|
|
47
47
|
name: param,
|
|
48
|
-
required: path[param].validation
|
|
49
|
-
schema: path[param].openApiDoc
|
|
50
|
-
description: path[param].openApiDoc
|
|
51
|
-
example: path[param].openApiDoc
|
|
48
|
+
required: path[param].validation?.required || false,
|
|
49
|
+
schema: path[param].openApiDoc?.schema,
|
|
50
|
+
description: path[param].openApiDoc?.description,
|
|
51
|
+
example: path[param].openApiDoc?.example,
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -57,10 +57,10 @@ function openApiDocFactory(openApiMethod, openApiRoute, context, openApiDocObjec
|
|
|
57
57
|
openApiDocObject.paths[openApiRoute][openApiMethod].parameters.push({
|
|
58
58
|
in: 'query',
|
|
59
59
|
name: param,
|
|
60
|
-
required: query[param].validation
|
|
61
|
-
schema: query[param].openApiDoc
|
|
62
|
-
description: query[param].openApiDoc
|
|
63
|
-
example: query[param].openApiDoc
|
|
60
|
+
required: query[param].validation?.required || false,
|
|
61
|
+
schema: query[param].openApiDoc?.schema,
|
|
62
|
+
description: query[param].openApiDoc?.description,
|
|
63
|
+
example: query[param].openApiDoc?.example,
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -83,7 +83,7 @@ function openApiDocFactory(openApiMethod, openApiRoute, context, openApiDocObjec
|
|
|
83
83
|
}
|
|
84
84
|
if (body) {
|
|
85
85
|
for (const prop in body) {
|
|
86
|
-
uploadObject.content['multipart/form-data'].schema.properties[prop] = body[prop].openApiDoc
|
|
86
|
+
uploadObject.content['multipart/form-data'].schema.properties[prop] = body[prop].openApiDoc?.schema;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
openApiDocObject.paths[openApiRoute][openApiMethod].requestBody = uploadObject;
|
|
@@ -102,13 +102,13 @@ function openApiDocFactory(openApiMethod, openApiRoute, context, openApiDocObjec
|
|
|
102
102
|
},
|
|
103
103
|
};
|
|
104
104
|
for (const prop in body) {
|
|
105
|
-
bodyObject.content[contentType].schema.properties[prop] = body[prop]
|
|
105
|
+
bodyObject.content[contentType].schema.properties[prop] = body[prop]?.openApiDoc?.schema;
|
|
106
106
|
}
|
|
107
107
|
openApiDocObject.paths[openApiRoute][openApiMethod].requestBody = bodyObject;
|
|
108
108
|
}
|
|
109
109
|
if (context.response) {
|
|
110
|
-
const { statusCode, headers, body, description, title } = context.response;
|
|
111
|
-
const responseContentType = headers['Content-Type'] || headers['content-type'];
|
|
110
|
+
const { statusCode, headers, body, description, title, entity } = context.response;
|
|
111
|
+
const responseContentType = headers && (headers['Content-Type'] || headers['content-type']);
|
|
112
112
|
if (body) {
|
|
113
113
|
if (Array.isArray(body)) {
|
|
114
114
|
let bodyObject;
|
|
@@ -119,7 +119,7 @@ function openApiDocFactory(openApiMethod, openApiRoute, context, openApiDocObjec
|
|
|
119
119
|
else {
|
|
120
120
|
bodyObject = { example: '' };
|
|
121
121
|
}
|
|
122
|
-
openApiDocObject.components.schemas[title] = bodyObject;
|
|
122
|
+
openApiDocObject.components.schemas[entity || title] = bodyObject;
|
|
123
123
|
openApiDocObject.paths[openApiRoute][openApiMethod].responses = {
|
|
124
124
|
[statusCode]: {
|
|
125
125
|
description,
|
|
@@ -128,7 +128,7 @@ function openApiDocFactory(openApiMethod, openApiRoute, context, openApiDocObjec
|
|
|
128
128
|
schema: {
|
|
129
129
|
type: 'array',
|
|
130
130
|
items: {
|
|
131
|
-
$ref: `#/components/schemas/${title}`,
|
|
131
|
+
$ref: `#/components/schemas/${entity || title}`,
|
|
132
132
|
},
|
|
133
133
|
},
|
|
134
134
|
},
|
|
@@ -145,14 +145,14 @@ function openApiDocFactory(openApiMethod, openApiRoute, context, openApiDocObjec
|
|
|
145
145
|
else {
|
|
146
146
|
bodyObject = { example: '' };
|
|
147
147
|
}
|
|
148
|
-
openApiDocObject.components.schemas[title] = bodyObject;
|
|
148
|
+
openApiDocObject.components.schemas[entity || title] = bodyObject;
|
|
149
149
|
openApiDocObject.paths[openApiRoute][openApiMethod].responses = {
|
|
150
150
|
[statusCode]: {
|
|
151
151
|
description,
|
|
152
152
|
content: {
|
|
153
153
|
[responseContentType]: {
|
|
154
154
|
schema: {
|
|
155
|
-
$ref: `#/components/schemas/${title}`,
|
|
155
|
+
$ref: `#/components/schemas/${entity || title}`,
|
|
156
156
|
},
|
|
157
157
|
},
|
|
158
158
|
},
|
|
@@ -174,5 +174,4 @@ function openApiDocFactory(openApiMethod, openApiRoute, context, openApiDocObjec
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
exports.openApiDocFactory = openApiDocFactory;
|
|
178
177
|
//# sourceMappingURL=open-api-doc-factory.js.map
|