This commit is contained in:
2023-04-26 22:41:36 +08:00
parent 7f2141e832
commit 6d2c0d8cb3
8 changed files with 37 additions and 8 deletions

View File

@@ -2,7 +2,7 @@ import type { NextApiRequest, NextApiResponse } from "next";
import { store, html } from "@/store";
import config from "@/config";
export default function handler(
export default async function handler(
req: NextApiRequest,
res: NextApiResponse<Record<string, string>>
) {
@@ -16,5 +16,6 @@ export default function handler(
const json = req.body;
store.update(json);
}
await store.save();
res.status(200).json(store.get());
}

View File

@@ -4,6 +4,7 @@ import config from "@/config";
export default function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method === "POST") {
if (req.headers.token !== config.token) {
console.log("wrong token", req.headers.token, config.token);
res.status(403).json({ error: "wrong token" });
return;
}

View File

@@ -8,7 +8,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse) {
if (req.method === "POST") {
if (!config.begin) {
res.status(400).json({
error: "还没到开时间哦",
error: "还没到开时间哦",
});
return;
}