borders/pages/api/user/border/@me.js

21 lines
589 B
JavaScript

import { getUserBorders, setUserBorder } from "../../../../lib/borders";
export default function handler(req, res) {
if (req.method === "POST") {
setUserBorder(req, req.body).then((result) => {
if (result) {
return res.status(200).json(result);
} else {
return res.status(500).json({ error: "could not update border" });
}
});
} else {
getUserBorders(req).then((result) => {
if (result) {
return res.status(200).json(result);
} else {
return res.status(404).json({ error: "Not Found" });
}
});
}
}