Skip to content

Commit

Permalink
Extracting OnEndpoint type.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinTail committed Dec 3, 2024
1 parent db2c966 commit b82233e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
8 changes: 2 additions & 6 deletions src/documentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
reformatParamsInPath,
} from "./documentation-helpers";
import { Routing } from "./routing";
import { RoutingWalkerParams, walkRouting } from "./routing-walker";
import { OnEndpoint, walkRouting } from "./routing-walker";
import { HandlingRules } from "./schema-walker";

type Component =
Expand Down Expand Up @@ -143,11 +143,7 @@ export class Documentation extends OpenApiBuilder {
this.addInfo({ title, version });
for (const url of typeof serverUrl === "string" ? [serverUrl] : serverUrl)
this.addServer({ url });
const onEndpoint: RoutingWalkerParams["onEndpoint"] = (
endpoint,
path,
method,
) => {
const onEndpoint: OnEndpoint = (endpoint, path, method) => {
const commons = {
path,
method,
Expand Down
16 changes: 9 additions & 7 deletions src/routing-walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import { Method } from "./method";
import { Routing } from "./routing";
import { ServeStatic, StaticHandler } from "./serve-static";

export interface RoutingWalkerParams {
export type OnEndpoint = (
endpoint: AbstractEndpoint,
path: string,
method: Method,
siblingMethods?: ReadonlyArray<Method>,
) => void;

interface RoutingWalkerParams {
routing: Routing;
onEndpoint: (
endpoint: AbstractEndpoint,
path: string,
method: Method,
siblingMethods?: ReadonlyArray<Method>,
) => void;
onEndpoint: OnEndpoint;
onStatic?: (path: string, handler: StaticHandler) => void;
parentPath?: string;
}
Expand Down

0 comments on commit b82233e

Please sign in to comment.