( app: Connect.Server, httpsOptions?: HttpsServerOptions, )
| 117 | export type CorsOrigin = boolean | string | RegExp | (string | RegExp)[] |
| 118 | |
| 119 | export async function resolveHttpServer( |
| 120 | app: Connect.Server, |
| 121 | httpsOptions?: HttpsServerOptions, |
| 122 | ): Promise<HttpServer> { |
| 123 | if (!httpsOptions) { |
| 124 | const { createServer } = await import('node:http') |
| 125 | return createServer(app) |
| 126 | } |
| 127 | |
| 128 | const { createSecureServer } = await import('node:http2') |
| 129 | return createSecureServer( |
| 130 | { |
| 131 | // Manually increase the session memory to prevent 502 ENHANCE_YOUR_CALM |
| 132 | // errors on large numbers of requests |
| 133 | maxSessionMemory: 1000, |
| 134 | // Increase the stream reset rate limit to prevent net::ERR_HTTP2_PROTOCOL_ERROR |
| 135 | // errors on large numbers of requests |
| 136 | streamResetBurst: 100000, |
| 137 | streamResetRate: 33, |
| 138 | ...httpsOptions, |
| 139 | allowHTTP1: true, |
| 140 | }, |
| 141 | // @ts-expect-error TODO: is this correct? |
| 142 | app, |
| 143 | ) |
| 144 | } |
| 145 | |
| 146 | export async function resolveHttpsConfig( |
| 147 | https: HttpsServerOptions | undefined, |
no test coverage detected