Skip to content

Commit

Permalink
EdgeSpec -> EdgeSpecRouteBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsdev committed Jan 19, 2024
1 parent efadae4 commit 772110a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/adapters/module-service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
type EdgeSpecAdapter,
type EdgeSpec,
type EdgeSpecRouteBundle,
handleRequestWithEdgeSpec,
} from "src/types/edge-spec"
import { EdgeSpecRequest, EdgeSpecRouteFn } from "src/types/web-handler"
Expand All @@ -18,7 +18,7 @@ export const createModuleService: EdgeSpecAdapter<[], ModuleService> = (
) => {
return (options) => async (request) => {
// cascade options down the edge spec chain
const edgeSpec: EdgeSpec = {
const edgeSpec: EdgeSpecRouteBundle = {
...request.edgeSpec,
...moduleServiceEdgeSpec,
...(options?.handleRouteParamNotFound && {
Expand Down
4 changes: 2 additions & 2 deletions src/serve/create-server-from-route-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import {
} from "src/edge-runtime/transform-to-node.js"
import { EdgeSpecRouteFn } from "src/types/web-handler.js"
import {
EdgeSpec,
EdgeSpecRouteBundle,
EdgeSpecOptions,
handleRequestWithEdgeSpec,
} from "src/types/edge-spec.js"

export const createEdgeSpecFromRouteMap = (
routeMap: Record<string, EdgeSpecRouteFn>,
edgeSpecOptions?: Partial<EdgeSpecOptions>
): EdgeSpec => {
): EdgeSpecRouteBundle => {
const formattedRoutes = normalizeRouteMap(routeMap)
const routeMatcher = getRouteMatcher(Object.keys(formattedRoutes))

Expand Down
6 changes: 3 additions & 3 deletions src/types/edge-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ export interface EdgeSpecOptions {
}

// make this deeply immutable to force usage through helper functions
export type EdgeSpec = ReadonlyDeep<EdgeSpecOptions>
export type EdgeSpecRouteBundle = ReadonlyDeep<EdgeSpecOptions>

export type EdgeSpecAdapter<
Options extends Array<unknown> = [],
ReturnValue = void,
> = (edgeSpec: EdgeSpec, ...options: Options) => ReturnValue
> = (edgeSpec: EdgeSpecRouteBundle, ...options: Options) => ReturnValue

export async function handleRequestWithEdgeSpec(
edgeSpec: EdgeSpec,
edgeSpec: EdgeSpecRouteBundle,
request: Request,
pathnameOverride?: string
): Promise<Response> {
Expand Down
4 changes: 2 additions & 2 deletions src/types/web-handler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { FetchEvent } from "@edge-runtime/primitives"
import { EdgeSpec } from "./edge-spec"
import { EdgeSpecRouteBundle } from "./edge-spec"

export type EdgeSpecRouteParams = {
[routeParam: string]: string | string[]
}
export interface EdgeSpecRequestOptions {
edgeSpec: EdgeSpec
edgeSpec: EdgeSpecRouteBundle
pathParams?: EdgeSpecRouteParams
}

Expand Down

0 comments on commit 772110a

Please sign in to comment.