22 lines
568 B
TypeScript
22 lines
568 B
TypeScript
import type { NextApiRequest, NextApiResponse } from "next";
|
|
import { store, html } from "@/store";
|
|
import config from "@/config";
|
|
|
|
export default async function handler(
|
|
req: NextApiRequest,
|
|
res: NextApiResponse<Record<string, string>>
|
|
) {
|
|
if (req.method === "POST") {
|
|
if (req.headers.token !== config.token) {
|
|
res.status(403).json({ error: "wrong token" });
|
|
return;
|
|
}
|
|
// update store
|
|
console.log("admin", req.body);
|
|
const json = req.body;
|
|
store.update(json);
|
|
}
|
|
await store.save();
|
|
res.status(200).json(store.get());
|
|
}
|