This commit is contained in:
2022-03-31 12:25:54 +08:00
parent 7e4c106683
commit a67715a2a0
7 changed files with 38 additions and 37 deletions

View File

@@ -1,11 +1,16 @@
import { deleteTimeRange, getLimit, authenticate, updateUsernameWithLimit } from "../../../../libs/db";
import {
deleteTimeRange,
getLimit,
authenticate,
updateUsernameWithLimit,
} from "../../../../libs/db";
export default function handler(req, res) {
// check if id is valid
const { id } = req.query;
if (id === undefined) {
res.status(400).json({
error: "Missing id",
error: `缺少参数 id`,
});
return;
}
@@ -17,7 +22,7 @@ export default function handler(req, res) {
if (!authenticate(token)) {
console.log("[DELETE] Authentication failed");
res.status(401).json({
error: "Unauthenticated",
error: `token ${token} 验证失败`,
});
return;
}
@@ -30,7 +35,7 @@ export default function handler(req, res) {
const { username } = req.body;
if (username === undefined) {
res.status(400).json({
error: "Missing username",
error: `缺少参数 username`,
});
return;
}
@@ -44,13 +49,10 @@ export default function handler(req, res) {
});
return;
}
// not allow
// not allow
} else {
// 500 error
res.status(500).json({
error: "Method not allowed",
});
res.status(405).send({ error: "方法" + req.method + "不被允许" });
}
res.status(200).json({