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.
 
 
 
 

18 lines
659 B

import { z } from "zod";
import { validate } from "#server/utils/validation";
import { createIdea } from "../../service/ideas";
const createSchema = z.object({
author: z.string().max(30, "昵称不能超过 30 字").nullable().optional(),
content: z.string().min(1, "想法不能为空").max(500, "想法不能超过 500 字"),
platform: z.string().max(30).nullable().optional(),
color: z.string().max(30).nullable().optional(),
});
export default defineWrappedResponseHandler(async (event) => {
const body = await readBody(event);
const data = validate(createSchema, body);
const idea = await createIdea(data);
return R.success(idea);
});