Skip to main content
createSecureServer - node__http2.d.ts - Node documentation
function createSecureServer

Usage in Deno

```typescript import { createSecureServer } from "node:node__http2.d.ts"; ```
createSecureServer(onRequestHandler?: () => void): Http2SecureServer
Returns a `tls.Server` instance that creates and manages `Http2Session` instances. ```js import http2 from 'node:http2'; import fs from 'node:fs'; const options = { key: fs.readFileSync('server-key.pem'), cert: fs.readFileSync('server-cert.pem'), }; // Create a secure HTTP/2 server const server = http2.createSecureServer(options); server.on('stream', (stream, headers) => { stream.respond({ 'content-type': 'text/html; charset=utf-8', ':status': 200, }); stream.end('

Hello World

'); }); server.listen(8443); ```

Parameters

optional
onRequestHandler: () => void
See `Compatibility API`

Return Type

createSecureServer<
Http1Request extends IncomingMessage = IncomingMessage,
Http1Response extends ServerResponse = ServerResponse,
Http2Request extends Http2ServerRequest = Http2ServerRequest,
Http2Response extends Http2ServerResponse = Http2ServerResponse,
>
(
options: SecureServerOptions<Http1Request, Http1Response, Http2Request, Http2Response>,
onRequestHandler?: (
request: InstanceType<Http2Request>,
response: InstanceType<Http2Response>,
) => void
,
): Http2SecureServer<Http1Request, Http1Response, Http2Request, Http2Response>

Type Parameters

Http1Request extends IncomingMessage = IncomingMessage
Http1Response extends ServerResponse = ServerResponse
Http2Request extends Http2ServerRequest = Http2ServerRequest
Http2Response extends Http2ServerResponse = Http2ServerResponse

Parameters

optional
onRequestHandler: (
request: InstanceType<Http2Request>,
response: InstanceType<Http2Response>,
) => void

Return Type