index.patch.mjs
1.1 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
import { e as eventHandler, d as getRouterParam, r as readBody, v as updateMockMemberRole } 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 rolePayloadSchema = z.object({
role: z.enum(["member", "admin", "customer"])
});
const index_patch = eventHandler(async (event) => {
const username = getRouterParam(event, "username");
if (!username) {
return {
success: false,
errorCode: "VALIDATION_ERROR",
message: "\u7F3A\u5C11\u6210\u5458\u6807\u8BC6\u3002"
};
}
const body = await readBody(event);
const parsed = rolePayloadSchema.safeParse(body);
if (!parsed.success) {
return {
success: false,
errorCode: "VALIDATION_ERROR",
message: "\u89D2\u8272\u53C2\u6570\u4E0D\u6B63\u786E\u3002"
};
}
return updateMockMemberRole(username, parsed.data.role);
});
export { index_patch as default };
//# sourceMappingURL=index.patch.mjs.map