skyblock endpoint
This commit is contained in:
parent
dbbab21bcb
commit
ffc864fe96
2 changed files with 23 additions and 1 deletions
|
@ -21,7 +21,8 @@
|
||||||
"next-auth": "^3.27.0",
|
"next-auth": "^3.27.0",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"react-icons": "^4.2.0"
|
"react-icons": "^4.2.0",
|
||||||
|
"skyhelper-networth": "^1.11.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.2.0",
|
"eslint": "^8.2.0",
|
||||||
|
|
21
pages/api/skyblock.js
Normal file
21
pages/api/skyblock.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
const {getItemNetworth} = require("skyhelper-networth");
|
||||||
|
const nbt = require("prismarine-nbt");
|
||||||
|
const parseNbt = require("util").promisify(nbt.parse);
|
||||||
|
async function decodeData(buffer) {
|
||||||
|
const parsedNbt = await parseNbt(Buffer.from(buffer, "base64"));
|
||||||
|
return nbt.simplify(parsedNbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function handler(req, res) {
|
||||||
|
if (req.method == "GET") {
|
||||||
|
const {ByteData} = JSON.parse(req.body);
|
||||||
|
if (ByteData == undefined)
|
||||||
|
res.status(400).json({error: "ByteData is undefined"});
|
||||||
|
const data = await getItemNetworth((await decodeData(ByteData)).i[0], {
|
||||||
|
cache: true,
|
||||||
|
});
|
||||||
|
res.status(200).json(data);
|
||||||
|
} else {
|
||||||
|
res.status(400).json({error: "This endpoint only accepts GET requests"});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue