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

Function post

pages/api/files/delete-directory.ts:17–45  ·  view source on GitHub ↗
({ request, user }: RequestHandlerParams)

Source from the content-addressed store, hash-verified

15}
16
17async function post({ request, user }: RequestHandlerParams) {
18 if (
19 !(await AppConfig.isAppEnabled('files')) && !(await AppConfig.isAppEnabled('photos')) &&
20 !(await AppConfig.isAppEnabled('notes'))
21 ) {
22 return new Response('Forbidden', { status: 403 });
23 }
24
25 const requestBody = await request.clone().json() as RequestBody;
26
27 if (
28 !requestBody.parentPath || !requestBody.name?.trim() || !requestBody.parentPath.startsWith('/') ||
29 requestBody.parentPath.includes('../')
30 ) {
31 return new Response('Bad Request', { status: 400 });
32 }
33
34 const deletedDirectory = await DirectoryModel.delete(
35 user!.id,
36 requestBody.parentPath,
37 requestBody.name.trim(),
38 );
39
40 const newDirectories = await DirectoryModel.list(user!.id, requestBody.parentPath);
41
42 const responseBody: ResponseBody = { success: deletedDirectory, newDirectories };
43
44 return new Response(JSON.stringify(responseBody));
45}
46
47export default page({
48 post,

Callers

nothing calls this directly

Calls 4

isAppEnabledMethod · 0.80
cloneMethod · 0.80
deleteMethod · 0.45
listMethod · 0.45

Tested by

no test coverage detected