Skip to content

Commit 9871d06

Browse files
committed
refactor(showcase): rename getRuntimeConfigEdge to getRuntimeConfigForMiddleware
Clarify the wrapper's role (it forces noStore:false because unstable_noStore is unavailable in middleware/Edge). Pure rename across shell, shell-docs, and shell-dashboard: definitions, middleware call sites, and tests. No behavior change.
1 parent f2f3f6d commit 9871d06

8 files changed

Lines changed: 20 additions & 20 deletions

File tree

showcase/shell-dashboard/src/lib/runtime-config.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe("server getRuntimeConfig (shell-dashboard)", () => {
120120
expect(cfg.opsBaseUrl).toBe("https://primary-ops.example.com");
121121
});
122122

123-
it("getRuntimeConfigEdge skips noStore() (Edge runtime path)", async () => {
123+
it("getRuntimeConfigForMiddleware skips noStore() (Edge runtime path)", async () => {
124124
// Confirm the Edge wrapper passes `{ noStore: false }`.
125125
// Reach into the mocked module to assert noStore was NOT called
126126
// on this path, while the default getRuntimeConfig() above DID
@@ -132,8 +132,8 @@ describe("server getRuntimeConfig (shell-dashboard)", () => {
132132
process.env.SHELL_URL = "https://edge-shell.example.com";
133133
process.env.OPS_BASE_URL = "https://edge-ops.example.com";
134134

135-
const { getRuntimeConfigEdge } = await import("./runtime-config");
136-
const cfg = getRuntimeConfigEdge();
135+
const { getRuntimeConfigForMiddleware } = await import("./runtime-config");
136+
const cfg = getRuntimeConfigForMiddleware();
137137
expect(cfg.pocketbaseUrl).toBe("https://edge.example.com");
138138
expect(noStoreSpy).not.toHaveBeenCalled();
139139

showcase/shell-dashboard/src/lib/runtime-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const PROD_INVALID_SHELL_URL = "about:blank#shell-url-missing";
4242
* the build artifact. The Edge runtime (middleware) MUST pass
4343
* `{ noStore: false }` — `unstable_noStore()` is unavailable there, and
4444
* middleware always runs per-request by definition so there is no
45-
* static cache to opt out of. The thin `getRuntimeConfigEdge()` wrapper
45+
* static cache to opt out of. The thin `getRuntimeConfigForMiddleware()` wrapper
4646
* below makes this explicit at the call site.
4747
*/
4848
export function getRuntimeConfig(
@@ -86,7 +86,7 @@ export function getRuntimeConfig(
8686
* `getRuntimeConfig` — otherwise the Edge bundle pulls in `next/cache`
8787
* and the build fails with "module not found in edge runtime."
8888
*/
89-
export function getRuntimeConfigEdge(): RuntimeConfig {
89+
export function getRuntimeConfigForMiddleware(): RuntimeConfig {
9090
return getRuntimeConfig({ noStore: false });
9191
}
9292

showcase/shell-docs/src/lib/runtime-config.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ vi.mock("next/cache", () => ({
88
unstable_noStore: () => {},
99
}));
1010

11-
import { getRuntimeConfig, getRuntimeConfigEdge } from "./runtime-config";
11+
import { getRuntimeConfig, getRuntimeConfigForMiddleware } from "./runtime-config";
1212

1313
const URL_KEYS = [
1414
"NEXT_PUBLIC_BASE_URL",
@@ -246,7 +246,7 @@ describe("server getRuntimeConfig (shell-docs)", () => {
246246
expect(cfg.posthogHost).toBe("https://primary-ph.example.com");
247247
});
248248

249-
it("getRuntimeConfigEdge skips noStore() (Edge runtime path)", async () => {
249+
it("getRuntimeConfigForMiddleware skips noStore() (Edge runtime path)", async () => {
250250
const cacheMod = await import("next/cache");
251251
const noStoreSpy = vi.spyOn(cacheMod, "unstable_noStore");
252252
(process.env as Record<string, string>).NODE_ENV = "production";
@@ -256,7 +256,7 @@ describe("server getRuntimeConfig (shell-docs)", () => {
256256
"https://edge-signup.example.com";
257257
process.env.NEXT_PUBLIC_POSTHOG_HOST = "https://edge-ph.example.com";
258258

259-
const cfg = getRuntimeConfigEdge();
259+
const cfg = getRuntimeConfigForMiddleware();
260260
expect(cfg.baseUrl).toBe("https://edge.example.com");
261261
expect(noStoreSpy).not.toHaveBeenCalled();
262262

showcase/shell-docs/src/lib/runtime-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const PROD_DEFAULT_POSTHOG_HOST = "https://eu.i.posthog.com";
6363
* into the build artifact. The Edge runtime (middleware) MUST pass
6464
* `{ noStore: false }` — `unstable_noStore()` is unavailable there,
6565
* and middleware always runs per-request by definition so there is no
66-
* static cache to opt out of. The thin `getRuntimeConfigEdge()`
66+
* static cache to opt out of. The thin `getRuntimeConfigForMiddleware()`
6767
* wrapper below makes this explicit at the call site.
6868
*/
6969
export function getRuntimeConfig(
@@ -134,7 +134,7 @@ export function getRuntimeConfig(
134134
* `getRuntimeConfig` — otherwise the Edge bundle pulls in `next/cache`
135135
* and the build fails with "module not found in edge runtime."
136136
*/
137-
export function getRuntimeConfigEdge(): RuntimeConfig {
137+
export function getRuntimeConfigForMiddleware(): RuntimeConfig {
138138
return getRuntimeConfig({ noStore: false });
139139
}
140140

showcase/shell-docs/src/middleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
22
import type { NextFetchEvent, NextRequest } from "next/server";
33
import { seoRedirects } from "@/lib/seo-redirects";
44
import { stripRouteGroupSegmentsFromPathname } from "@/lib/route-groups";
5-
import { getRuntimeConfigEdge } from "@/lib/runtime-config";
5+
import { getRuntimeConfigForMiddleware } from "@/lib/runtime-config";
66
import registry from "@/data/registry.json";
77

88
// ---------------------------------------------------------------------------
@@ -67,7 +67,7 @@ for (const entry of seoRedirects) {
6767
// changing NEXT_PUBLIC_POSTHOG_HOST. The reader applies the same
6868
// `https://eu.i.posthog.com` fallback used before.
6969
function getPosthogHost(): string {
70-
return getRuntimeConfigEdge().posthogHost;
70+
return getRuntimeConfigForMiddleware().posthogHost;
7171
}
7272
const DISTINCT_ID_COOKIE = "ph_distinct_id";
7373
// ~2 years — long enough to meaningfully track returning visitors.

showcase/shell/src/lib/runtime-config.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ describe("server getRuntimeConfig (shell)", () => {
119119
expect(cfg.posthogHost).toBe("https://alt-ph.example.com");
120120
});
121121

122-
it("getRuntimeConfigEdge skips noStore() (Edge runtime path)", async () => {
122+
it("getRuntimeConfigForMiddleware skips noStore() (Edge runtime path)", async () => {
123123
const cacheMod = await import("next/cache");
124124
const noStoreSpy = vi.spyOn(cacheMod, "unstable_noStore");
125125
(process.env as Record<string, string>).NODE_ENV = "production";
126126
process.env.BASE_URL = "https://edge.example.com";
127127
process.env.POSTHOG_HOST = "https://edge-posthog.example.com";
128128

129-
const { getRuntimeConfigEdge } = await import("./runtime-config");
130-
const cfg = getRuntimeConfigEdge();
129+
const { getRuntimeConfigForMiddleware } = await import("./runtime-config");
130+
const cfg = getRuntimeConfigForMiddleware();
131131
expect(cfg.baseUrl).toBe("https://edge.example.com");
132132
expect(noStoreSpy).not.toHaveBeenCalled();
133133

showcase/shell/src/lib/runtime-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const PROD_INVALID_BASE_URL = "about:blank#shell-base-url-missing";
3838
* the build artifact. The Edge runtime (middleware) MUST pass
3939
* `{ noStore: false }` — `unstable_noStore()` is unavailable there, and
4040
* middleware always runs per-request by definition so there is no
41-
* static cache to opt out of. The thin `getRuntimeConfigEdge()` wrapper
41+
* static cache to opt out of. The thin `getRuntimeConfigForMiddleware()` wrapper
4242
* below makes this explicit at the call site.
4343
*/
4444
export function getRuntimeConfig(
@@ -71,7 +71,7 @@ export function getRuntimeConfig(
7171
* `getRuntimeConfig` — otherwise the Edge bundle pulls in `next/cache`
7272
* and the build fails with "module not found in edge runtime."
7373
*/
74-
export function getRuntimeConfigEdge(): RuntimeConfig {
74+
export function getRuntimeConfigForMiddleware(): RuntimeConfig {
7575
return getRuntimeConfig({ noStore: false });
7676
}
7777

showcase/shell/src/middleware.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NextResponse } from "next/server";
22
import type { NextRequest } from "next/server";
33
import { seoRedirects } from "@/lib/seo-redirects";
4-
import { getRuntimeConfigEdge } from "@/lib/runtime-config";
4+
import { getRuntimeConfigForMiddleware } from "@/lib/runtime-config";
55
import registry from "@/data/registry.json";
66

77
// ---------------------------------------------------------------------------
@@ -55,8 +55,8 @@ function trackRedirect(id: string, fromPath: string, toPath: string): void {
5555

5656
// Read the PostHog host from the Edge-safe runtime config (live
5757
// process.env at request time, no `next/cache` import — see
58-
// getRuntimeConfigEdge in src/lib/runtime-config.ts).
59-
const posthogHost = getRuntimeConfigEdge().posthogHost;
58+
// getRuntimeConfigForMiddleware in src/lib/runtime-config.ts).
59+
const posthogHost = getRuntimeConfigForMiddleware().posthogHost;
6060

6161
// Fire-and-forget — don't await
6262
fetch(`${posthogHost}/capture/`, {

0 commit comments

Comments
 (0)