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

Function post

pages/api/dashboard/save-notes.ts:14–36  ·  view source on GitHub ↗
({ request, user }: RequestHandlerParams)

Source from the content-addressed store, hash-verified

12}
13
14async function post({ request, user }: RequestHandlerParams) {
15 if (!(await AppConfig.isAppEnabled('dashboard'))) {
16 return new Response('Forbidden', { status: 403 });
17 }
18
19 const userDashboard = await DashboardModel.getByUserId(user!.id);
20
21 if (!userDashboard) {
22 return new Response('Not found', { status: 404 });
23 }
24
25 const requestBody = await request.clone().json() as RequestBody;
26
27 if (typeof requestBody.notes !== 'undefined' && userDashboard.data.notes !== requestBody.notes) {
28 userDashboard.data.notes = requestBody.notes;
29
30 await DashboardModel.update(userDashboard);
31 }
32
33 const responseBody: ResponseBody = { success: true };
34
35 return new Response(JSON.stringify(responseBody));
36}
37
38export default page({
39 post,

Callers

nothing calls this directly

Calls 4

isAppEnabledMethod · 0.80
getByUserIdMethod · 0.80
cloneMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected