-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(migrate-to-w3up): refactor and cleanup to be used as library
- Loading branch information
1 parent
ffe5c03
commit d7587fd
Showing
17 changed files
with
121 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * as w32023ToW3up from "./w32023-to-w3up.js" | ||
export * as NFTStorage from './classic-nft.storage.js' | ||
export * as OldWeb3Storage from './old-web3.storage.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Web3Storage } from "web3.storage" | ||
import { W32023Upload } from "../src/w32023.js"; | ||
|
||
const API = 'https://api.web3.storage' | ||
|
||
/** | ||
* get a stream of w32023 uploads via | ||
* interactive prompts using inquirer | ||
* + old web3.storage client library | ||
* @param {object} options - options | ||
* @param {string} [options.api] - optional API endpoint override | ||
* @param {string} options.token | ||
* @returns {AsyncIterable<W32023Upload> & { length: Promise<number> }} uploads | ||
*/ | ||
export function getUploads({ | ||
api = API, | ||
token | ||
}) { | ||
if (!token) { | ||
throw new Error('! run `nft token` to set an API token to use') | ||
} | ||
const endpoint = new URL(api) | ||
if (api !== API) { | ||
// note if we're using something other than prod. | ||
console.info(`using ${endpoint.hostname}`) | ||
} | ||
const oldW3 = new Web3Storage({ token, endpoint }) | ||
const uploads = (async function* () { | ||
for await (const u of oldW3.list()) { | ||
if (u) { | ||
yield new W32023Upload(u) | ||
} | ||
} | ||
}()) | ||
// get count | ||
const userUploadsResponse = fetch(`${api}/user/uploads`, { | ||
headers: { authorization: `Bearer ${token}` }, | ||
}) | ||
const count = userUploadsResponse.then(r => parseInt(r.headers.get('count'), 10)).then(c => isNaN(c) ? undefined : c) | ||
return Object.assign(uploads, { length: count }) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters