(basePath: string)
| 237 | * @returns Normalized base path |
| 238 | */ |
| 239 | export function normalizeBasePath(basePath: string): string { |
| 240 | if (typeof basePath !== 'string') { |
| 241 | throw new Error(`Invalid path prefix ${JSON.stringify(basePath)}`); |
| 242 | } |
| 243 | |
| 244 | // ensure the path prefix does not end in '/', since our method map starts all paths with '/' |
| 245 | basePath = basePath.replace(/\/$/, ''); |
| 246 | |
| 247 | // likewise, ensure the path prefix does always START with /, unless the path |
| 248 | // is empty meaning no base path at all |
| 249 | if (basePath !== '' && !basePath.startsWith('/')) { |
| 250 | basePath = `/${basePath}`; |
| 251 | } |
| 252 | |
| 253 | return basePath; |
| 254 | } |
| 255 | |
| 256 | async function createServer(app: Express, cliArgs?: Partial<ServerArgs>): Promise<HttpServer> { |
| 257 | const {sslCertificatePath, sslKeyPath} = cliArgs ?? {}; |
no outgoing calls
no test coverage detected