refactor: replace references of options with config (#1903)

This commit is contained in:
Asher Gomez
2023-10-11 09:25:03 +02:00
committed by GitHub
parent 1d12853889
commit 6ddef91d95
28 changed files with 138 additions and 127 deletions
+5 -11
View File
@@ -8,22 +8,16 @@ In this page we discuss how the server can be configured during startup.
The signature of the primary method looks like this: The signature of the primary method looks like this:
```ts main.ts ```ts main.ts
export async function start(manifest: Manifest, opts: StartOptions = {}); export async function start(manifest: Manifest, config: FreshConfig = {});
``` ```
## Options ## Configuration
`Manifest` comes from `fresh.gen.ts`, so nothing to do there. `opts` is where `Manifest` comes from `fresh.gen.ts`, so nothing to do there. `config` is where
things get interesting. `StartOptions` looks like this: things get interesting. `FreshConfig` looks like this:
```
export type StartOptions = ServeInit & FreshOptions;
```
The good stuff is really in...
```ts ```ts
export interface FreshOptions { export interface FreshConfig {
render?: RenderFunction; render?: RenderFunction;
plugins?: Plugin[]; plugins?: Plugin[];
staticDir?: string; staticDir?: string;
@@ -35,7 +35,7 @@ passing the extra folder as an argument: `--watch=static/`. You should also add
`routes/` to the watch list, so that the server restarts automatically whenever `routes/` to the watch list, so that the server restarts automatically whenever
you add a new route. you add a new route.
If you want to change the port or host, modify the options bag of the `start()` If you want to change the port or host, modify the config bag of the `start()`
call in `main.ts` to include an explicit port number: call in `main.ts` to include an explicit port number:
```js main.ts ```js main.ts
+2 -2
View File
@@ -3,10 +3,10 @@ import { join } from "../server/deps.ts";
import { colors, fs } from "./deps.ts"; import { colors, fs } from "./deps.ts";
import { BuildSnapshotJson } from "../build/mod.ts"; import { BuildSnapshotJson } from "../build/mod.ts";
import { BUILD_ID } from "../server/build_id.ts"; import { BUILD_ID } from "../server/build_id.ts";
import { InternalFreshOptions } from "../server/types.ts"; import { InternalFreshConfig } from "../server/types.ts";
export async function build( export async function build(
config: InternalFreshOptions, config: InternalFreshConfig,
) { ) {
// Ensure that build dir is empty // Ensure that build dir is empty
await fs.emptyDir(config.build.outDir); await fs.emptyDir(config.build.outDir);
+15 -15
View File
@@ -1,6 +1,6 @@
import { updateCheck } from "./update_check.ts"; import { updateCheck } from "./update_check.ts";
import { DAY, dirname, fromFileUrl, join, toFileUrl } from "./deps.ts"; import { DAY, dirname, fromFileUrl, join, toFileUrl } from "./deps.ts";
import { FreshOptions, Manifest as ServerManifest } from "../server/mod.ts"; import { FreshConfig, Manifest as ServerManifest } from "../server/mod.ts";
import { build } from "./build.ts"; import { build } from "./build.ts";
import { collect, ensureMinDenoVersion, generate, Manifest } from "./mod.ts"; import { collect, ensureMinDenoVersion, generate, Manifest } from "./mod.ts";
import { startFromContext } from "../server/boot.ts"; import { startFromContext } from "../server/boot.ts";
@@ -10,7 +10,7 @@ import { getServerContext } from "$fresh/src/server/context.ts";
export async function dev( export async function dev(
base: string, base: string,
entrypoint: string, entrypoint: string,
options?: FreshOptions, config?: FreshConfig,
) { ) {
ensureMinDenoVersion(); ensureMinDenoVersion();
@@ -26,7 +26,7 @@ export async function dev(
} else { } else {
currentManifest = { islands: [], routes: [] }; currentManifest = { islands: [], routes: [] };
} }
const newManifest = await collect(dir, options?.router?.ignoreFilePattern); const newManifest = await collect(dir, config?.router?.ignoreFilePattern);
Deno.env.set("FRSH_DEV_PREVIOUS_MANIFEST", JSON.stringify(newManifest)); Deno.env.set("FRSH_DEV_PREVIOUS_MANIFEST", JSON.stringify(newManifest));
const manifestChanged = const manifestChanged =
@@ -39,22 +39,22 @@ export async function dev(
.default as ServerManifest; .default as ServerManifest;
if (Deno.args.includes("build")) { if (Deno.args.includes("build")) {
const config = await getFreshConfigWithDefaults( const configWithDefaults = await getFreshConfigWithDefaults(
manifest, manifest,
options ?? {}, config ?? {},
); );
config.dev = false; configWithDefaults.dev = false;
config.loadSnapshot = false; configWithDefaults.loadSnapshot = false;
await build(config); await build(configWithDefaults);
} else if (options) { } else if (config) {
const config = await getFreshConfigWithDefaults( const configWithDefaults = await getFreshConfigWithDefaults(
manifest, manifest,
options, config,
); );
config.dev = true; configWithDefaults.dev = true;
config.loadSnapshot = false; configWithDefaults.loadSnapshot = false;
const ctx = await getServerContext(config); const ctx = await getServerContext(configWithDefaults);
await startFromContext(ctx, config.server); await startFromContext(ctx, configWithDefaults.server);
} else { } else {
// Legacy entry point: Back then `dev.ts` would call `main.ts` but // Legacy entry point: Back then `dev.ts` would call `main.ts` but
// this causes duplicate plugin instantiation if both `dev.ts` and // this causes duplicate plugin instantiation if both `dev.ts` and
+34 -34
View File
@@ -1,6 +1,6 @@
import { dirname, fromFileUrl, isAbsolute, join, JSONC } from "./deps.ts"; import { dirname, fromFileUrl, isAbsolute, join, JSONC } from "./deps.ts";
import { FromManifestOptions, Manifest } from "./mod.ts"; import { FromManifestConfig, Manifest } from "./mod.ts";
import { DenoConfig, InternalFreshOptions } from "./types.ts"; import { DenoConfig, InternalFreshConfig } from "./types.ts";
export async function readDenoConfig( export async function readDenoConfig(
directory: string, directory: string,
@@ -39,8 +39,8 @@ function isObject(value: unknown) {
export async function getFreshConfigWithDefaults( export async function getFreshConfigWithDefaults(
manifest: Manifest, manifest: Manifest,
opts: FromManifestOptions, config: FromManifestConfig,
): Promise<InternalFreshOptions> { ): Promise<InternalFreshConfig> {
const base = dirname(fromFileUrl(manifest.baseUrl)); const base = dirname(fromFileUrl(manifest.baseUrl));
const { config: denoJson, path: denoJsonPath } = await readDenoConfig(base); const { config: denoJson, path: denoJsonPath } = await readDenoConfig(base);
@@ -50,59 +50,59 @@ export async function getFreshConfigWithDefaults(
); );
} }
const config: InternalFreshOptions = { const internalConfig: InternalFreshConfig = {
loadSnapshot: typeof opts.skipSnapshot === "boolean" loadSnapshot: typeof config.skipSnapshot === "boolean"
? !opts.skipSnapshot ? !config.skipSnapshot
: false, : false,
dev: opts.dev ?? false, dev: config.dev ?? false,
denoJsonPath, denoJsonPath,
denoJson, denoJson,
manifest, manifest,
build: { build: {
outDir: "", outDir: "",
target: opts.build?.target ?? ["chrome99", "firefox99", "safari15"], target: config.build?.target ?? ["chrome99", "firefox99", "safari15"],
}, },
plugins: opts.plugins ?? [], plugins: config.plugins ?? [],
staticDir: "", staticDir: "",
render: opts.render, render: config.render,
router: opts.router, router: config.router,
server: opts.server ?? {}, server: config.server ?? {},
}; };
if (opts.cert) { if (config.cert) {
config.server.cert = opts.cert; internalConfig.server.cert = config.cert;
} }
if (opts.hostname) { if (config.hostname) {
config.server.hostname = opts.hostname; internalConfig.server.hostname = config.hostname;
} }
if (opts.key) { if (config.key) {
config.server.key = opts.key; internalConfig.server.key = config.key;
} }
if (opts.onError) { if (config.onError) {
config.server.onError = opts.onError; internalConfig.server.onError = config.onError;
} }
if (opts.onListen) { if (config.onListen) {
config.server.onListen = opts.onListen; internalConfig.server.onListen = config.onListen;
} }
if (opts.port) { if (config.port) {
config.server.port = opts.port; internalConfig.server.port = config.port;
} }
if (opts.reusePort) { if (config.reusePort) {
config.server.reusePort = opts.reusePort; internalConfig.server.reusePort = config.reusePort;
} }
if (opts.signal) { if (config.signal) {
config.server.signal = opts.signal; internalConfig.server.signal = config.signal;
} }
config.build.outDir = opts.build?.outDir internalConfig.build.outDir = config.build?.outDir
? parseFileOrUrl(opts.build.outDir, base) ? parseFileOrUrl(config.build.outDir, base)
: join(base, "_fresh"); : join(base, "_fresh");
config.staticDir = opts.staticDir internalConfig.staticDir = config.staticDir
? parseFileOrUrl(opts.staticDir, base) ? parseFileOrUrl(config.staticDir, base)
: join(base, "static"); : join(base, "static");
return config; return internalConfig;
} }
function parseFileOrUrl(input: string, base: string) { function parseFileOrUrl(input: string, base: string) {
+18 -11
View File
@@ -9,7 +9,7 @@ import {
} from "./deps.ts"; } from "./deps.ts";
import { ComponentType, h } from "preact"; import { ComponentType, h } from "preact";
import * as router from "./router.ts"; import * as router from "./router.ts";
import { Manifest } from "./mod.ts"; import { FreshConfig, Manifest } from "./mod.ts";
import { ALIVE_URL, JS_PREFIX, REFRESH_JS_URL } from "./constants.ts"; import { ALIVE_URL, JS_PREFIX, REFRESH_JS_URL } from "./constants.ts";
import { BUILD_ID, setBuildId } from "./build_id.ts"; import { BUILD_ID, setBuildId } from "./build_id.ts";
import DefaultErrorHandler from "./default_error_page.tsx"; import DefaultErrorHandler from "./default_error_page.tsx";
@@ -18,9 +18,8 @@ import {
BaseRoute, BaseRoute,
ErrorPage, ErrorPage,
ErrorPageModule, ErrorPageModule,
FreshOptions,
Handler, Handler,
InternalFreshOptions, InternalFreshConfig,
Island, Island,
LayoutModule, LayoutModule,
LayoutRoute, LayoutRoute,
@@ -79,12 +78,17 @@ interface StaticFile {
etag: string; etag: string;
} }
export type FromManifestOptions = FreshOptions & { /**
* @deprecated Use {@linkcode FromManifestConfig} instead
*/
export type FromManifestOptions = FromManifestConfig;
export type FromManifestConfig = FreshConfig & {
skipSnapshot?: boolean; skipSnapshot?: boolean;
dev?: boolean; dev?: boolean;
}; };
export async function getServerContext(opts: InternalFreshOptions) { export async function getServerContext(opts: InternalFreshConfig) {
const { manifest, denoJson: config, denoJsonPath: configPath } = opts; const { manifest, denoJson: config, denoJsonPath: configPath } = opts;
// Get the manifest' base URL. // Get the manifest' base URL.
const baseUrl = new URL("./", manifest.baseUrl).href; const baseUrl = new URL("./", manifest.baseUrl).href;
@@ -455,18 +459,21 @@ export class ServerContext {
*/ */
static async fromManifest( static async fromManifest(
manifest: Manifest, manifest: Manifest,
opts: FromManifestOptions, config: FromManifestConfig,
): Promise<ServerContext> { ): Promise<ServerContext> {
const isLegacyDev = Deno.env.get("__FRSH_LEGACY_DEV") === "true"; const isLegacyDev = Deno.env.get("__FRSH_LEGACY_DEV") === "true";
opts.dev = isLegacyDev || config.dev = isLegacyDev ||
Boolean(opts.dev); Boolean(config.dev);
if (isLegacyDev) { if (isLegacyDev) {
opts.skipSnapshot = true; config.skipSnapshot = true;
} }
const config = await getFreshConfigWithDefaults(manifest, opts); const configWithDefaults = await getFreshConfigWithDefaults(
return getServerContext(config); manifest,
config,
);
return getServerContext(configWithDefaults);
} }
/** /**
+2 -2
View File
@@ -2,14 +2,14 @@ import { ComponentChildren } from "preact";
import { import {
AsyncLayout, AsyncLayout,
AsyncRoute, AsyncRoute,
FreshConfig,
LayoutContext, LayoutContext,
RouteContext, RouteContext,
StartOptions,
} from "./types.ts"; } from "./types.ts";
import { checkAsyncComponent } from "./render.ts"; import { checkAsyncComponent } from "./render.ts";
import { AppContext } from "$fresh/server.ts"; import { AppContext } from "$fresh/server.ts";
export function defineConfig(config: StartOptions): StartOptions { export function defineConfig(config: FreshConfig): FreshConfig {
return config; return config;
} }
+8 -7
View File
@@ -1,8 +1,9 @@
import { ServerContext } from "./context.ts"; import { ServerContext } from "./context.ts";
export type { FromManifestOptions } from "./context.ts"; export type { FromManifestConfig, FromManifestOptions } from "./context.ts";
export { Status } from "./deps.ts"; export { Status } from "./deps.ts";
import { import {
ErrorHandler, ErrorHandler,
FreshConfig,
Handler, Handler,
Handlers, Handlers,
IslandModule, IslandModule,
@@ -10,7 +11,6 @@ import {
MiddlewareModule, MiddlewareModule,
RouteConfig, RouteConfig,
ServeHandlerInfo, ServeHandlerInfo,
StartOptions,
UnknownHandler, UnknownHandler,
} from "./types.ts"; } from "./types.ts";
import { startFromContext } from "./boot.ts"; import { startFromContext } from "./boot.ts";
@@ -27,6 +27,7 @@ export type {
ErrorHandler, ErrorHandler,
ErrorHandlerContext, ErrorHandlerContext,
ErrorPageProps, ErrorPageProps,
FreshConfig,
FreshOptions, FreshOptions,
Handler, Handler,
HandlerContext, HandlerContext,
@@ -86,19 +87,19 @@ export { ServerContext };
export async function createHandler( export async function createHandler(
manifest: Manifest, manifest: Manifest,
opts: StartOptions = {}, config: FreshConfig = {},
): Promise< ): Promise<
(req: Request, connInfo?: ServeHandlerInfo) => Promise<Response> (req: Request, connInfo?: ServeHandlerInfo) => Promise<Response>
> { > {
const ctx = await ServerContext.fromManifest(manifest, opts); const ctx = await ServerContext.fromManifest(manifest, config);
return ctx.handler(); return ctx.handler();
} }
export async function start(manifest: Manifest, opts: StartOptions = {}) { export async function start(manifest: Manifest, config: FreshConfig = {}) {
const ctx = await ServerContext.fromManifest(manifest, { const ctx = await ServerContext.fromManifest(manifest, {
...opts, ...config,
skipSnapshot: false, skipSnapshot: false,
dev: false, dev: false,
}); });
await startFromContext(ctx, opts.server ?? opts); await startFromContext(ctx, config.server ?? config);
} }
+11 -3
View File
@@ -23,9 +23,17 @@ export interface DenoConfig {
// --- APPLICATION CONFIGURATION --- // --- APPLICATION CONFIGURATION ---
export type StartOptions = FreshOptions; /**
* @deprecated Use {@linkcode FreshConfig} instead
*/
export type StartOptions = FreshConfig;
export interface FreshOptions { /**
* @deprecated Use {@linkcode FreshConfig} interface instead.
*/
export type FreshOptions = FreshConfig;
export interface FreshConfig {
build?: { build?: {
/** /**
* The directory to write generated files to when `dev.ts build` is run. * The directory to write generated files to when `dev.ts build` is run.
@@ -100,7 +108,7 @@ export interface FreshOptions {
onListen?: (params: { hostname: string; port: number }) => void; onListen?: (params: { hostname: string; port: number }) => void;
} }
export interface InternalFreshOptions { export interface InternalFreshConfig {
dev: boolean; dev: boolean;
loadSnapshot: boolean; loadSnapshot: boolean;
denoJsonPath: string; denoJsonPath: string;
@@ -1,4 +1,4 @@
import { FreshOptions } from "$fresh/server.ts"; import { FreshConfig } from "$fresh/server.ts";
export default { export default {
async render(_ctx, render) { async render(_ctx, render) {
@@ -8,4 +8,4 @@ export default {
throw new Error("body is missing"); throw new Error("body is missing");
} }
}, },
} as FreshOptions; } as FreshConfig;
+2 -2
View File
@@ -6,6 +6,6 @@
import { start } from "$fresh/server.ts"; import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts"; import manifest from "./fresh.gen.ts";
import options from "./options.ts"; import config from "./fresh.config.ts";
await start(manifest, options); await start(manifest, config);
+2 -2
View File
@@ -6,7 +6,7 @@
import { start } from "$fresh/server.ts"; import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts"; import manifest from "./fresh.gen.ts";
import options from "./options.ts"; import config from "./fresh.config.ts";
// this just exists to function as a type check to assert that we can actually pass a key and cert in // this just exists to function as a type check to assert that we can actually pass a key and cert in
await start(manifest, { ...options, key: "test", cert: "test" }); await start(manifest, { ...config, key: "test", cert: "test" });
+2 -2
View File
@@ -9,6 +9,6 @@
import "./polyfill_deno_deploy.ts"; import "./polyfill_deno_deploy.ts";
import { start } from "$fresh/server.ts"; import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts"; import manifest from "./fresh.gen.ts";
import options from "./options.ts"; import config from "./fresh.config.ts";
await start(manifest, options); await start(manifest, config);
@@ -1,4 +1,4 @@
import { FreshOptions } from "$fresh/server.ts"; import { FreshConfig } from "$fresh/server.ts";
import cssInjectPlugin from "./utils/css-inject-plugin.ts"; import cssInjectPlugin from "./utils/css-inject-plugin.ts";
import jsInjectPlugin from "./utils/js-inject-plugin.ts"; import jsInjectPlugin from "./utils/js-inject-plugin.ts";
import cssInjectPluginAsync from "./utils/css-inject-plugin-async.ts"; import cssInjectPluginAsync from "./utils/css-inject-plugin-async.ts";
@@ -13,4 +13,4 @@ export default {
routePlugin({ title: "Title Set From Plugin Config" }), routePlugin({ title: "Title Set From Plugin Config" }),
secondMiddlewarePlugin(), secondMiddlewarePlugin(),
], ],
} as FreshOptions; } as FreshConfig;
+3 -2
View File
@@ -6,5 +6,6 @@
import { start } from "$fresh/server.ts"; import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts"; import manifest from "./fresh.gen.ts";
import options from "./options.ts"; import config from "./fresh.config.ts";
await start(manifest, options);
await start(manifest, config);
@@ -1,4 +1,4 @@
import { FreshOptions } from "$fresh/server.ts"; import { FreshConfig } from "$fresh/server.ts";
export default { export default {
async render(_ctx, render) { async render(_ctx, render) {
@@ -8,4 +8,4 @@ export default {
throw new Error("body is missing"); throw new Error("body is missing");
} }
}, },
} as FreshOptions; } as FreshConfig;
+2 -2
View File
@@ -6,6 +6,6 @@
import { start } from "$fresh/server.ts"; import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts"; import manifest from "./fresh.gen.ts";
import options from "./options.ts"; import config from "./fresh.config.ts";
await start(manifest, options); await start(manifest, config);
+2 -2
View File
@@ -9,6 +9,6 @@
import "./polyfill_deno_deploy.ts"; import "./polyfill_deno_deploy.ts";
import { start } from "$fresh/server.ts"; import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts"; import manifest from "./fresh.gen.ts";
import options from "./options.ts"; import config from "./fresh.config.ts";
await start(manifest, options); await start(manifest, config);
+2 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/ #!/usr/bin/env -S deno run -A --watch=static/,routes/
import dev from "$fresh/dev.ts"; import dev from "$fresh/dev.ts";
import options from "./options.ts"; import config from "./fresh.config.ts";
await dev(import.meta.url, "./main.ts", options); await dev(import.meta.url, "./main.ts", config);
@@ -1,7 +1,7 @@
import { FreshOptions } from "$fresh/server.ts"; import { FreshConfig } from "$fresh/server.ts";
export default { export default {
router: { router: {
ignoreFilePattern: /[\.|_]cy\.[t|j]s(x)?$/, ignoreFilePattern: /[\.|_]cy\.[t|j]s(x)?$/,
}, },
} as FreshOptions; } as FreshConfig;
+2 -2
View File
@@ -6,6 +6,6 @@
import { start } from "$fresh/server.ts"; import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts"; import manifest from "./fresh.gen.ts";
import options from "./options.ts"; import config from "./fresh.config.ts";
await start(manifest, options); await start(manifest, config);
@@ -0,0 +1,5 @@
import { FreshConfig } from "$fresh/server.ts";
import twindPlugin from "../../plugins/twindv1.ts";
import twindConfig from "./twind.config.ts";
export default { plugins: [twindPlugin(twindConfig)] } as FreshConfig;
+2 -2
View File
@@ -6,6 +6,6 @@
import { start } from "$fresh/server.ts"; import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts"; import manifest from "./fresh.gen.ts";
import options from "./options.ts"; import config from "./fresh.config.ts";
await start(manifest, options); await start(manifest, config);
-5
View File
@@ -1,5 +0,0 @@
import { FreshOptions } from "$fresh/server.ts";
import twindPlugin from "../../plugins/twindv1.ts";
import twindConfig from "./twind.config.ts";
export default { plugins: [twindPlugin(twindConfig)] } as FreshOptions;
+3 -3
View File
@@ -10,7 +10,7 @@ import {
retry, retry,
} from "./deps.ts"; } from "./deps.ts";
import manifest from "./fixture/fresh.gen.ts"; import manifest from "./fixture/fresh.gen.ts";
import options from "./fixture/options.ts"; import config from "./fixture/fresh.config.ts";
import { BUILD_ID } from "../src/server/build_id.ts"; import { BUILD_ID } from "../src/server/build_id.ts";
import { import {
assertSelector, assertSelector,
@@ -22,7 +22,7 @@ import {
withPageName, withPageName,
} from "./test_utils.ts"; } from "./test_utils.ts";
const ctx = await ServerContext.fromManifest(manifest, options); const ctx = await ServerContext.fromManifest(manifest, config);
const handler = ctx.handler(); const handler = ctx.handler();
Deno.test("/ page prerender", async () => { Deno.test("/ page prerender", async () => {
@@ -303,7 +303,7 @@ Deno.test("/foo/:path*", async () => {
Deno.test("static files in custom directory", async () => { Deno.test("static files in custom directory", async () => {
const newCtx = await ServerContext.fromManifest(manifest, { const newCtx = await ServerContext.fromManifest(manifest, {
...options, ...config,
staticDir: "./custom_static", staticDir: "./custom_static",
}); });
const newRouter = (req: Request) => { const newRouter = (req: Request) => {
+2 -2
View File
@@ -8,7 +8,7 @@ import {
puppeteer, puppeteer,
} from "./deps.ts"; } from "./deps.ts";
import manifest from "./fixture_plugin/fresh.gen.ts"; import manifest from "./fixture_plugin/fresh.gen.ts";
import options from "./fixture_plugin/options.ts"; import config from "./fixture_plugin/fresh.config.ts";
import { import {
clickWhenListenerReady, clickWhenListenerReady,
runBuild, runBuild,
@@ -16,7 +16,7 @@ import {
withPageName, withPageName,
} from "./test_utils.ts"; } from "./test_utils.ts";
const ctx = await ServerContext.fromManifest(manifest, options); const ctx = await ServerContext.fromManifest(manifest, config);
const handler = ctx.handler(); const handler = ctx.handler();
const router = (req: Request) => { const router = (req: Request) => {
return handler(req, { return handler(req, {
+2 -2
View File
@@ -2,9 +2,9 @@ import { assertSelector, parseHtml } from "$fresh/tests/test_utils.ts";
import { assertEquals } from "$std/testing/asserts.ts"; import { assertEquals } from "$std/testing/asserts.ts";
import { createHandler } from "$fresh/server.ts"; import { createHandler } from "$fresh/server.ts";
import manifest from "./fixture/fresh.gen.ts"; import manifest from "./fixture/fresh.gen.ts";
import options from "./fixture/options.ts"; import config from "./fixture/fresh.config.ts";
const handler = await createHandler(manifest, options); const handler = await createHandler(manifest, config);
// Issue: https://github.com/denoland/fresh/issues/1636 // Issue: https://github.com/denoland/fresh/issues/1636
Deno.test("doesn't leak data across renderers", async () => { Deno.test("doesn't leak data across renderers", async () => {
+3 -3
View File
@@ -2,7 +2,7 @@ import { colors, toFileUrl } from "$fresh/src/server/deps.ts";
import { assert } from "$std/_util/asserts.ts"; import { assert } from "$std/_util/asserts.ts";
import * as path from "$std/path/mod.ts"; import * as path from "$std/path/mod.ts";
import { import {
FromManifestOptions, FromManifestConfig,
Manifest, Manifest,
ServeHandlerInfo, ServeHandlerInfo,
ServerContext, ServerContext,
@@ -252,9 +252,9 @@ async function handleRequest(
export async function fakeServe( export async function fakeServe(
manifest: Manifest, manifest: Manifest,
options: FromManifestOptions, config: FromManifestConfig,
): Promise<FakeServer> { ): Promise<FakeServer> {
const ctx = await ServerContext.fromManifest(manifest, options); const ctx = await ServerContext.fromManifest(manifest, config);
const handler = ctx.handler(); const handler = ctx.handler();
const conn: ServeHandlerInfo = { const conn: ServeHandlerInfo = {