diff --git a/src/logged.ts b/src/logged.ts index 3f9f541..e4fc79b 100644 --- a/src/logged.ts +++ b/src/logged.ts @@ -126,7 +126,7 @@ function overrideBuild, R>( baseLogger: Logger, metadatas: FunctionMetadata, key: string, - returnsData: ReturnsReflectData[] | true, + returnsData: ReturnsReflectData[] | string | true, route?: { fullRoute: string; } @@ -196,11 +196,13 @@ function overrideBuild, R>( .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 diff --git a/src/reflected.ts b/src/reflected.ts index 9daa727..8b3216d 100644 --- a/src/reflected.ts +++ b/src/reflected.ts @@ -230,19 +230,21 @@ export function LoggedHeaders(property?: string): LoggedParamReturns { export function Returns, R>(namePaths?: { [name: string]: string; -}) { +} | string) { return ( _target: any, _key: string | symbol, - descriptor: TypedPropertyDescriptor<(...args: F) => Promise> + descriptor: TypedPropertyDescriptor<(...args: F) => Promise | R> ) => { Reflect.defineMetadata( 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 );