Add: clear

This commit is contained in:
2022-04-02 15:42:45 +08:00
parent 33eaa9ee00
commit 880c26b8d3
2 changed files with 50 additions and 11 deletions

View File

@@ -2,10 +2,11 @@ import {
deleteTimeRange,
getLimit,
authenticate,
updateUsername,
updateUsernameWithLimit,
} from "../../../../libs/db";
import { addAPIQPS } from '../../../../libs/stats';
import { addAPIQPS } from "../../../../libs/stats";
export default function handler(req, res) {
addAPIQPS();
@@ -43,6 +44,16 @@ export default function handler(req, res) {
return;
}
// admin update username
const { token } = req.body;
if (authenticate(token)) {
updateUsername.run(username, id);
res.status(200).json({
success: true,
});
return;
}
try {
const limit = getLimit();
updateUsernameWithLimit(username, id, limit);