( sources: CppCodeSources, engine: ICopyFilesArguments['engine'], basePath: string, isSpa: boolean )
| 73 | source.cacheTime ? `max-age=${source.cacheTime.value}` : 'no-cache'; |
| 74 | |
| 75 | export 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 | |
| 94 | export const genCommonHeader = (d: TemplateData): string => { |
| 95 | const lines: string[] = []; |
no outgoing calls
no test coverage detected