mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-11 00:08:37 +01:00
shields update
This commit is contained in:
21
dashboard/server/api/shields/domains/add.post.ts
Normal file
21
dashboard/server/api/shields/domains/add.post.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { DomainWhitelistModel } from "~/shared/schema/shields/DomainWhitelistSchema";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
const data = await getRequestData(event, [], ['OWNER']);
|
||||
if (!data) return;
|
||||
|
||||
const body = await readBody(event);
|
||||
const { domain } = body;
|
||||
|
||||
if (domain.trim().length == 0) return setResponseStatus(event, 400, 'Domain is required');
|
||||
|
||||
const whitelist = await DomainWhitelistModel.updateOne({
|
||||
project_id: data.project_id
|
||||
},
|
||||
{ $push: { domains: domain } },
|
||||
{ upsert: true }
|
||||
);
|
||||
|
||||
return { ok: true };
|
||||
});
|
||||
Reference in New Issue
Block a user