Skip to content

Commit

Permalink
Upgrade from Remix v2 to React Router v7 (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
thdk authored Nov 24, 2024
1 parent d2b211a commit c67147b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Binary file modified bun.lockb
Binary file not shown.
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,13 @@
"uuid": "^11.0.2"
},
"peerDependencies": {
"@remix-run/react": "^1.0.0 || ^2.0.0",
"@remix-run/server-runtime": "^1.0.0 || ^2.0.0"
"react-router": "^7.0.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.0",
"@babel/preset-react": "^7.13.13",
"@biomejs/biome": "^1.8.3",
"@remix-run/node": "^2.0.1",
"@remix-run/react": "^2.0.1",
"@remix-run/serve": "^2.0.1",
"@remix-run/server-runtime": "^2.0.1",
"react-router": "^7.0.1",
"@total-typescript/tsconfig": "^1.0.4",
"@types/bun": "^1.1.6",
"@types/react": "^18.2.20",
Expand Down
8 changes: 6 additions & 2 deletions src/lib/authenticator.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { beforeEach, describe, expect, mock, test } from "bun:test";
import { createCookieSessionStorage } from "@remix-run/node";
import { SessionStorage, redirect } from "@remix-run/server-runtime";
import {
SessionStorage,
createCookieSessionStorage,
redirect,
} from "react-router";

import {
AuthenticateOptions,
Authenticator,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/authenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
type SessionStorage,
isSession,
redirect,
} from "@remix-run/server-runtime";
} from "react-router";
import { type AuthenticateOptions, Strategy } from "./strategy.js";

export type AuthenticateCallback<User> = (user: User) => Promise<Response>;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/strategy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
type AppLoadContext,
type SessionStorage,
json,
data,
redirect,
} from "@remix-run/server-runtime";
} from "react-router";
import { AuthorizationError } from "./error.js";

/**
Expand Down Expand Up @@ -123,7 +123,7 @@ export abstract class Strategy<User, VerifyOptions> {
// if a failureRedirect is not set, we throw a 401 Response or an error
if (!options.failureRedirect) {
if (options.throwOnError) throw new AuthorizationError(message, cause);
throw json<{ message: string }>({ message }, 401);
throw data<{ message: string }>({ message }, 401);
}

let session = await sessionStorage.getSession(
Expand Down

0 comments on commit c67147b

Please sign in to comment.