MCPcopy Create free account
hub / github.com/triggerdotdev/jsonhero-web / action

Function action

app/routes/actions/setTheme.ts:7–33  ·  view source on GitHub ↗
({ request, context })

Source from the content-addressed store, hash-verified

5import { sendEvent } from "~/graphJSON.server";
6
7export const action: ActionFunction = async ({ request, context }) => {
8 const themeSession = await getThemeSession(request);
9 const requestText = await request.text();
10 const form = new URLSearchParams(requestText);
11 const theme = form.get("theme");
12
13 if (!isTheme(theme)) {
14 return json({
15 success: false,
16 message: `theme value of ${theme} is not a valid theme`,
17 });
18 }
19
20 themeSession.setTheme(theme);
21
22 context.waitUntil(
23 sendEvent({
24 type: "set-theme",
25 theme,
26 })
27 );
28
29 return json(
30 { success: true },
31 { headers: { "Set-Cookie": await themeSession.commit() } }
32 );
33};
34
35export const loader: LoaderFunction = () => redirect("/", { status: 404 });

Callers

nothing calls this directly

Calls 3

getThemeSessionFunction · 0.90
isThemeFunction · 0.90
sendEventFunction · 0.90

Tested by

no test coverage detected