init
This commit is contained in:
23
pages/api/admin.ts
Normal file
23
pages/api/admin.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { NextApiRequest, NextApiResponse } from "next";
|
||||
import store from "@/store";
|
||||
|
||||
export default function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse<Record<string, string>>,
|
||||
) {
|
||||
if (req.method === 'POST') {
|
||||
// update store
|
||||
console.log('admin', req.body)
|
||||
const json = req.body
|
||||
for (const key in json) {
|
||||
store[key] = json[key];
|
||||
}
|
||||
const keys = Object.keys(json)
|
||||
for (const key in store) {
|
||||
if (json[key] === undefined) {
|
||||
delete store[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
res.status(200).json(store);
|
||||
}
|
||||
Reference in New Issue
Block a user