Skip to content

Commit

Permalink
feat: add skip request option
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewPattell committed Oct 11, 2024
1 parent 320aefb commit 25f69dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/node/entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type ServerConfig from '@services/server-config';
export interface IInitServerRequestOut<T = Record<string, any>> {
appProps?: T;
hasEarlyHints?: boolean;
shouldSkip?: boolean;
}

export interface IEntrypointOptions<TAppProps = Record<string, any>> {
Expand Down
6 changes: 5 additions & 1 deletion src/node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ async function createServer(config: ServerConfig): Promise<ICreateServerOut> {
prepareServer.loadEntrypoint(),
prepareServer.loadHtml(req),
]);
const { appProps, hasEarlyHints } = (await onRequest?.(req, res)) ?? {};
const { appProps, hasEarlyHints, shouldSkip } = (await onRequest?.(req, res)) ?? {};
const [header, footer] = clientHtml;

if (shouldSkip) {
return next();
}

const context: IRequestContext = {
req,
res,
Expand Down

0 comments on commit 25f69dc

Please sign in to comment.