| 1 | import { WorkspaceConfiguration } from "vscode"; |
| 2 | |
| 3 | export const authRouteFileContent = (config: WorkspaceConfiguration) => { |
| 4 | const runtimeDependency = config.get("runtimeDependency") || "@remix-run/node"; |
| 5 | return [ |
| 6 | `import type { LoaderFunctionArgs } from "${runtimeDependency}";`, |
| 7 | 'import { authenticator } from "~/services/auth.server";', |
| 8 | "", |
| 9 | "export const loader = async ({ request }: LoaderFunctionArgs) => {", |
| 10 | " return await authenticator.isAuthenticated(request, {", |
| 11 | ' successRedirect: "/dashboard",', |
| 12 | " });", |
| 13 | "};", |
| 14 | ].join("\n"); |
| 15 | }; |