Skip to content

Commit d871740

Browse files
committed
update release 1.1.0
1 parent 8725a4a commit d871740

File tree

8 files changed

+6264
-23
lines changed

8 files changed

+6264
-23
lines changed

.github/workflows/release.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v2
13+
14+
- name: Set up Node.js
15+
uses: actions/setup-node@v2
16+
with:
17+
node-version: '22' # specify node version 22
18+
registry-url: 'https://registry.npmjs.org/'
19+
20+
# Install dependencies
21+
- name: Install dependencies
22+
run: npm install
23+
24+
# Build the project
25+
- name: Build the project
26+
run: npm run build
27+
28+
# Testung the project
29+
- name: Testing the project
30+
run: npm run test
31+
32+
- name: Publish package
33+
env:
34+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
35+
run: npm publish

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
node_modules
2-
yarn.lock
3-
package-lock.json
42
dist
53
coverage.data
64
coverage

lib/index.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import axios from 'axios';
2+
import https from 'https';
23

34
const gateways: string[] = [
45
'https://ipfs.io/ipfs/{hash}',
@@ -11,8 +12,14 @@ const gateways: string[] = [
1112
'https://{hash}.ipfs.cf-ipfs.com',
1213
'https://{hash}.ipfs.4everland.io',
1314
'https://{hash}.ipfs.gw3.io',
15+
'https://gateway.pinata.cloud/ipfs/{hash}',
16+
'https://ipfs.quicknode.com/ipfs/{hash}',
1417
];
1518

19+
const agent = new https.Agent({
20+
rejectUnauthorized: true,
21+
});
22+
1623
export const getAllGateway = (ipfsUrl: string): string[] => {
1724
const finalUrl: string[] = [];
1825
const getHash = ipfsUrl.replace('ipfs://', '');
@@ -31,10 +38,10 @@ export const getAllGateway = (ipfsUrl: string): string[] => {
3138
return finalUrl;
3239
};
3340

34-
export const getLiveGateway = async (
41+
export const getAllLiveGateway = async (
3542
ipfsUrl: string,
3643
timeout?: number
37-
): Promise<string> => {
44+
): Promise<string[]> => {
3845
const listLoop: unknown[] = [];
3946
const finalUrl: string[] = [];
4047
const getHash = ipfsUrl.replace('ipfs://', '');
@@ -48,7 +55,9 @@ export const getLiveGateway = async (
4855
}
4956

5057
finalUrl.push(url);
51-
listLoop.push(axios.head(url, { timeout: timeout || 5000 }));
58+
listLoop.push(
59+
axios.head(url, { httpsAgent: agent, timeout: timeout || 3000 })
60+
);
5261
});
5362

5463
const result = await Promise.allSettled(listLoop);
@@ -60,6 +69,17 @@ export const getLiveGateway = async (
6069
}
6170
}
6271

72+
return fullfilled;
73+
};
74+
75+
export const getLiveGateway = async (
76+
ipfsUrl: string,
77+
timeout?: number
78+
): Promise<string> => {
79+
const finalUrl = getAllGateway(ipfsUrl);
80+
const rto = timeout || 5000;
81+
const fullfilled: string[] = await getAllLiveGateway(ipfsUrl, rto);
82+
6383
if (fullfilled.length > 0) {
6484
return fullfilled[0];
6585
} else {

0 commit comments

Comments
 (0)