Skip to content

Commit

Permalink
use cache module
Browse files Browse the repository at this point in the history
  • Loading branch information
guitavano committed Mar 3, 2025
1 parent 59777af commit 639d3db
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions website/loaders/secret.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface Props {
*/
name?: string;
}

const moduleCache: Record<string, Promise<string | null>> = {};
const showWarningOnce = once(() => {
console.warn(
colors.brightYellow(
Expand All @@ -47,7 +47,7 @@ const getSecret = async (props: Props): Promise<string | null> => {
await showWarningOnce();
return Promise.resolve(null);
}
return decryptFromHex(encrypted).then((d) => d.decrypted)
return moduleCache[encrypted] ??= decryptFromHex(encrypted).then((d) => d.decrypted)
.catch((err) => {
const prettyName = name ? colors.brightRed(name) : "anonymous secret";
console.error(
Expand Down

0 comments on commit 639d3db

Please sign in to comment.