Skip to content

Commit

Permalink
Merge pull request #52 from trustenterprises/feature/ipfs-provider-fi…
Browse files Browse the repository at this point in the history
…lebase

Add filebase, and implement client for all metadata post requests
  • Loading branch information
mattsmithies authored Apr 30, 2024
2 parents 7bd6bbd + 3963a9f commit 863a0b5
Show file tree
Hide file tree
Showing 4 changed files with 1,089 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/handler/createMetadataHandler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import createMetadataRequest from "app/validators/createMetadataRequest"
import Response from "app/response"
import NftStorage from "app/utils/nftStorage"
import FilebaseStorage from "app/utils/filebaseStorage"
import Language from "app/constants/language"

async function CreateMetadataHandler(req, res) {
Expand All @@ -14,7 +14,7 @@ async function CreateMetadataHandler(req, res) {
)
}

const cid = await NftStorage.storeData(req.body)
const cid = await FilebaseStorage.storeData(req.body)

if (cid) {
return Response.json(res, { cid })
Expand Down
20 changes: 20 additions & 0 deletions app/utils/filebaseStorage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { FilebaseClient } from "@filebase/client"
import Config from "app/config"

// Returns metadata for pinned payload
async function storeData(payload) {
const storage = new FilebaseClient({ token: Config.nftStorageToken })

const asBlob = new Blob([JSON.stringify(payload)])

// Assume that metadata storage, like images is already handled
try {
return await storage.storeBlob(asBlob)
} catch (e) {
return false
}
}

export default {
storeData
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"start-server": "next start -H 0.0.0.0 -p ${PORT:-8080}"
},
"dependencies": {
"@filebase/client": "^0.0.5",
"@hapi/joi": "^17.1.1",
"@hashgraph/sdk": "^2.6.0",
"axios": "^0.21.1",
Expand Down
Loading

0 comments on commit 863a0b5

Please sign in to comment.