next/server/api/user/[id]/admin.post.ts

15 lines
358 B
TypeScript
Raw Permalink Normal View History

import { isAdmin, isLoggedIn } from "@server/middlewareButNotReally";
import { User } from "@models/user";
export default eventHandler(async (ev) => {
isLoggedIn(ev);
isAdmin(ev);
const b = await readBody(ev);
let idee = parseInt(getRouterParam(ev, "id")!);
await User.findByIdAndUpdate(idee, {
$set: {
"profile.isAdmin": b.promote,
},
});
});