feat: temporarily disable the nft api

This commit is contained in:
DIYgod 2023-03-27 17:45:17 +01:00
parent d7f8a1bef8
commit 1021abcf18
No known key found for this signature in database
1 changed files with 32 additions and 30 deletions

View File

@ -25,35 +25,37 @@ export default async function handler(
if (cache) {
res.status(200).json(JSON.parse(cache))
} else {
const result = await getNFTs(query.address as string)
await Promise.all(
result.list.map(async (nft: Asset) => {
if (!nft.items?.[0].mime_type && nft.items?.[0]?.address) {
try {
const mime_type = await cacheGet({
key: `nft-mimetype/${nft.items[0].address}`,
getValueFun: async () => {
const head = await fetch(
`${nft.items![0].address!.replace(
IPFS_GATEWAY,
"https://gateway.ipfs.io/ipfs/",
)}`,
{
method: "HEAD",
},
)
return head.headers.get("content-type")
},
})
nft.items[0].mime_type = mime_type
} catch (error) {
console.warn(error)
}
}
return nft
}),
)
redis.set(redisKey, JSON.stringify(result), "EX", 60 * 60 * 24)
res.status(200).json(result)
// const result = await getNFTs(query.address as string)
// await Promise.all(
// result.list.map(async (nft: Asset) => {
// if (!nft.items?.[0].mime_type && nft.items?.[0]?.address) {
// try {
// const mime_type = await cacheGet({
// key: `nft-mimetype/${nft.items[0].address}`,
// getValueFun: async () => {
// const head = await fetch(
// `${nft.items![0].address!.replace(
// IPFS_GATEWAY,
// "https://gateway.ipfs.io/ipfs/",
// )}`,
// {
// method: "HEAD",
// },
// )
// return head.headers.get("content-type")
// },
// })
// nft.items[0].mime_type = mime_type
// } catch (error) {
// console.warn(error)
// }
// }
// return nft
// }),
// )
// redis.set(redisKey, JSON.stringify(result), "EX", 60 * 60 * 24)
res.status(200).json({
list: [],
})
}
}