Skip to content

Commit af97aab

Browse files
refactor(ipfs): remove default node/gateway, use SDK config
1 parent 67cae09 commit af97aab

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/utils/ipfs-service.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { create } from 'kubo-rpc-client';
2-
import { IPFS_UPLOAD_URL, DEFAULT_IPFS_GATEWAY } from '../config/config.js';
32

43
interface GetOptions {
54
ipfsGateway?: string;
@@ -8,10 +7,7 @@ interface AddOptions extends GetOptions {
87
ipfsNode?: string;
98
}
109

11-
const get = async (
12-
cid,
13-
{ ipfsGateway = DEFAULT_IPFS_GATEWAY }: GetOptions = {}
14-
) => {
10+
const get = async (cid, { ipfsGateway }: GetOptions = {}) => {
1511
const multiaddr = `/ipfs/${cid.toString()}`;
1612
const publicUrl = `${ipfsGateway}${multiaddr}`;
1713
const res = await fetch(publicUrl);
@@ -22,13 +18,7 @@ const get = async (
2218
return new Uint8Array(arrayBuffer);
2319
};
2420

25-
const add = async (
26-
content,
27-
{
28-
ipfsNode = IPFS_UPLOAD_URL,
29-
ipfsGateway = DEFAULT_IPFS_GATEWAY,
30-
}: AddOptions = {}
31-
) => {
21+
const add = async (content, { ipfsNode, ipfsGateway }: AddOptions = {}) => {
3222
const ipfsClient = create(ipfsNode);
3323
const { cid } = await ipfsClient.add(content);
3424
await get(cid.toString(), { ipfsGateway });

0 commit comments

Comments
 (0)