Skip to content

Commit

Permalink
flip apiRoutes and inlineServerFunctions middleware order
Browse files Browse the repository at this point in the history
  • Loading branch information
edivados committed Sep 2, 2023
1 parent 23a2021 commit 7cb0b1e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions packages/start/entry-server/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { composeMiddleware, createHandler, default as StartServer } from "./StartServer";
export { default as StartServer, composeMiddleware, createHandler } from "./StartServer";
export type { Middleware, MiddlewareFn, MiddlewareInput } from "./StartServer";

import { JSX } from "solid-js";
Expand All @@ -21,8 +21,8 @@ export const render = (
}
) =>
composeMiddleware([
apiRoutes,
inlineServerFunctions,
apiRoutes,
import.meta.env.START_SSR === "async"
? _renderAsync(fn, options)
: import.meta.env.START_SSR === "streaming"
Expand All @@ -37,7 +37,7 @@ export const renderAsync = (
nonce?: string;
renderId?: string;
}
) => composeMiddleware([apiRoutes, inlineServerFunctions, _renderAsync(fn, options)]);
) => composeMiddleware([inlineServerFunctions, apiRoutes, _renderAsync(fn, options)]);

export const renderStream = (
fn: (context: PageEvent) => JSX.Element,
Expand All @@ -46,7 +46,7 @@ export const renderStream = (
nonce?: string;
renderId?: string;
}
) => composeMiddleware([apiRoutes, inlineServerFunctions, _renderStream(fn, options)]);
) => composeMiddleware([inlineServerFunctions, apiRoutes, _renderStream(fn, options)]);

export const renderSync = (
fn: (context: PageEvent) => JSX.Element,
Expand All @@ -55,4 +55,4 @@ export const renderSync = (
nonce?: string;
renderId?: string;
}
) => composeMiddleware([apiRoutes, inlineServerFunctions, _renderSync(fn, options)]);
) => composeMiddleware([inlineServerFunctions, apiRoutes, _renderSync(fn, options)]);
14 changes: 7 additions & 7 deletions packages/start/server/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { renderToStream, renderToString, renderToStringAsync } from "solid-js/we
import { apiRoutes } from "../api/middleware";
import { inlineServerFunctions } from "../server/middleware";
import { redirect } from "../server/responses";
import { FetchEvent, FETCH_EVENT, PageEvent } from "../server/types";
import { FETCH_EVENT, FetchEvent, PageEvent } from "../server/types";

export function renderSync(
fn: (context: PageEvent) => JSX.Element,
Expand All @@ -12,8 +12,8 @@ export function renderSync(
renderId?: string;
}
) {
return () => apiRoutes({
forward: inlineServerFunctions({
return () => inlineServerFunctions({
forward: apiRoutes({
async forward(event: FetchEvent): Promise<Response> {
if (
!import.meta.env.DEV &&
Expand Down Expand Up @@ -53,8 +53,8 @@ export function renderAsync(
renderId?: string;
}
) {
return () => apiRoutes({
forward: inlineServerFunctions({
return () => inlineServerFunctions({
forward: apiRoutes({
async forward(event: FetchEvent): Promise<Response> {
if (
!import.meta.env.DEV &&
Expand Down Expand Up @@ -96,8 +96,8 @@ export function renderStream(
onCompleteAll?: (info: { write: (v: string) => void }) => void;
} = {}
) {
return () => apiRoutes({
forward: inlineServerFunctions({
return () => inlineServerFunctions({
forward: apiRoutes({
async forward(event: FetchEvent): Promise<Response> {
if (
!import.meta.env.DEV &&
Expand Down

0 comments on commit 7cb0b1e

Please sign in to comment.