GithubHelp home page GithubHelp logo

salespaulo / nft.storage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nftstorage/nft.storage

0.0 1.0 0.0 4.78 MB

Free decentralized storage and bandwidth for NFTs on IPFS and Filecoin BETA.

Home Page: https://nft.storage

License: Other

JavaScript 95.54% CSS 0.66% TypeScript 1.64% HTML 0.87% Shell 1.30%

nft.storage's Introduction

Free decentralized storage and bandwidth for NFTs on IPFS and Filecoin BETA.

nft.storage screenshot

Table of Contents

Client Libraries

The JS client library is the official and supported client to nft.storage. Other libraries listed have been generated from the OpenAPI schema and are experimental, unsupported and may not work at all!

  • JavaScript
  • Go (Generated from OpenAPI schema)
  • Java (Generated from OpenAPI schema)
  • PHP (Generated from OpenAPI schema)
  • Python (Generated from OpenAPI schema)
  • Ruby (Generated from OpenAPI schema)
  • Rust (Generated from OpenAPI schema)

HTTP API

Check out the HTTP API documentation.

Development

# install all dependencies in the mono-repo
yarn

# setup git hooks
npx simple-git-hooks

site Setup

Local env vars

Inside the site folder create a file called .env.local with the following content.

SENTRY_TOKEN=<sentry user auth token>
SENTRY_UPLOAD=false # toggle for sentry source/sourcemaps upload (capture will still work)

Production vars should set in Github Actions secrets.

Cloudflare Workers CLI

yarn global add @cloudflare/wrangler
wrangler login
# when using personal accounts you may need to manually change the `account_id` inside `wrangler.toml`

Magic.link account

Go to magic.link and create an account. Create two applications one for dev and another for production. In the "settings" of each application you will find the secrets needed to complete the initial setup.

IPFS Cluster

The nft.storage site talks to IPFS Cluster. You need to run a cluster locally and make it accessible from the internet for development.

Follow the quickstart guide to get an IPFS Cluster up and running: https://cluster.ipfs.io/documentation/quickstart/

Expose the IPFS Proxy by opening the docker-compose.yml file and add:

CLUSTER_IPFSPROXY_NODEMULTIADDRESS: /dns4/ipfs0/tcp/5001
CLUSTER_IPFSPROXY_LISTENMULTIADDRESS: /ip4/0.0.0.0/tcp/9095

...to the custer0 environment and add:

- '127.0.0.1:9095:9095'

...to the cluster0 ports. Then restart for the changes to take effect.

Install localtunnel and expose the IPFS Cluster HTTP API and IPFS Proxy API (replacing "USER" with your name):

npm install -g localtunnel
lt --port 9094 --subdomain USER-cluster-api-nft-storage
lt --port 9095 --subdomain USER-ipfs-proxy-api-nft-storage

These two URLs should be used for CLUSTER_API_URL and CLUSTER_IPFS_PROXY_API_URL in the wrangler.toml (see below).

There is an npm script you can use to quickly establish these tunnels during development:

npm run lt

Cloudflare Workers initial setup:

This only needs to be run once when setting up from scratch.

Development Setup

Open wrangler.toml and add an env for yourself (replacing "USER" with your name and "CF_ACCOUNT" with your Cloudflare account):

[env.USER]
type = "webpack"
name = "nft-storage-USER"
account_id = "CF_ACCOUNT"
workers_dev = true
route = ""
zone_id = ""
vars = { ENV = "dev", DEBUG = "*", CLUSTER_API_URL = "", CLUSTER_IPFS_PROXY_API_URL = "" }
kv_namespaces = []

Additionally, fill in the CLUSTER_API_URL and CLUSTER_IPFS_PROXY_API_URL with the localtunnel URLs you obtained when setting up the IPFS Cluster.

cd site
yarn install
# dev and preview KVs
wrangler kv:namespace create USERS --preview --env USER
# cli output something like: `{ binding = "USERS", preview_id = "7e441603d1bc4d5a87f6cecb959018e4" }`
# but you need to put `{ binding = "USERS", preview_id = "7e441603d1bc4d5a87f6cecb959018e4", id = "7e441603d1bc4d5a87f6cecb959018e4" }` inside the `kv_namespaces`.
wrangler kv:namespace create NFTS --preview --env USER
# same as above
wrangler kv:namespace create NFTS_IDX --preview --env USER
# same as above
wrangler kv:namespace create DEALS --preview --env USER
# same as above
wrangler kv:namespace create METRICS --preview --env USER
# same as above

Go to /site/src/constants.js uncomment the first line and run wrangler publish --env USER.

# dev and preview secrets
wrangler secret put MAGIC_SECRET_KEY --env USER # Get from magic.link account
wrangler secret put SALT --env USER # open `https://csprng.xyz/v1/api` in the browser and use the value of `Data`
wrangler secret put PINATA_JWT --env USER # Get from Pinata
wrangler secret put SENTRY_DSN --env USER # Get from Sentry

Go to /site/src/constants.js comment the first line and run wrangler publish --env USER.

Production Setup [env.production]

# production KVs
wrangler kv:namespace create USERS --env production
# Follow the instructions from the cli output
wrangler kv:namespace create NFTS --env production
# Follow the instructions from the cli output
wrangler kv:namespace create NFTS_IDX --env production
# Follow the instructions from the cli output
wrangler kv:namespace create DEALS --env production
# Follow the instructions from the cli output
wrangler kv:namespace create METRICS --env production
# Follow the instructions from the cli output
wrangler secret put MAGIC_SECRET_KEY --env production # Get from magic.link account
wrangler secret put SALT --env production # open `https://csprng.xyz/v1/api` in the browser and use the value of `Data`
wrangler secret put PINATA_JWT --env production # Get from Pinata
wrangler secret put CLUSTER_BASIC_AUTH_TOKEN --env production # Get from nft.storage vault in 1password
wrangler secret put CLUSTER_IPFS_PROXY_BASIC_AUTH_TOKEN --env production # Get from nft.storage vault in 1password
wrangler publish --env production

site Usage

Local development

cd site
yarn install
yarn dev

Deploy

Deployment should be done with github actions but in the case you need to manually test something you can run yarn deploy inside the site folder.

website Setup

Inside the website folder create a file called .env.local with the following content.

NEXT_PUBLIC_ENV=dev
NEXT_PUBLIC_API=http://127.0.0.1:8787
NEXT_PUBLIC_MAGIC=<magic test mode publishable key>
NEXT_PUBLIC_SENTRY_DSN=<sentry dsn>
SENTRY_URL=https://sentry.io/
SENTRY_ORG=<sentry org name>
SENTRY_PROJECT=<sentry project name>
SENTRY_AUTH_TOKEN=<sentry auth token>

Production vars should set in Cloudflare Pages settings.

website Usage

Local development

cd site
yarn install
yarn dev

Contributing

Feel free to join in. All welcome. Open an issue!

License

Dual-licensed under MIT + Apache 2.0

nft.storage's People

Contributors

alanshaw avatar gozala avatar hugomrdias avatar jonyg80 avatar ribasushi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.