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