-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
141 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NEXT_PUBLIC_ALOKAI_MIDDLEWARE_API_URL="http://localhost:4000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NEXT_PUBLIC_ALOKAI_MIDDLEWARE_API_URL="http://localhost:4000" |
2 changes: 1 addition & 1 deletion
2
packages/next/__tests__/apps/app-router/app/csr/ClientComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
"use client"; | ||
|
||
import { ReactNode } from "react"; | ||
import { SdkProvider } from "../hooks"; | ||
import { createSdk, type CreateSdkOptions } from "@vue-storefront/next"; | ||
import { SdkProvider } from "../sdk/sdk-provider"; | ||
import { getSdkConfig } from "../sdk/config"; | ||
|
||
export function Providers({ children }: { children: ReactNode }) { | ||
return <SdkProvider>{children}</SdkProvider>; | ||
export function Providers({ | ||
children, | ||
sdkOptions, | ||
}: { | ||
children: ReactNode; | ||
sdkOptions: CreateSdkOptions; | ||
}) { | ||
const { getSdk } = createSdk(sdkOptions, getSdkConfig()); | ||
|
||
return <SdkProvider sdk={getSdk()}>{children}</SdkProvider>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Endpoints } from "@storefront/shared"; | ||
import { defineSdkConfig } from "@vue-storefront/next"; | ||
|
||
export function getSdkConfig() { | ||
return defineSdkConfig(({ buildModule, middlewareModule, config, getRequestHeaders }) => ({ | ||
example: buildModule(middlewareModule<Endpoints>, { | ||
apiUrl: `${config.middlewareUrl}/test_integration`, | ||
defaultRequestConfig: { | ||
headers: getRequestHeaders(), | ||
}, | ||
}), | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { CreateSdkOptions } from "@vue-storefront/next"; | ||
import { env } from "next-runtime-env"; | ||
|
||
export function getSdkOptions() { | ||
return { | ||
middleware: { | ||
apiUrl: env('NEXT_PUBLIC_ALOKAI_MIDDLEWARE_API_URL'), | ||
}, | ||
} satisfies CreateSdkOptions; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use client"; | ||
|
||
import { createSdkContext } from "@vue-storefront/next/client"; | ||
|
||
import type { Sdk } from "./sdk.server"; | ||
|
||
export const [SdkProvider, useSdk] = createSdkContext<Sdk>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { createSdk } from "@vue-storefront/next"; | ||
import { getSdkOptions } from "./options"; | ||
import { getSdkConfig } from "./config"; | ||
|
||
export const { getSdk } = createSdk( | ||
getSdkOptions(), getSdkConfig() | ||
); | ||
|
||
export type Sdk = ReturnType<typeof getSdk>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NEXT_PUBLIC_ALOKAI_MIDDLEWARE_API_URL="http://localhost:4000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
NEXT_PUBLIC_ALOKAI_MIDDLEWARE_API_URL="http://localhost:4000" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,33 @@ | ||
import type { AppProps } from "next/app"; | ||
import { SdkProvider } from "../hooks"; | ||
import { createSdk } from "@vue-storefront/next"; | ||
import { SdkProvider } from "../sdk/sdk-provider"; | ||
import { getSdkOptions } from "../sdk/options"; | ||
import { getSdkConfig } from "../sdk/config"; | ||
import { PublicEnvScript } from "next-runtime-env"; | ||
|
||
export default function App({ Component, pageProps }: AppProps) { | ||
const { getSdk } = createSdk(getSdkOptions(), getSdkConfig()); | ||
|
||
return ( | ||
<SdkProvider> | ||
<nav> | ||
<ul> | ||
<li> | ||
<a href="/ssr">SSR Page</a> | ||
</li> | ||
<li> | ||
<a href="/csr">CSR Page</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
<Component {...pageProps} /> | ||
</SdkProvider> | ||
<html> | ||
<head> | ||
<PublicEnvScript /> | ||
</head> | ||
<body> | ||
<SdkProvider sdk={getSdk()}> | ||
<nav> | ||
<ul> | ||
<li> | ||
<a href="/ssr">SSR Page</a> | ||
</li> | ||
<li> | ||
<a href="/csr">CSR Page</a> | ||
</li> | ||
</ul> | ||
</nav> | ||
<Component {...pageProps} /> | ||
</SdkProvider> | ||
</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { defineSdkConfig } from "@vue-storefront/next"; | ||
import type { Endpoints } from "@storefront/shared"; | ||
|
||
export function getSdkConfig() { | ||
return defineSdkConfig(({ buildModule, middlewareModule, config, getRequestHeaders }) => ({ | ||
example: buildModule(middlewareModule<Endpoints>, { | ||
apiUrl: `${config.middlewareUrl}/test_integration`, | ||
defaultRequestConfig: { | ||
headers: getRequestHeaders(), | ||
}, | ||
}) | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { CreateSdkOptions } from "@vue-storefront/next"; | ||
import { env } from "next-runtime-env"; | ||
|
||
export function getSdkOptions() { | ||
return { | ||
middleware: { | ||
apiUrl: | ||
env("NEXT_PUBLIC_ALOKAI_MIDDLEWARE_API_URL") ?? "http://localhost:4000", | ||
}, | ||
} satisfies CreateSdkOptions; | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/next/__tests__/apps/pages-router/sdk/sdk-provider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use client"; | ||
|
||
import { createSdkContext } from "@vue-storefront/next/client"; | ||
|
||
import type { Sdk } from "./sdk.server"; | ||
|
||
export const [SdkProvider, useSdk] = createSdkContext<Sdk>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { createSdk } from "@vue-storefront/next"; | ||
import { getSdkConfig } from "./config"; | ||
import { getSdkOptions } from "./options"; | ||
|
||
export const { getSdk } = createSdk(getSdkOptions(), getSdkConfig()); | ||
|
||
export type Sdk = ReturnType<typeof getSdk>; |