expresso-macchiato 0.3.4 → 0.3.5
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +34 -28
- package/dist/index.mjs +35 -29
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -599,5 +599,6 @@ declare const fullLogNok: (service: string, error: any, ...args: any[]) => void;
|
|
|
599
599
|
declare const apiOk: (res: any, status?: number, contentType?: string) => ExpressReturn;
|
|
600
600
|
declare const apiNok: (err: any, status?: number) => ExpressReturn;
|
|
601
601
|
declare const errorCatcher: (res: Response$1, err: unknown, errorsList?: ErrorsMapping, errorString?: string) => void;
|
|
602
|
+
declare const getCompiledPath: (__filename: string, __dirname: string, pathsWithoutExtension: string[]) => string[];
|
|
602
603
|
|
|
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 };
|
|
604
|
+
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, getCompiledPath, log };
|
package/dist/index.d.ts
CHANGED
|
@@ -599,5 +599,6 @@ declare const fullLogNok: (service: string, error: any, ...args: any[]) => void;
|
|
|
599
599
|
declare const apiOk: (res: any, status?: number, contentType?: string) => ExpressReturn;
|
|
600
600
|
declare const apiNok: (err: any, status?: number) => ExpressReturn;
|
|
601
601
|
declare const errorCatcher: (res: Response$1, err: unknown, errorsList?: ErrorsMapping, errorString?: string) => void;
|
|
602
|
+
declare const getCompiledPath: (__filename: string, __dirname: string, pathsWithoutExtension: string[]) => string[];
|
|
602
603
|
|
|
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 };
|
|
604
|
+
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, getCompiledPath, log };
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
var _express = require('express'); var _express2 = _interopRequireDefault(_express);
|
|
3
3
|
|
|
4
4
|
// src/_utils.ts
|
|
5
|
+
var _path2 = require('path'); var _path3 = _interopRequireDefault(_path2);
|
|
5
6
|
var _utilsloggerav = require('utils-logger-av');
|
|
6
7
|
var MyLogger = class extends _utilsloggerav.Logger {
|
|
7
8
|
constructor() {
|
|
@@ -34,6 +35,10 @@ var errorCatcher = (res, err, errorsList, errorString) => {
|
|
|
34
35
|
if (!error) res.status(500).send({ message: err.message });
|
|
35
36
|
else res.status(_nullishCoalesce(error.status, () => ( 500))).send({ message: _nullishCoalesce(error.responseMessage, () => ( err.message)) });
|
|
36
37
|
};
|
|
38
|
+
var getCompiledPath = (__filename, __dirname, pathsWithoutExtension) => {
|
|
39
|
+
const isCompiled = __filename.endsWith(".js");
|
|
40
|
+
return pathsWithoutExtension.map((p) => _path3.default.join(__dirname, p + (isCompiled ? ".js" : ".ts")).replaceAll("\\", "/"));
|
|
41
|
+
};
|
|
37
42
|
|
|
38
43
|
// src/DynamicDbRouter.ts
|
|
39
44
|
var _typeorm = require('typeorm');
|
|
@@ -186,16 +191,16 @@ _Swagger.getBasicGet = (parameters) => ({
|
|
|
186
191
|
* - You can create the structure of a specified path and method, with a schema name that should be created elsewhere
|
|
187
192
|
*/
|
|
188
193
|
_Swagger.addSingleApiPath = (tag, basePath, _path, method, parameters, bodyObj, responses = {}) => {
|
|
189
|
-
const
|
|
194
|
+
const path3 = `${_Swagger.fromExpressParamsToSwagger(basePath)}${_Swagger.fromExpressParamsToSwagger(_path)}`;
|
|
190
195
|
const transcribedMethod = _Swagger.restMethodToSwaggerKeyMapping[method];
|
|
191
|
-
if (!_Swagger.apiDocument.paths[
|
|
192
|
-
if (_Swagger.apiDocument.paths[
|
|
193
|
-
_Swagger.apiDocument.paths[
|
|
196
|
+
if (!_Swagger.apiDocument.paths[path3]) _Swagger.apiDocument.paths[path3] = {};
|
|
197
|
+
if (_Swagger.apiDocument.paths[path3][transcribedMethod]) return;
|
|
198
|
+
_Swagger.apiDocument.paths[path3][transcribedMethod] = {
|
|
194
199
|
responses,
|
|
195
200
|
parameters,
|
|
196
201
|
tags: [tag]
|
|
197
202
|
};
|
|
198
|
-
if (bodyObj) _Swagger.apiDocument.paths[
|
|
203
|
+
if (bodyObj) _Swagger.apiDocument.paths[path3][transcribedMethod].requestBody = {
|
|
199
204
|
required: _nullishCoalesce(bodyObj.required, () => ( false)),
|
|
200
205
|
description: bodyObj.description,
|
|
201
206
|
content: {
|
|
@@ -217,9 +222,9 @@ _Swagger._addApiPath = (tag, basePath, options) => {
|
|
|
217
222
|
const finalPaths = {};
|
|
218
223
|
const finalSchemas = {};
|
|
219
224
|
for (const _path in options) {
|
|
220
|
-
const
|
|
225
|
+
const path3 = `${basePath}${_path}`;
|
|
221
226
|
if (_optionalChain([options, 'access', _3 => _3[_path], 'access', _4 => _4.get, 'optionalAccess', _5 => _5.tags])) options[_path].get.tags = [tag];
|
|
222
|
-
finalPaths[
|
|
227
|
+
finalPaths[path3] = {
|
|
223
228
|
get: options[_path].get,
|
|
224
229
|
$ref: options[_path].$ref,
|
|
225
230
|
head: options[_path].head,
|
|
@@ -227,7 +232,7 @@ _Swagger._addApiPath = (tag, basePath, options) => {
|
|
|
227
232
|
};
|
|
228
233
|
if (options[_path].get) options[_path].get.tags = [tag];
|
|
229
234
|
if (options[_path].post && options[_path].post.requestBody) {
|
|
230
|
-
finalPaths[
|
|
235
|
+
finalPaths[path3].post = {
|
|
231
236
|
responses: {},
|
|
232
237
|
parameters: options[_path].post.parameters,
|
|
233
238
|
tags: [tag],
|
|
@@ -245,7 +250,7 @@ _Swagger._addApiPath = (tag, basePath, options) => {
|
|
|
245
250
|
}
|
|
246
251
|
}
|
|
247
252
|
if (options[_path].put && options[_path].put.requestBody) {
|
|
248
|
-
finalPaths[
|
|
253
|
+
finalPaths[path3].put = {
|
|
249
254
|
responses: {},
|
|
250
255
|
tags: [tag],
|
|
251
256
|
parameters: options[_path].put.parameters,
|
|
@@ -263,7 +268,7 @@ _Swagger._addApiPath = (tag, basePath, options) => {
|
|
|
263
268
|
}
|
|
264
269
|
}
|
|
265
270
|
if (options[_path].delete) {
|
|
266
|
-
finalPaths[
|
|
271
|
+
finalPaths[path3].delete = {
|
|
267
272
|
responses: {},
|
|
268
273
|
tags: [tag],
|
|
269
274
|
parameters: options[_path].delete.parameters,
|
|
@@ -271,7 +276,7 @@ _Swagger._addApiPath = (tag, basePath, options) => {
|
|
|
271
276
|
};
|
|
272
277
|
if (options[_path].delete.requestBody) {
|
|
273
278
|
const finalComType = _nullishCoalesce(options[_path].delete.requestBody.comType, () => ( "application/json"));
|
|
274
|
-
finalPaths[
|
|
279
|
+
finalPaths[path3].delete.requestBody = {
|
|
275
280
|
required: options[_path].delete.requestBody.required,
|
|
276
281
|
description: options[_path].delete.requestBody.description,
|
|
277
282
|
content: {
|
|
@@ -286,11 +291,11 @@ _Swagger._addApiPath = (tag, basePath, options) => {
|
|
|
286
291
|
}
|
|
287
292
|
}
|
|
288
293
|
}
|
|
289
|
-
for (const
|
|
290
|
-
for (const method in finalPaths[
|
|
294
|
+
for (const path3 in finalPaths) {
|
|
295
|
+
for (const method in finalPaths[path3]) {
|
|
291
296
|
const methodKey = method;
|
|
292
|
-
if (!_Swagger.apiDocument.paths[
|
|
293
|
-
if (!_Swagger.apiDocument.paths[
|
|
297
|
+
if (!_Swagger.apiDocument.paths[path3]) _Swagger.apiDocument.paths[path3] = {};
|
|
298
|
+
if (!_Swagger.apiDocument.paths[path3][methodKey]) _Swagger.apiDocument.paths[path3][methodKey] = finalPaths[path3][methodKey];
|
|
294
299
|
}
|
|
295
300
|
}
|
|
296
301
|
for (const schema in finalSchemas) {
|
|
@@ -629,11 +634,11 @@ var RouterWrapper = class {
|
|
|
629
634
|
for (const schema in this.data.swaggerNewSchemas) Swagger.addSchema(schema, this.data.swaggerNewSchemas[schema].properties);
|
|
630
635
|
}
|
|
631
636
|
for (const _path in _nullishCoalesce(this.data.apis, () => ( {}))) {
|
|
632
|
-
const
|
|
633
|
-
if (!this.data.apis || !this.data.apis[
|
|
634
|
-
for (const method in this.data.apis[
|
|
635
|
-
if ((_nullishCoalesce(_optionalChain([this, 'access', _36 => _36.data, 'access', _37 => _37.apis, 'optionalAccess', _38 => _38[
|
|
636
|
-
const currentMethod = this.data.apis[
|
|
637
|
+
const path3 = _path.startsWith("/") ? _path : `/${_path}`;
|
|
638
|
+
if (!this.data.apis || !this.data.apis[path3]) continue;
|
|
639
|
+
for (const method in this.data.apis[path3]) {
|
|
640
|
+
if ((_nullishCoalesce(_optionalChain([this, 'access', _36 => _36.data, 'access', _37 => _37.apis, 'optionalAccess', _38 => _38[path3], 'optionalAccess', _39 => _39[method]]), () => ( void 0))) === void 0) continue;
|
|
641
|
+
const currentMethod = this.data.apis[path3][method];
|
|
637
642
|
const middlewares = _nullishCoalesce(currentMethod.middlewares, () => ( []));
|
|
638
643
|
const callBackFunction = async (req, res) => {
|
|
639
644
|
try {
|
|
@@ -644,18 +649,18 @@ var RouterWrapper = class {
|
|
|
644
649
|
} else if (typeof handlerRes.result === "object") res.status(handlerRes.status).json(handlerRes.result);
|
|
645
650
|
else res.status(handlerRes.status).send(handlerRes.result);
|
|
646
651
|
} catch (err) {
|
|
647
|
-
fullLogNok("api", `[${method}] ${
|
|
652
|
+
fullLogNok("api", `[${method}] ${path3} => ${_nullishCoalesce(err.message, () => ( err))}`);
|
|
648
653
|
res.status(500).send(_nullishCoalesce(_optionalChain([err, 'optionalAccess', _40 => _40.message]), () => ( err)));
|
|
649
654
|
}
|
|
650
655
|
};
|
|
651
|
-
if (method === "GET") newRouter.get(
|
|
652
|
-
else if (method === "POST") newRouter.post(
|
|
653
|
-
else if (method === "PUT") newRouter.put(
|
|
654
|
-
else if (method === "DELETE") newRouter.delete(
|
|
656
|
+
if (method === "GET") newRouter.get(path3, middlewares, callBackFunction);
|
|
657
|
+
else if (method === "POST") newRouter.post(path3, middlewares, callBackFunction);
|
|
658
|
+
else if (method === "PUT") newRouter.put(path3, middlewares, callBackFunction);
|
|
659
|
+
else if (method === "DELETE") newRouter.delete(path3, middlewares, callBackFunction);
|
|
655
660
|
Swagger.addSingleApiPath(
|
|
656
661
|
this.data.tag,
|
|
657
662
|
this.data.basePath,
|
|
658
|
-
|
|
663
|
+
path3,
|
|
659
664
|
method,
|
|
660
665
|
currentMethod.swaggerParameters,
|
|
661
666
|
currentMethod.swaggerBody,
|
|
@@ -687,7 +692,7 @@ var RouterWrapper = class {
|
|
|
687
692
|
// src/Starter.ts
|
|
688
693
|
|
|
689
694
|
var _http = require('http'); var _http2 = _interopRequireDefault(_http);
|
|
690
|
-
|
|
695
|
+
|
|
691
696
|
var _swaggeruiexpress = require('swagger-ui-express'); var _swaggeruiexpress2 = _interopRequireDefault(_swaggeruiexpress);
|
|
692
697
|
var Starter = class {
|
|
693
698
|
constructor(options) {
|
|
@@ -822,4 +827,5 @@ var Token = class {
|
|
|
822
827
|
|
|
823
828
|
|
|
824
829
|
|
|
825
|
-
|
|
830
|
+
|
|
831
|
+
exports.RouterWrapper = RouterWrapper; exports.Starter = Starter; exports.Swagger = Swagger; exports.Token = Token; exports.apiNok = apiNok; exports.apiOk = apiOk; exports.errorCatcher = errorCatcher; exports.fullLogNok = fullLogNok; exports.fullLogOk = fullLogOk; exports.getCompiledPath = getCompiledPath; exports.log = log;
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { Router } from "express";
|
|
3
3
|
|
|
4
4
|
// src/_utils.ts
|
|
5
|
+
import path from "path";
|
|
5
6
|
import { Logger } from "utils-logger-av";
|
|
6
7
|
var MyLogger = class extends Logger {
|
|
7
8
|
constructor() {
|
|
@@ -34,6 +35,10 @@ var errorCatcher = (res, err, errorsList, errorString) => {
|
|
|
34
35
|
if (!error) res.status(500).send({ message: err.message });
|
|
35
36
|
else res.status(error.status ?? 500).send({ message: error.responseMessage ?? err.message });
|
|
36
37
|
};
|
|
38
|
+
var getCompiledPath = (__filename2, __dirname2, pathsWithoutExtension) => {
|
|
39
|
+
const isCompiled = __filename2.endsWith(".js");
|
|
40
|
+
return pathsWithoutExtension.map((p) => path.join(__dirname2, p + (isCompiled ? ".js" : ".ts")).replaceAll("\\", "/"));
|
|
41
|
+
};
|
|
37
42
|
|
|
38
43
|
// src/DynamicDbRouter.ts
|
|
39
44
|
import { EntityMetadataNotFoundError, Equal, Like } from "typeorm";
|
|
@@ -186,16 +191,16 @@ _Swagger.getBasicGet = (parameters) => ({
|
|
|
186
191
|
* - You can create the structure of a specified path and method, with a schema name that should be created elsewhere
|
|
187
192
|
*/
|
|
188
193
|
_Swagger.addSingleApiPath = (tag, basePath, _path, method, parameters, bodyObj, responses = {}) => {
|
|
189
|
-
const
|
|
194
|
+
const path3 = `${_Swagger.fromExpressParamsToSwagger(basePath)}${_Swagger.fromExpressParamsToSwagger(_path)}`;
|
|
190
195
|
const transcribedMethod = _Swagger.restMethodToSwaggerKeyMapping[method];
|
|
191
|
-
if (!_Swagger.apiDocument.paths[
|
|
192
|
-
if (_Swagger.apiDocument.paths[
|
|
193
|
-
_Swagger.apiDocument.paths[
|
|
196
|
+
if (!_Swagger.apiDocument.paths[path3]) _Swagger.apiDocument.paths[path3] = {};
|
|
197
|
+
if (_Swagger.apiDocument.paths[path3][transcribedMethod]) return;
|
|
198
|
+
_Swagger.apiDocument.paths[path3][transcribedMethod] = {
|
|
194
199
|
responses,
|
|
195
200
|
parameters,
|
|
196
201
|
tags: [tag]
|
|
197
202
|
};
|
|
198
|
-
if (bodyObj) _Swagger.apiDocument.paths[
|
|
203
|
+
if (bodyObj) _Swagger.apiDocument.paths[path3][transcribedMethod].requestBody = {
|
|
199
204
|
required: bodyObj.required ?? false,
|
|
200
205
|
description: bodyObj.description,
|
|
201
206
|
content: {
|
|
@@ -217,9 +222,9 @@ _Swagger._addApiPath = (tag, basePath, options) => {
|
|
|
217
222
|
const finalPaths = {};
|
|
218
223
|
const finalSchemas = {};
|
|
219
224
|
for (const _path in options) {
|
|
220
|
-
const
|
|
225
|
+
const path3 = `${basePath}${_path}`;
|
|
221
226
|
if (options[_path].get?.tags) options[_path].get.tags = [tag];
|
|
222
|
-
finalPaths[
|
|
227
|
+
finalPaths[path3] = {
|
|
223
228
|
get: options[_path].get,
|
|
224
229
|
$ref: options[_path].$ref,
|
|
225
230
|
head: options[_path].head,
|
|
@@ -227,7 +232,7 @@ _Swagger._addApiPath = (tag, basePath, options) => {
|
|
|
227
232
|
};
|
|
228
233
|
if (options[_path].get) options[_path].get.tags = [tag];
|
|
229
234
|
if (options[_path].post && options[_path].post.requestBody) {
|
|
230
|
-
finalPaths[
|
|
235
|
+
finalPaths[path3].post = {
|
|
231
236
|
responses: {},
|
|
232
237
|
parameters: options[_path].post.parameters,
|
|
233
238
|
tags: [tag],
|
|
@@ -245,7 +250,7 @@ _Swagger._addApiPath = (tag, basePath, options) => {
|
|
|
245
250
|
}
|
|
246
251
|
}
|
|
247
252
|
if (options[_path].put && options[_path].put.requestBody) {
|
|
248
|
-
finalPaths[
|
|
253
|
+
finalPaths[path3].put = {
|
|
249
254
|
responses: {},
|
|
250
255
|
tags: [tag],
|
|
251
256
|
parameters: options[_path].put.parameters,
|
|
@@ -263,7 +268,7 @@ _Swagger._addApiPath = (tag, basePath, options) => {
|
|
|
263
268
|
}
|
|
264
269
|
}
|
|
265
270
|
if (options[_path].delete) {
|
|
266
|
-
finalPaths[
|
|
271
|
+
finalPaths[path3].delete = {
|
|
267
272
|
responses: {},
|
|
268
273
|
tags: [tag],
|
|
269
274
|
parameters: options[_path].delete.parameters,
|
|
@@ -271,7 +276,7 @@ _Swagger._addApiPath = (tag, basePath, options) => {
|
|
|
271
276
|
};
|
|
272
277
|
if (options[_path].delete.requestBody) {
|
|
273
278
|
const finalComType = options[_path].delete.requestBody.comType ?? "application/json";
|
|
274
|
-
finalPaths[
|
|
279
|
+
finalPaths[path3].delete.requestBody = {
|
|
275
280
|
required: options[_path].delete.requestBody.required,
|
|
276
281
|
description: options[_path].delete.requestBody.description,
|
|
277
282
|
content: {
|
|
@@ -286,11 +291,11 @@ _Swagger._addApiPath = (tag, basePath, options) => {
|
|
|
286
291
|
}
|
|
287
292
|
}
|
|
288
293
|
}
|
|
289
|
-
for (const
|
|
290
|
-
for (const method in finalPaths[
|
|
294
|
+
for (const path3 in finalPaths) {
|
|
295
|
+
for (const method in finalPaths[path3]) {
|
|
291
296
|
const methodKey = method;
|
|
292
|
-
if (!_Swagger.apiDocument.paths[
|
|
293
|
-
if (!_Swagger.apiDocument.paths[
|
|
297
|
+
if (!_Swagger.apiDocument.paths[path3]) _Swagger.apiDocument.paths[path3] = {};
|
|
298
|
+
if (!_Swagger.apiDocument.paths[path3][methodKey]) _Swagger.apiDocument.paths[path3][methodKey] = finalPaths[path3][methodKey];
|
|
294
299
|
}
|
|
295
300
|
}
|
|
296
301
|
for (const schema in finalSchemas) {
|
|
@@ -629,11 +634,11 @@ var RouterWrapper = class {
|
|
|
629
634
|
for (const schema in this.data.swaggerNewSchemas) Swagger.addSchema(schema, this.data.swaggerNewSchemas[schema].properties);
|
|
630
635
|
}
|
|
631
636
|
for (const _path in this.data.apis ?? {}) {
|
|
632
|
-
const
|
|
633
|
-
if (!this.data.apis || !this.data.apis[
|
|
634
|
-
for (const method in this.data.apis[
|
|
635
|
-
if ((this.data.apis?.[
|
|
636
|
-
const currentMethod = this.data.apis[
|
|
637
|
+
const path3 = _path.startsWith("/") ? _path : `/${_path}`;
|
|
638
|
+
if (!this.data.apis || !this.data.apis[path3]) continue;
|
|
639
|
+
for (const method in this.data.apis[path3]) {
|
|
640
|
+
if ((this.data.apis?.[path3]?.[method] ?? void 0) === void 0) continue;
|
|
641
|
+
const currentMethod = this.data.apis[path3][method];
|
|
637
642
|
const middlewares = currentMethod.middlewares ?? [];
|
|
638
643
|
const callBackFunction = async (req, res) => {
|
|
639
644
|
try {
|
|
@@ -644,18 +649,18 @@ var RouterWrapper = class {
|
|
|
644
649
|
} else if (typeof handlerRes.result === "object") res.status(handlerRes.status).json(handlerRes.result);
|
|
645
650
|
else res.status(handlerRes.status).send(handlerRes.result);
|
|
646
651
|
} catch (err) {
|
|
647
|
-
fullLogNok("api", `[${method}] ${
|
|
652
|
+
fullLogNok("api", `[${method}] ${path3} => ${err.message ?? err}`);
|
|
648
653
|
res.status(500).send(err?.message ?? err);
|
|
649
654
|
}
|
|
650
655
|
};
|
|
651
|
-
if (method === "GET") newRouter.get(
|
|
652
|
-
else if (method === "POST") newRouter.post(
|
|
653
|
-
else if (method === "PUT") newRouter.put(
|
|
654
|
-
else if (method === "DELETE") newRouter.delete(
|
|
656
|
+
if (method === "GET") newRouter.get(path3, middlewares, callBackFunction);
|
|
657
|
+
else if (method === "POST") newRouter.post(path3, middlewares, callBackFunction);
|
|
658
|
+
else if (method === "PUT") newRouter.put(path3, middlewares, callBackFunction);
|
|
659
|
+
else if (method === "DELETE") newRouter.delete(path3, middlewares, callBackFunction);
|
|
655
660
|
Swagger.addSingleApiPath(
|
|
656
661
|
this.data.tag,
|
|
657
662
|
this.data.basePath,
|
|
658
|
-
|
|
663
|
+
path3,
|
|
659
664
|
method,
|
|
660
665
|
currentMethod.swaggerParameters,
|
|
661
666
|
currentMethod.swaggerBody,
|
|
@@ -687,7 +692,7 @@ var RouterWrapper = class {
|
|
|
687
692
|
// src/Starter.ts
|
|
688
693
|
import express from "express";
|
|
689
694
|
import http from "http";
|
|
690
|
-
import
|
|
695
|
+
import path2 from "path";
|
|
691
696
|
import swaggerUi from "swagger-ui-express";
|
|
692
697
|
var Starter = class {
|
|
693
698
|
constructor(options) {
|
|
@@ -713,14 +718,14 @@ var Starter = class {
|
|
|
713
718
|
}
|
|
714
719
|
if (options.tokenOptions) DynamicDbRouter.setTokenInstance(options.tokenOptions.tokenInstance);
|
|
715
720
|
if (options.clientPath) {
|
|
716
|
-
const clientPath =
|
|
721
|
+
const clientPath = path2.resolve(process.cwd(), "client");
|
|
717
722
|
app.use(express.static(clientPath));
|
|
718
723
|
app.get("/apiUrl", (_, res) => res.send(options.projectConfig.API_URL));
|
|
719
724
|
if (options.tokenOptions?.api) {
|
|
720
725
|
app.get(options.tokenOptions.api.path ?? "/api/auth", options.tokenOptions.api.callback);
|
|
721
726
|
}
|
|
722
727
|
app.get("*", (_, res) => {
|
|
723
|
-
res.sendFile(
|
|
728
|
+
res.sendFile(path2.join(clientPath, "index.html"));
|
|
724
729
|
});
|
|
725
730
|
}
|
|
726
731
|
if (options.socket === void 0 || options.socket === false) {
|
|
@@ -821,5 +826,6 @@ export {
|
|
|
821
826
|
errorCatcher,
|
|
822
827
|
fullLogNok,
|
|
823
828
|
fullLogOk,
|
|
829
|
+
getCompiledPath,
|
|
824
830
|
log
|
|
825
831
|
};
|