forked from heyxyz/hey
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate metadata worker to next api
- Loading branch information
Showing
34 changed files
with
1,018 additions
and
1,391 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Errors } from '@hey/data/errors'; | ||
import { NodeIrys } from '@irys/sdk'; | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
import allowCors from 'utils/allowCors'; | ||
|
||
const handler = async (req: NextApiRequest, res: NextApiResponse) => { | ||
const { body } = req; | ||
|
||
if (!body) { | ||
return res.status(400).json({ success: false, error: Errors.NoBody }); | ||
} | ||
|
||
try { | ||
const url = 'https://node2.irys.xyz'; | ||
const token = 'matic'; | ||
const client = new NodeIrys({ | ||
url, | ||
token, | ||
key: process.env.IRYS_PRIVATE_KEY | ||
}); | ||
|
||
const receipt = await client.upload(JSON.stringify(body), { | ||
tags: [ | ||
{ name: 'content-type', value: 'application/json' }, | ||
{ name: 'App-Name', value: 'Hey.xyz' } | ||
] | ||
}); | ||
|
||
return res.status(200).json({ success: true, id: receipt.id }); | ||
} catch (error) { | ||
throw error; | ||
} | ||
}; | ||
|
||
export default allowCors(handler); |
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.