MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / post

Function post

pages/api/contacts/delete-addressbook.ts:15–35  ·  view source on GitHub ↗
({ request, user }: RequestHandlerParams)

Source from the content-addressed store, hash-verified

13}
14
15async function post({ request, user }: RequestHandlerParams) {
16 if (!(await AppConfig.isAppEnabled('contacts'))) {
17 return new Response('Forbidden', { status: 403 });
18 }
19
20 const requestBody = await request.clone().json() as RequestBody;
21
22 if (!requestBody.addressBookId) {
23 return new Response('Bad request', { status: 400 });
24 }
25
26 const userId = user!.id;
27
28 await ContactModel.deleteAddressBook(userId, requestBody.addressBookId);
29
30 const addressBooks = await ContactModel.listAddressBooks(userId);
31
32 const responseBody: ResponseBody = { success: true, addressBooks };
33
34 return new Response(JSON.stringify(responseBody));
35}
36
37export default page({
38 post,

Callers

nothing calls this directly

Calls 4

isAppEnabledMethod · 0.80
cloneMethod · 0.80
deleteAddressBookMethod · 0.80
listAddressBooksMethod · 0.80

Tested by

no test coverage detected