Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
guyutongxue committed Jan 24, 2025
1 parent 90d425e commit c2db402
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion api/v2/data/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ import { all, keywords } from "../data.js";
* @param {VercelResponse} res
* @returns
*/
export default function handler(req, res) {
export default async function handler(req, res) {
const { id } = req.query;
if (Array.isArray(id)) {
res.status(400)
.send("Bad request (multiple id)");
return;
}
const { Accept } = req.headers;
if (Accept.includes("image/webp")) {
const response = await fetch(`https://gi-tcg-card-data-img.vercel.app/${id}.webp`);
res.status(200).send(response);
return;
}
let found;
if (id.startsWith("K")) {
found = keywords.find((obj) => obj.id === Number(id.slice(1)));
Expand Down

0 comments on commit c2db402

Please sign in to comment.