Skip to content

Commit 3502bc7

Browse files
committed
feat: deploy to infura.io besides pinata.cloud
1 parent 4335458 commit 3502bc7

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

β€ŽREADME.mdβ€Ž

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ control.
2626

2727
## Background
2828

29-
So far, ipfs-deploy relies on [Pinata.cloud](https://pinata.cloud) as the
30-
pinning service and [Cloudflare](https://cloudflare.com) as the DNS provider
31-
and IPFS gateway. Hopefully those will be configurable in the future.
29+
So far, ipfs-deploy relies on [Pinata.cloud](https://pinata.cloud) and
30+
[Infura.io](https://infura.io) as the pinning services and
31+
[Cloudflare](https://cloudflare.com) as the DNS provider. Hopefully those will
32+
be configurable in the future.
3233

3334
Cloudflare doesn't host the content itself, so Pinata is needed if you don't
3435
want to rely on your computer's IPFS daemon's availability to serve your
@@ -58,6 +59,8 @@ and:
5859

5960
https://pinata.cloud/documentation#GettingStarted
6061

62+
(Infura doesn't require creating an account.)
63+
6164
Then copy over `.env.sample` to `.env` and fill out your credentials:
6265

6366
```

β€Žindex.jsβ€Ž

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const IPFSFactory = require('ipfsd-ctl')
22
const which = require('which')
33
const clipboardy = require('clipboardy')
44
const pinataSDK = require('@pinata/sdk')
5+
const got = require('got')
56
const updateCloudflareDnslink = require('dnslink-cloudflare')
67
const ora = require('ora')
78

@@ -49,14 +50,14 @@ async function main() {
4950

5051
const spinner = ora()
5152
spinner.start()
52-
spinner.info('☎️Connecting to local IPFS daemon...')
53+
spinner.info('☎️ Connecting to local IPFS daemon...')
5354

5455
df.spawn({ disposable: false, init: false, start: false }, (err, ipfsd) => {
5556
if (err) throw err
5657

5758
ipfsd.start([], (err2, ipfsClient) => {
5859
if (err2) throw err2
59-
spinner.succeed('πŸ“Ά Connected.')
60+
spinner.succeed('πŸ“Ά Connected.')
6061

6162
spinner.info('πŸ’Ύ Adding and pinning ./public/ locally...')
6263
ipfsClient.addFromFs(
@@ -66,7 +67,7 @@ async function main() {
6667
if (err3) throw err3
6768

6869
const { hash } = localPinResult[localPinResult.length - 1]
69-
spinner.succeed(`#️⃣ Added locally as ${hash}.`)
70+
spinner.succeed(`πŸ”— Added locally as ${hash}.`)
7071

7172
ipfsClient.id((err4, { addresses }) => {
7273
if (err4) throw err4
@@ -93,12 +94,28 @@ async function main() {
9394
process.env.PINATA_SECRET_API_KEY
9495
)
9596

96-
spinner.info('πŸ“  Requesting remote pin to Pinata.cloud...')
97+
spinner.info('πŸ“  Requesting remote pin to pinata.cloud...')
9798
pinata
9899
.pinHashToIPFS(hash, pinataOptions)
99-
.then(_pinataPinResult => {
100+
.then(async _pinataPinResult => {
100101
spinner.succeed("πŸ“Œ It's pinned to Pinata now.")
101102

103+
try {
104+
spinner.info('πŸ“  Requesting remote pin to infura.io...')
105+
const infuraResponse = await got(
106+
`https://ipfs.infura.io:5001/api/v0/pin/add?arg=${hash}` +
107+
'&recursive=true'
108+
)
109+
110+
if (infuraResponse.statusCode === 200) {
111+
spinner.succeed("πŸ“Œ It's pinned to Infura now.")
112+
} else {
113+
spinner.fail("Pinning to Infura didn't work.")
114+
}
115+
} catch (e) {
116+
console.error(e)
117+
}
118+
102119
clipboardy.writeSync(hash)
103120
spinner.succeed(`πŸ“‹ Hash ${hash} copied to clipboard.`)
104121

0 commit comments

Comments
Β (0)