Skip to content

Commit

Permalink
chore(api): fix non-existent next package import
Browse files Browse the repository at this point in the history
  • Loading branch information
PJColombo committed Oct 24, 2024
1 parent 3c6a6a3 commit 8b106dc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/api/src/context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import type { NextApiRequest } from "next";
import { TRPCError } from "@trpc/server";
import type { inferAsyncReturnType } from "@trpc/server";
import type { CreateNextContextOptions } from "@trpc/server/adapters/next";
Expand All @@ -17,6 +16,8 @@ import { env } from "@blobscan/env";

import { posthog } from "./posthog";

type NextHTTPRequest = CreateNextContextOptions["req"];

export type CreateContextOptions =
| NodeHTTPCreateContextFnOptions<NodeHTTPRequest, NodeHTTPResponse>
| CreateNextContextOptions;
Expand All @@ -25,9 +26,7 @@ type CreateInnerContextOptions = Partial<CreateContextOptions> & {
apiClient: string | null;
};

export function getJWTFromRequest(
req: NodeHTTPRequest | CreateNextContextOptions["req"]
) {
export function getJWTFromRequest(req: NodeHTTPRequest | NextHTTPRequest) {
const authHeader = req.headers.authorization;
if (!authHeader) {
return null;
Expand Down Expand Up @@ -63,7 +62,7 @@ export async function createTRPCInnerContext(opts?: CreateInnerContextOptions) {
};
}

function getIP(req: NodeHTTPRequest | NextApiRequest): string | undefined {
function getIP(req: NodeHTTPRequest | NextHTTPRequest): string | undefined {
const ip = req.headers["x-forwarded-for"] ?? req.socket.remoteAddress;

if (Array.isArray(ip)) {
Expand Down

0 comments on commit 8b106dc

Please sign in to comment.