fix repeat-recent code
This commit is contained in:
@@ -19,10 +19,6 @@ export default async (req, res) => {
|
||||
res.end(String(data));
|
||||
}
|
||||
};
|
||||
res.status = function (code) {
|
||||
res.statusCode = code;
|
||||
return res;
|
||||
};
|
||||
const url = new URL(req.url, "https://localhost");
|
||||
req.query = Object.fromEntries(url.searchParams.entries());
|
||||
|
||||
|
||||
@@ -2,13 +2,16 @@ import { repeatRecentRequests } from "../src/common/database.js";
|
||||
|
||||
export default async (req, res) => {
|
||||
if (req.method !== "POST") {
|
||||
res.status(405).json({ error: "Method Not Allowed" });
|
||||
res.statusCode = 405;
|
||||
res.send({ error: "Method Not Allowed" });
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await repeatRecentRequests();
|
||||
res.status(200).json({ message: "Recent requests repeated successfully." });
|
||||
res.statusCode = 200;
|
||||
res.send({ message: "Recent requests repeated successfully." });
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message || "Internal Server Error" });
|
||||
res.statusCode = 500;
|
||||
res.send({ error: error.message || "Internal Server Error" });
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user