diff --git a/dist/lib/index.d.ts b/dist/lib/index.d.ts index 9163e61..65127e4 100644 --- a/dist/lib/index.d.ts +++ b/dist/lib/index.d.ts @@ -1,3 +1,3 @@ export { LoggedRoute, LoggedFunction, LoggedController, LoggedInjectable, } from "./logged"; export { ScopedLogger } from "./logger"; -export { InjectLogger, LoggedParam, LoggedHeaders, LoggedBody, LoggedQuery, Returns } from "./reflected"; +export { InjectLogger, LoggedParam, LoggedHeaders, LoggedBody, LoggedQuery, Logged, Returns } from "./reflected"; diff --git a/dist/lib/index.js b/dist/lib/index.js index 8395f47..9300571 100644 --- a/dist/lib/index.js +++ b/dist/lib/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Returns = exports.LoggedQuery = exports.LoggedBody = exports.LoggedHeaders = exports.LoggedParam = exports.InjectLogger = exports.ScopedLogger = exports.LoggedInjectable = exports.LoggedController = exports.LoggedFunction = exports.LoggedRoute = void 0; +exports.Returns = exports.Logged = exports.LoggedQuery = exports.LoggedBody = exports.LoggedHeaders = exports.LoggedParam = exports.InjectLogger = exports.ScopedLogger = exports.LoggedInjectable = exports.LoggedController = exports.LoggedFunction = exports.LoggedRoute = void 0; var logged_1 = require("./logged"); Object.defineProperty(exports, "LoggedRoute", { enumerable: true, get: function () { return logged_1.LoggedRoute; } }); Object.defineProperty(exports, "LoggedFunction", { enumerable: true, get: function () { return logged_1.LoggedFunction; } }); @@ -14,4 +14,5 @@ Object.defineProperty(exports, "LoggedParam", { enumerable: true, get: function Object.defineProperty(exports, "LoggedHeaders", { enumerable: true, get: function () { return reflected_1.LoggedHeaders; } }); Object.defineProperty(exports, "LoggedBody", { enumerable: true, get: function () { return reflected_1.LoggedBody; } }); Object.defineProperty(exports, "LoggedQuery", { enumerable: true, get: function () { return reflected_1.LoggedQuery; } }); +Object.defineProperty(exports, "Logged", { enumerable: true, get: function () { return reflected_1.Logged; } }); Object.defineProperty(exports, "Returns", { enumerable: true, get: function () { return reflected_1.Returns; } }); diff --git a/dist/lib/logged.js b/dist/lib/logged.js index 2486ae7..af28533 100644 --- a/dist/lib/logged.js +++ b/dist/lib/logged.js @@ -107,11 +107,13 @@ function overrideBuild(originalFunction, baseLogger, metadatas, key, returnsData .filter((v) => v.length > 0) .join(", ") : "" - : returnsData - ? typeof r === "object" - ? "WITH " + JSON.stringify(r) - : "WITH " + r - : ""; + : typeof returnsData === 'string' + ? "WITH " + returnsData + "=" + typeof r === "object" ? JSON.stringify(r) : r + : returnsData + ? typeof r === "object" + ? "WITH " + JSON.stringify(r) + : "WITH " + r + : ""; injectedLogger.log(route ? `RETURNED HTTP ${route.fullRoute} (${key}) ${resultLogged}` : `RETURNED ${key} ${resultLogged}`); diff --git a/dist/lib/reflected.d.ts b/dist/lib/reflected.d.ts index 4fece1a..ea9ec17 100644 --- a/dist/lib/reflected.d.ts +++ b/dist/lib/reflected.d.ts @@ -42,5 +42,5 @@ export declare function LoggedBody(property: string, ...pipes: Pipe[]): LoggedPa export declare function LoggedHeaders(property?: string): LoggedParamReturns; export declare function Returns, R>(namePaths?: { [name: string]: string; -}): (_target: any, _key: string | symbol, descriptor: TypedPropertyDescriptor<(...args: F) => Promise>) => void; +} | string): (_target: any, _key: string | symbol, descriptor: TypedPropertyDescriptor<(...args: F) => Promise | R>) => void; export {}; diff --git a/dist/lib/reflected.js b/dist/lib/reflected.js index 6d768fa..362423b 100644 --- a/dist/lib/reflected.js +++ b/dist/lib/reflected.js @@ -84,7 +84,9 @@ exports.LoggedHeaders = LoggedHeaders; function Returns(namePaths) { return (_target, _key, descriptor) => { Reflect.defineMetadata(exports.returns, namePaths - ? Object.entries(namePaths).reduce((prev, curr) => [...prev, { name: curr[0], path: curr[1] }], []) + ? typeof namePaths === 'string' + ? namePaths + : Object.entries(namePaths).reduce((prev, curr) => [...prev, { name: curr[0], path: curr[1] }], []) : true, descriptor.value); }; }