MCPcopy Create free account
hub / github.com/code-forge-io/Remix-Forge / dashboardFileContent

Function dashboardFileContent

src/auth/authFiles/dashboard.ts:3–29  ·  view source on GitHub ↗
(config: WorkspaceConfiguration)

Source from the content-addressed store, hash-verified

1import { WorkspaceConfiguration } from "vscode";
2
3export const dashboardFileContent = (config: WorkspaceConfiguration) => {
4 const runtimeDependency = config.get("runtimeDependency") || "@remix-run/node";
5 return [
6 `import type { LoaderFunctionArgs } from '${runtimeDependency}';`,
7 "import { useLoaderData, Form } from '@remix-run/react';",
8 "import { authenticator } from '~/services/auth.server';",
9 "",
10 "export const loader = async ({ request }: LoaderFunctionArgs) => {",
11 " await authenticator.isAuthenticated(request, {",
12 ' failureRedirect: "/login",',
13 " });",
14 " return { message: 'You are logged in!' };",
15 "};",
16 "",
17 "export default function DashboardRoute() {",
18 " const { message } = useLoaderData<typeof loader>();",
19 " return (",
20 " <div>",
21 " <h1>{message}</h1>",
22 " <Form method='post' action='/logout'>",
23 " <button type='submit'>Logout</button>",
24 " </Form>",
25 " </div>",
26 " );",
27 "}",
28 ].join("\n");
29};

Callers 1

generateAuthFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected