MCPcopy Create free account
hub / github.com/BCsabaEngine/svelteesp32 / computeRouteCount

Function computeRouteCount

src/cppCode.ts:75–92  ·  view source on GitHub ↗
(
  sources: CppCodeSources,
  engine: ICopyFilesArguments['engine'],
  basePath: string,
  isSpa: boolean
)

Source from the content-addressed store, hash-verified

73 source.cacheTime ? `max-age=${source.cacheTime.value}` : 'no-cache';
74
75export const computeRouteCount = (
76 sources: CppCodeSources,
77 engine: ICopyFilesArguments['engine'],
78 basePath: string,
79 isSpa: boolean
80): number => {
81 const numberDefault = sources.filter((s) => s.filename === 'index.html' || s.filename === 'index.htm').length;
82 const hasDefault = numberDefault > 0;
83 if (engine === 'psychic') {
84 // psychic aliases the default route onto the existing handler when basePath is empty, so no extra handler is registered
85 const defaultExtra = basePath ? numberDefault : 0;
86 const spaExtra = isSpa && hasDefault && basePath ? 1 : 0;
87 return sources.length + defaultExtra + spaExtra;
88 }
89 // espidf/async/webserver always register a separate default-route handler and a separate SPA/404 handler
90 const spaExtra = isSpa && hasDefault ? 1 : 0;
91 return sources.length + numberDefault + spaExtra;
92};
93
94export const genCommonHeader = (d: TemplateData): string => {
95 const lines: string[] = [];

Callers 2

cppCode.test.tsFile · 0.90
getCppCodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected