Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit da05ab4

Browse files
committed
feat: upgrade to Remix v2
1 parent af4c898 commit da05ab4

File tree

17 files changed

+62
-150
lines changed

17 files changed

+62
-150
lines changed

app/entry.server.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
* For more information, see https://remix.run/docs/en/main/file-conventions/entry.server
55
*/
66

7-
import { PassThrough } from "node:stream";
7+
import { PassThrough, Readable } from "node:stream";
88

99
import type { EntryContext } from "@remix-run/node";
10-
import { Response } from "@remix-run/node";
1110
import { RemixServer } from "@remix-run/react";
1211
import isbot from "isbot";
1312
import { renderToPipeableStream } from "react-dom/server";
@@ -55,7 +54,7 @@ function handleBotRequest(
5554
responseHeaders.set("Content-Type", "text/html");
5655

5756
resolve(
58-
new Response(body, {
57+
new Response(Readable.toWeb(body) as ReadableStream, {
5958
headers: responseHeaders,
6059
status: responseStatusCode,
6160
}),
@@ -97,7 +96,7 @@ function handleBrowserRequest(
9796
responseHeaders.set("Content-Type", "text/html");
9897

9998
resolve(
100-
new Response(body, {
99+
new Response(Readable.toWeb(body) as ReadableStream, {
101100
headers: responseHeaders,
102101
status: responseStatusCode,
103102
}),

app/root.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cssBundleHref } from "@remix-run/css-bundle";
2-
import type { LinksFunction, LoaderArgs } from "@remix-run/node";
2+
import type { LinksFunction, LoaderFunctionArgs } from "@remix-run/node";
33
import { json } from "@remix-run/node";
44
import {
55
Links,
@@ -20,7 +20,7 @@ export const links: LinksFunction = () => [
2020
{ rel: "icon", href: "/_static/favicon.ico" },
2121
];
2222

23-
export const loader = async ({ request }: LoaderArgs) => {
23+
export const loader = async ({ request }: LoaderFunctionArgs) => {
2424
return json({ user: await getUser(request) });
2525
};
2626

app/routes/_index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import type { V2_MetaFunction } from "@remix-run/node";
1+
import type { MetaFunction } from "@remix-run/node";
22
import { Link } from "@remix-run/react";
33

44
import { useOptionalUser } from "~/utils";
55

6-
export const meta: V2_MetaFunction = () => [{ title: "Remix Notes" }];
6+
export const meta: MetaFunction = () => [{ title: "Remix Notes" }];
77

88
export default function Index() {
99
const user = useOptionalUser();

app/routes/join.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import type { ActionArgs, LoaderArgs, V2_MetaFunction } from "@remix-run/node";
1+
import type {
2+
ActionFunctionArgs,
3+
LoaderFunctionArgs,
4+
MetaFunction,
5+
} from "@remix-run/node";
26
import { json, redirect } from "@remix-run/node";
37
import { Form, Link, useActionData, useSearchParams } from "@remix-run/react";
48
import { useEffect, useRef } from "react";
@@ -7,13 +11,13 @@ import { createUser, getUserByEmail } from "~/models/user.server";
711
import { createUserSession, getUserId } from "~/session.server";
812
import { safeRedirect, validateEmail } from "~/utils";
913

10-
export const loader = async ({ request }: LoaderArgs) => {
14+
export const loader = async ({ request }: LoaderFunctionArgs) => {
1115
const userId = await getUserId(request);
1216
if (userId) return redirect("/");
1317
return json({});
1418
};
1519

16-
export const action = async ({ request }: ActionArgs) => {
20+
export const action = async ({ request }: ActionFunctionArgs) => {
1721
const formData = await request.formData();
1822
const email = formData.get("email");
1923
const password = formData.get("password");
@@ -63,7 +67,7 @@ export const action = async ({ request }: ActionArgs) => {
6367
});
6468
};
6569

66-
export const meta: V2_MetaFunction = () => [{ title: "Sign Up" }];
70+
export const meta: MetaFunction = () => [{ title: "Sign Up" }];
6771

6872
export default function Join() {
6973
const [searchParams] = useSearchParams();

app/routes/login.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import type { ActionArgs, LoaderArgs, V2_MetaFunction } from "@remix-run/node";
1+
import type {
2+
ActionFunctionArgs,
3+
LoaderFunctionArgs,
4+
MetaFunction,
5+
} from "@remix-run/node";
26
import { json, redirect } from "@remix-run/node";
37
import { Form, Link, useActionData, useSearchParams } from "@remix-run/react";
48
import { useEffect, useRef } from "react";
@@ -7,13 +11,13 @@ import { verifyLogin } from "~/models/user.server";
711
import { createUserSession, getUserId } from "~/session.server";
812
import { safeRedirect, validateEmail } from "~/utils";
913

10-
export const loader = async ({ request }: LoaderArgs) => {
14+
export const loader = async ({ request }: LoaderFunctionArgs) => {
1115
const userId = await getUserId(request);
1216
if (userId) return redirect("/");
1317
return json({});
1418
};
1519

16-
export const action = async ({ request }: ActionArgs) => {
20+
export const action = async ({ request }: ActionFunctionArgs) => {
1721
const formData = await request.formData();
1822
const email = formData.get("email");
1923
const password = formData.get("password");
@@ -58,7 +62,7 @@ export const action = async ({ request }: ActionArgs) => {
5862
});
5963
};
6064

61-
export const meta: V2_MetaFunction = () => [{ title: "Login" }];
65+
export const meta: MetaFunction = () => [{ title: "Login" }];
6266

6367
export default function LoginPage() {
6468
const [searchParams] = useSearchParams();

app/routes/logout.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import type { ActionArgs } from "@remix-run/node";
1+
import type { ActionFunctionArgs } from "@remix-run/node";
22
import { redirect } from "@remix-run/node";
33

44
import { logout } from "~/session.server";
55

6-
export const action = async ({ request }: ActionArgs) => logout(request);
6+
export const action = async ({ request }: ActionFunctionArgs) =>
7+
logout(request);
78

89
export const loader = async () => redirect("/");

app/routes/notes.$noteId.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ActionArgs, LoaderArgs } from "@remix-run/node";
1+
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
22
import { json, redirect } from "@remix-run/node";
33
import {
44
Form,
@@ -11,7 +11,7 @@ import invariant from "tiny-invariant";
1111
import { deleteNote, getNote } from "~/models/note.server";
1212
import { requireUserId } from "~/session.server";
1313

14-
export const loader = async ({ params, request }: LoaderArgs) => {
14+
export const loader = async ({ params, request }: LoaderFunctionArgs) => {
1515
const userId = await requireUserId(request);
1616
invariant(params.noteId, "noteId not found");
1717

@@ -22,7 +22,7 @@ export const loader = async ({ params, request }: LoaderArgs) => {
2222
return json({ note });
2323
};
2424

25-
export const action = async ({ params, request }: ActionArgs) => {
25+
export const action = async ({ params, request }: ActionFunctionArgs) => {
2626
const userId = await requireUserId(request);
2727
invariant(params.noteId, "noteId not found");
2828

app/routes/notes.new.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import type { ActionArgs } from "@remix-run/node";
1+
import type { ActionFunctionArgs } from "@remix-run/node";
22
import { json, redirect } from "@remix-run/node";
33
import { Form, useActionData } from "@remix-run/react";
44
import { useEffect, useRef } from "react";
55

66
import { createNote } from "~/models/note.server";
77
import { requireUserId } from "~/session.server";
88

9-
export const action = async ({ request }: ActionArgs) => {
9+
export const action = async ({ request }: ActionFunctionArgs) => {
1010
const userId = await requireUserId(request);
1111

1212
const formData = await request.formData();

app/routes/notes.tsx

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

55
import { getNoteListItems } from "~/models/note.server";
66
import { requireUserId } from "~/session.server";
77
import { useUser } from "~/utils";
88

9-
export const loader = async ({ request }: LoaderArgs) => {
9+
export const loader = async ({ request }: LoaderFunctionArgs) => {
1010
const userId = await requireUserId(request);
1111
const noteListItems = await getNoteListItems({ userId });
1212
return json({ noteListItems });

app/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export function useMatchesData(
4141
() => matchingRoutes.find((route) => route.id === id),
4242
[matchingRoutes, id],
4343
);
44-
return route?.data;
44+
return route?.data as Record<string, unknown>;
4545
}
4646

4747
function isUser(user: any): user is User {

0 commit comments

Comments
 (0)