profile.put.mjs
1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { e as eventHandler, r as readBody, A as updateMockSettingsProfile } from '../../../nitro/nitro.mjs';
import { z } from 'zod';
import 'node:http';
import 'node:https';
import 'node:events';
import 'node:buffer';
import 'node:fs';
import 'node:path';
import 'node:crypto';
import 'node:url';
import '@iconify/utils';
import 'consola';
const profilePayloadSchema = z.object({
name: z.string().trim().min(2),
email: z.string().trim().email(),
username: z.string().trim().min(2),
avatar: z.string().trim().optional(),
bio: z.string().trim().optional()
});
const profile_put = eventHandler(async (event) => {
const body = await readBody(event);
const parsed = profilePayloadSchema.safeParse(body);
if (!parsed.success) {
return {
success: false,
errorCode: "VALIDATION_ERROR",
message: "\u63D0\u4EA4\u7684\u4E2A\u4EBA\u8D44\u6599\u683C\u5F0F\u4E0D\u6B63\u786E\u3002"
};
}
const profile = updateMockSettingsProfile(parsed.data);
return {
success: true,
errorCode: null,
message: "\u4E2A\u4EBA\u8D44\u6599\u5DF2\u4FDD\u5B58\u3002",
profile
};
});
export { profile_put as default };
//# sourceMappingURL=profile.put.mjs.map