Skip to content

Commit

Permalink
fix: multipart form proxy (#1987)
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity authored Jan 11, 2025
1 parent 224530a commit 3be5ab0
Show file tree
Hide file tree
Showing 22 changed files with 180 additions and 679 deletions.

This file was deleted.

102 changes: 0 additions & 102 deletions packages/fern-docs/bundle/src/app/api/fern-docs/proxy/rest/route.ts

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions packages/fern-docs/ui/src/hooks/useStandardProxyEnvironment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { withDefaultProtocol } from "@fern-api/ui-core-utils";
import { once } from "es-toolkit/function";
import { useBasePath, useEdgeFlags } from "../atoms";
import { useApiRoute } from "./useApiRoute";

const APP_BUILDWITHFERN_COM = "app.buildwithfern.com";

Expand All @@ -23,12 +21,3 @@ export const getAppBuildwithfernCom = once((): string => {

return withDefaultProtocol(APP_BUILDWITHFERN_COM);
});

export function useStandardProxyEnvironment(): string {
const basePath = useBasePath();
const { proxyShouldUseAppBuildwithfernCom } = useEdgeFlags();
const proxyBasePath = proxyShouldUseAppBuildwithfernCom
? getAppBuildwithfernCom()
: basePath;
return useApiRoute("/api/fern-docs/proxy", { basepath: proxyBasePath });
}
1 change: 0 additions & 1 deletion packages/fern-docs/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export * from "./docs/DocsPage";
export * from "./docs/NextApp";
export { getApiRouteSupplier } from "./hooks/useApiRoute";
export * from "./mdx/types";
export { Stream } from "./playground/Stream";
export { ProxyRequestSchema } from "./playground/types";
export type {
ProxyRequest,
Expand Down
20 changes: 2 additions & 18 deletions packages/fern-docs/ui/src/playground/PlaygroundRequestPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
PLAYGROUND_AUTH_STATE_OAUTH_ATOM,
useEdgeFlags,
} from "../atoms";
import { useStandardProxyEnvironment } from "../hooks/useStandardProxyEnvironment";
import { PlaygroundCodeSnippetResolverBuilder } from "./code-snippets/resolver";
import { useSnippet } from "./code-snippets/useSnippet";
import { PlaygroundEndpointRequestFormState } from "./types";
Expand Down Expand Up @@ -39,27 +38,12 @@ export const PlaygroundRequestPreview: FC<PlaygroundRequestPreviewProps> = ({
),
[context, isSnippetTemplatesEnabled, isFileForgeHackEnabled]
);
const proxyEnvironment = useStandardProxyEnvironment();

const resolver = useMemo(
() =>
oAuthValue &&
builder.createRedacted(
authState,
formState,
proxyEnvironment,
baseUrl,
setOAuthValue
),
[
authState,
builder,
formState,
proxyEnvironment,
oAuthValue,
baseUrl,
setOAuthValue,
]
builder.createRedacted(authState, formState, baseUrl, setOAuthValue),
[authState, builder, formState, oAuthValue, baseUrl, setOAuthValue]
);
const code = useSnippet(resolver, requestType);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ export const PlaygroundResponsePreview: FC<PlaygroundResponsePreviewProps> = ({
}) => {
const responseJson = useMemo(
() =>
response.type === "stream"
typeof response.response.body === "string"
? response.response.body
: response.type === "file"
? ""
: typeof response.response.body === "string"
? response.response.body
: JSON.stringify(response.response.body, null, 2),
: JSON.stringify(response.response.body, null, 2),
[response]
);
const viewportRef = useRef<ScrollToHandle>(null);
Expand Down
48 changes: 0 additions & 48 deletions packages/fern-docs/ui/src/playground/Stream.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
PLAYGROUND_AUTH_STATE_OAUTH_ATOM,
usePlaygroundEndpointFormState,
} from "../../atoms";
import { useStandardProxyEnvironment } from "../../hooks/useStandardProxyEnvironment";
import { Callout } from "../../mdx/components/callout";
import { PasswordInputGroup } from "../PasswordInputGroup";
import { PlaygroundEndpointForm } from "../endpoint";
Expand All @@ -39,7 +38,6 @@ function FoundOAuthReferencedEndpointForm({
disabled?: boolean;
}): ReactElement {
const [value, setValue] = useAtom(PLAYGROUND_AUTH_STATE_OAUTH_ATOM);
const proxyEnvironment = useStandardProxyEnvironment();
const [formState, setFormState] = usePlaygroundEndpointFormState(context);
const [baseUrl] = usePlaygroundBaseUrl(context.endpoint);

Expand All @@ -53,7 +51,6 @@ function FoundOAuthReferencedEndpointForm({
await oAuthClientCredentialReferencedEndpointLoginFlow({
formState,
endpoint: context.endpoint,
proxyEnvironment,
referencedEndpoint,
baseUrl,
setValue,
Expand Down
Loading

0 comments on commit 3be5ab0

Please sign in to comment.