Skip to content

Commit

Permalink
rename Func to Fn + minor typing
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenlautier committed Sep 10, 2024
1 parent ba0c5ba commit b700055
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib/prerendering/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { BootFunc, BootFuncParams, RenderToStringResult, RenderResult, RedirectResult } from "./prerendering.model";
export { BootFn, BootFuncParams, RenderToStringResult, RenderResult, RedirectResult } from "./prerendering.model";
export { createServerRenderer } from "./prerendering";
4 changes: 2 additions & 2 deletions src/lib/prerendering/prerendering.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface RenderToStringFunc {
export interface RenderToStringFn {
(
// callback: RenderToStringCallback,
applicationBasePath: string,
Expand Down Expand Up @@ -27,7 +27,7 @@ export interface RedirectResult {

export type RenderResult = RenderToStringResult | RedirectResult;

export interface BootFunc {
export interface BootFn {
(params: BootFuncParams): Promise<RenderResult>;
}

Expand Down
10 changes: 6 additions & 4 deletions src/lib/prerendering/prerendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import * as url from "url";
import * as domain from "domain";
import { run as domainTaskRun, baseUrl as domainTaskBaseUrl } from "domain-task/main";

import { BootFunc, BootFuncParams, BootModuleInfo, RenderResult, RenderToStringFunc } from "./prerendering.model";
import { BootFn, BootFuncParams, BootModuleInfo, RenderResult, RenderToStringFn } from "./prerendering.model";

const defaultTimeoutMilliseconds = 30 * 1000;

// REF: https://github.com/aspnet/JavaScriptServices/blob/master/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-prerendering/src/Prerendering.ts
export function createServerRenderer(bootFunc: BootFunc): RenderToStringFunc {
const resultFunc = (
// REF: based on https://github.com/aspnet/JavaScriptServices/blob/master/src/Microsoft.AspNetCore.SpaServices/npm/aspnet-prerendering/src/Prerendering.ts
export function createServerRenderer(bootFunc: BootFn): RenderToStringFn {
console.warn(">>>> createServerRenderer PRE FN x2");
const resultFunc: RenderToStringFn & { isServerRenderer: boolean } = (
// callback: RenderToStringCallback,
applicationBasePath: string,
bootModule: BootModuleInfo,
Expand All @@ -19,6 +20,7 @@ export function createServerRenderer(bootFunc: BootFunc): RenderToStringFunc {
overrideTimeoutMilliseconds: number,
requestPathBase: string
) => {
console.warn(">>>> createServerRenderer applicationBasePath", applicationBasePath);
let renderPromiseResolve: (value?: RenderResult) => void;
let renderPromiseReject: (reason?: any) => void;
const renderPromise = new Promise<RenderResult>((resolve, reject) => {
Expand Down

0 comments on commit b700055

Please sign in to comment.