createSecureServer - Node documentation
function createSecureServer

Usage in Deno

import { createSecureServer } from "node:http2";
createSecureServer(onRequestHandler?: () => void): Http2SecureServer

Returns a tls.Server instance that creates and manages Http2Sessioninstances.

const http2 = require('node:http2');
const fs = require('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('<h1>Hello World</h1>');
});

server.listen(8443);

Parameters

optional
onRequestHandler: () => void

See Compatibility API

Return Type

createSecureServer(
onRequestHandler?: () => void,
): Http2SecureServer

Parameters

optional
onRequestHandler: () => void

Return Type