You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

13 lines
466 B

import { fetchUrlMeta } from "#server/service/collection";
import { z } from "zod";
const fetchSchema = z.object({ url: z.string().url() });
export default defineWrappedResponseHandler({ auth: "required" }, async (event) => {
const body = await readBody(event);
const parsed = fetchSchema.safeParse(body);
if (!parsed.success) return R.error("请输入有效的 URL", null);
const meta = await fetchUrlMeta(parsed.data.url);
return R.success(meta);
});