Skip to content

Commit 6d0f2f8

Browse files
committed
fix: request types
1 parent 3ba59c1 commit 6d0f2f8

3 files changed

Lines changed: 5 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"main": "dist/index.js",
77
"files": ["dist"],
88
"license": "WTFPL",
9-
"version": "1.0.9",
9+
"version": "1.1.0",
1010
"type": "module",
1111
"keywords": [
1212
"auth",

src/client.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { type ClientSession } from "./index";
44
import { getSession } from "./server-actions";
55
import { createContext, useContext, type ReactNode } from "react";
66
import useSWR from "swr";
7-
import { NextRequest, NextResponse } from "next/server";
87

98
interface UserInfoContextType {
109
session: ClientSession | null;
@@ -69,14 +68,14 @@ export function useUserInfo() {
6968
}
7069

7170
export const createSessionProviderRoute = () => {
72-
return async (_request: NextRequest) => {
71+
return async (_request: Request) => {
7372
const session = await getSession();
7473

7574
if (!session) {
76-
return NextResponse.json({ error: "Not logged in" });
75+
return Response.json({ error: "Not logged in" }, { status: 401 });
7776
} else {
7877
const { accessToken, refreshToken, ...clientSession } = session;
79-
return NextResponse.json(clientSession);
78+
return Response.json(clientSession);
8079
}
8180
};
8281
};

types/client.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { ClientSession } from "./index";
22
import type { ReactNode } from "react";
3-
import type { NextRequest } from "next/server";
43

54
interface UserInfoContextType {
65
session: ClientSession | null;
@@ -17,5 +16,5 @@ export declare function UserInfoProvider(props: {
1716
export declare function useUserInfo(): UserInfoContextType;
1817

1918
export declare function createSessionProviderRoute(
20-
request: NextRequest,
19+
request: Request,
2120
): Promise<Response>;

0 commit comments

Comments
 (0)