20 lines
403 B
TypeScript
20 lines
403 B
TypeScript
import { isLoggedIn } from "@server/middlewareButNotReally";
|
|
import { User } from "@models/user";
|
|
|
|
export default eventHandler(async (ev) => {
|
|
isLoggedIn(ev);
|
|
let idee = parseInt(getRouterParam(ev, "id")!);
|
|
if (isNaN(idee))
|
|
throw createError({
|
|
statusCode: 400,
|
|
});
|
|
await User.findOneAndUpdate(
|
|
{ _id: ev.context.currentUser!._id },
|
|
{
|
|
$addToSet: {
|
|
blocked: idee,
|
|
},
|
|
},
|
|
);
|
|
});
|