Skip to content

Commit

Permalink
Fixing APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
jlkalberer committed Mar 23, 2024
1 parent 9c876bf commit 93d10a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/RouteConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export default (
error as unknown as string | Error | HttpError,
);
response.status(httpError.status).json({
...httpError,
error: httpError.message,
ok: false,
});
Expand Down
9 changes: 5 additions & 4 deletions src/repository/MongoDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,17 @@ class MongoDb<
findOne = async (
collectionName: string,
query?: Record<string, unknown>,
): Promise<TEntity> =>
): Promise<TEntity | undefined> =>
this.__runForCollection(
collectionName,
async (collection: Collection): Promise<TEntity> => {
async (collection: Collection): Promise<TEntity | undefined> => {
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
);
},
);
Expand Down

0 comments on commit 93d10a1

Please sign in to comment.