Skip to content

Commit 391bd26

Browse files
refactor(remix-auth-form): Switch to V2 (#353)
1 parent 577ae94 commit 391bd26

File tree

5 files changed

+37
-30
lines changed

5 files changed

+37
-30
lines changed

remix-auth-form/app/root.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { MetaFunction } from "@remix-run/node";
1+
import { cssBundleHref } from "@remix-run/css-bundle";
2+
import type { LinksFunction, MetaFunction } from "@remix-run/node";
23
import {
34
Links,
45
LiveReload,
@@ -8,16 +9,23 @@ import {
89
ScrollRestoration,
910
} from "@remix-run/react";
1011

11-
export const meta: MetaFunction = () => ({
12-
charset: "utf-8",
13-
title: "New Remix App",
14-
viewport: "width=device-width,initial-scale=1",
15-
});
12+
export const links: LinksFunction = () => [
13+
...(cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : []),
14+
];
15+
16+
export const meta: MetaFunction = () => {
17+
return [
18+
{ title: "New Remix App" },
19+
{ name: "description", content: "Welcome to Remix!" },
20+
];
21+
};
1622

1723
export default function App() {
1824
return (
1925
<html lang="en">
2026
<head>
27+
<meta charSet="utf-8" />
28+
<meta name="viewport" content="width=device-width, initial-scale=1" />
2129
<Meta />
2230
<Links />
2331
</head>

remix-auth-form/app/routes/login.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
1+
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
22
import { json } from "@remix-run/node";
33
import { Form, useLoaderData } from "@remix-run/react";
44

55
import { auth, sessionStorage } from "~/auth.server";
66

7-
export const action = async ({ request }: ActionArgs) => {
7+
export const action = async ({ request }: ActionFunctionArgs) => {
88
await auth.authenticate("form", request, {
99
successRedirect: "/private",
1010
failureRedirect: "/login",
1111
});
1212
};
1313

1414
type LoaderError = { message: string } | null;
15-
export const loader = async ({ request }: LoaderArgs) => {
15+
export const loader = async ({ request }: LoaderFunctionArgs) => {
1616
await auth.isAuthenticated(request, { successRedirect: "/private" });
1717
const session = await sessionStorage.getSession(
1818
request.headers.get("Cookie"),

remix-auth-form/app/routes/private.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
1+
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
22
import { json } from "@remix-run/node";
33
import { Form, useLoaderData } from "@remix-run/react";
44

55
import { auth } from "~/auth.server";
66

7-
export const action = async ({ request }: ActionArgs) => {
7+
export const action = async ({ request }: ActionFunctionArgs) => {
88
await auth.logout(request, { redirectTo: "/login" });
99
};
1010

11-
export const loader = async ({ request }: LoaderArgs) => {
11+
export const loader = async ({ request }: LoaderFunctionArgs) => {
1212
const email = await auth.isAuthenticated(request, {
1313
failureRedirect: "/login",
1414
});

remix-auth-form/package.json

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
{
22
"private": true,
33
"sideEffects": false,
4+
"type": "module",
45
"scripts": {
56
"build": "remix build",
6-
"dev": "remix dev",
7-
"start": "remix-serve build",
7+
"dev": "remix dev --manual",
8+
"start": "remix-serve ./build/index.js",
89
"typecheck": "tsc"
910
},
1011
"dependencies": {
11-
"@remix-run/node": "^1.19.3",
12-
"@remix-run/react": "^1.19.3",
13-
"@remix-run/serve": "^1.19.3",
14-
"isbot": "^3.6.5",
12+
"@remix-run/css-bundle": "^2.0.1",
13+
"@remix-run/node": "^2.0.1",
14+
"@remix-run/react": "^2.0.1",
15+
"@remix-run/serve": "^2.0.1",
16+
"isbot": "^3.6.8",
1517
"react": "^18.2.0",
1618
"react-dom": "^18.2.0",
17-
"remix-auth": "^3.2.1",
18-
"remix-auth-form": "^1.1.1"
19+
"remix-auth": "^3.6.0",
20+
"remix-auth-form": "^1.4.0"
1921
},
2022
"devDependencies": {
21-
"@remix-run/dev": "^1.19.3",
22-
"@remix-run/eslint-config": "^1.19.3",
23-
"@types/react": "^18.0.25",
24-
"@types/react-dom": "^18.0.8",
25-
"eslint": "^8.27.0",
26-
"typescript": "^4.8.4"
23+
"@remix-run/dev": "^2.0.1",
24+
"@remix-run/eslint-config": "^2.0.1",
25+
"@types/react": "^18.2.20",
26+
"@types/react-dom": "^18.2.7",
27+
"eslint": "^8.38.0",
28+
"typescript": "^5.1.6"
2729
},
2830
"engines": {
2931
"node": ">=14.0.0"

remix-auth-form/remix.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
/** @type {import('@remix-run/dev').AppConfig} */
2-
module.exports = {
3-
future: {
4-
v2_routeConvention: true,
5-
},
2+
export default {
63
ignoredRouteFiles: ["**/.*"],
74
// appDirectory: "app",
85
// assetsBuildDirectory: "public/build",

0 commit comments

Comments
 (0)