MCPcopy
hub / github.com/freshframework/fresh / newRouteCmd

Function newRouteCmd

packages/fresh/src/commands.ts:142–167  ·  view source on GitHub ↗
(
  pattern: string,
  route: MaybeLazy<Route<State>>,
  config: RouteConfig | undefined,
  includeLastSegment: boolean,
)

Source from the content-addressed store, hash-verified

140 includeLastSegment: boolean;
141}
142export function newRouteCmd<State>(
143 pattern: string,
144 route: MaybeLazy<Route<State>>,
145 config: RouteConfig | undefined,
146 includeLastSegment: boolean,
147): RouteCommand<State> {
148 let normalized;
149 if (isLazy(route)) {
150 normalized = async () => {
151 const result = await route();
152 ensureHandler(result);
153 return result;
154 };
155 } else {
156 ensureHandler(route);
157 normalized = route;
158 }
159
160 return {
161 type: CommandType.Route,
162 pattern,
163 route: normalized,
164 config,
165 includeLastSegment,
166 };
167}
168
169export interface HandlerCommand<State> {
170 type: CommandType.Handler;

Callers 2

fsItemsToCommandsFunction · 0.90
routeMethod · 0.90

Calls 2

isLazyFunction · 0.90
ensureHandlerFunction · 0.85

Tested by

no test coverage detected