From 93d10a1f9ec02313712b585f4b7c93dbf9c3178b Mon Sep 17 00:00:00 2001 From: John Kalberer Date: Sat, 23 Mar 2024 12:00:12 -0700 Subject: [PATCH] Fixing APIs --- src/RouteConfig.ts | 1 + src/repository/MongoDb.ts | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/RouteConfig.ts b/src/RouteConfig.ts index 89010169..29f3b9bd 100644 --- a/src/RouteConfig.ts +++ b/src/RouteConfig.ts @@ -193,6 +193,7 @@ export default ( error as unknown as string | Error | HttpError, ); response.status(httpError.status).json({ + ...httpError, error: httpError.message, ok: false, }); diff --git a/src/repository/MongoDb.ts b/src/repository/MongoDb.ts index 712bc921..acdf1a62 100644 --- a/src/repository/MongoDb.ts +++ b/src/repository/MongoDb.ts @@ -128,16 +128,17 @@ class MongoDb< findOne = async ( collectionName: string, query?: Record, - ): Promise => + ): Promise => this.__runForCollection( collectionName, - async (collection: Collection): Promise => { + async (collection: Collection): Promise => { const resultItem = await collection.findOne( this.__translateQuery(query), ); - return nullthrows( - this.__translateResultItem(resultItem as unknown as TEntity), + return ( + this.__translateResultItem(resultItem as unknown as TEntity) ?? + undefined ); }, );