Skip to content

Commit

Permalink
fix(dao): json.parse instead of deserialize to support minification
Browse files Browse the repository at this point in the history
  • Loading branch information
uladkasach committed Jul 28, 2023
1 parent b3a43d8 commit 57f4731
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/logic/emit/asyncTask/daoTaskEmitToRemote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ const findByUnique: AsyncTaskEmitToRemoteDao['findByUnique'] = async ({
const cacheKey = getCacheKey({ endpoint, payload });
const cachedValue = await cache.get(cacheKey);
if (!cachedValue) return null;
return deserialize(cachedValue, { with: [AsyncTaskEmitToRemote] }) ?? null;
return new AsyncTaskEmitToRemote(
JSON.parse(cachedValue),
) as HasMetadata<AsyncTaskEmitToRemote>;
};

/**
Expand All @@ -54,10 +56,11 @@ const findAllByStatus: AsyncTaskEmitToRemoteDao['findAllByStatus'] = async ({
const keysAll = await cache.keys();
const tasksAll = (await Promise.all(keysAll.map((key) => cache.get(key))))
.filter(isPresent)
.map((taskJSON) =>
deserialize<HasMetadata<AsyncTaskEmitToRemote>>(taskJSON, {
with: [AsyncTaskEmitToRemote],
}),
.map(
(taskJSON) =>
new AsyncTaskEmitToRemote(
JSON.parse(taskJSON),
) as HasMetadata<AsyncTaskEmitToRemote>,
);
const tasksMatching = tasksAll.filter((task) => status.includes(task.status));
return tasksMatching;
Expand Down

0 comments on commit 57f4731

Please sign in to comment.