Skip to content

Commit 53f83c9

Browse files
authored
Merge pull request #10 from kankje/remove-cache
Remove unbounded Map cache to prevent memory leaks
2 parents 2ad29da + 4b179c0 commit 53f83c9

File tree

7 files changed

+9
-79
lines changed

7 files changed

+9
-79
lines changed

.changeset/calm-birds-start.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@imgproxy/imgproxy-node": minor
3+
---
4+
5+
Remove unbounded Map cache to prevent memory leaks. Thanks @kankje!

src/utils/getEncryptedUrl.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import { getEncryptedUrl } from "./getEncryptedUrl";
2+
import getEncryptedUrl from "./getEncryptedUrl";
33

44
describe("getEncryptedUrl", () => {
55
it("should return a valid encrypted URL", () => {

src/utils/getEncryptedUrl.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import crypto from "crypto";
22
import { ICryptPair } from "../types.js";
33
import bufferToBase64 from "./bufferToBase64.js";
4-
import withCache from "./withCache.js";
54

65
const getEncryptedUrl = (url: string, pair: ICryptPair): string => {
76
const bufferKey = Buffer.from(pair.key, "hex");
@@ -17,7 +16,4 @@ const getEncryptedUrl = (url: string, pair: ICryptPair): string => {
1716
return bufferToBase64(Buffer.concat([iv, encrypted]));
1817
};
1918

20-
const withCacheGetEncryptedUrl = withCache(getEncryptedUrl);
21-
22-
export default withCacheGetEncryptedUrl;
23-
export { getEncryptedUrl };
19+
export default getEncryptedUrl;

src/utils/getSignedUrl.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vitest";
2-
import { getSignedUrl } from "./getSignedUrl";
2+
import getSignedUrl from "./getSignedUrl";
33

44
describe("getSignedUrl", () => {
55
it("should return a signed url with options if salt and key are provided", () => {

src/utils/getSignedUrl.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import crypto from "crypto";
22
import type { ISignPair } from "../types";
3-
import withCache from "./withCache.js";
43

54
const hexDecode = (hex: string): Buffer => Buffer.from(hex, "hex");
65

@@ -17,7 +16,4 @@ const getSignedUrl = (path: string, pair: ISignPair): string => {
1716
return `/${signature}${path}`;
1817
};
1918

20-
const withCacheGetSignedUrl = withCache(getSignedUrl);
21-
22-
export default withCacheGetSignedUrl;
23-
export { getSignedUrl };
19+
export default getSignedUrl;

src/utils/withCache.test.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/utils/withCache.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)