function createServer
Usage in Deno
import { createServer } from "node:https";
createServer<Request extends http.IncomingMessage = http.IncomingMessage,Response extends http.ServerResponse = http.ServerResponse,>(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>
// curl -k https://localhost:8000/
import https from 'node:https';
import fs from 'node:fs';
const options = {
key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem'),
};
https.createServer(options, (req, res) => {
res.writeHead(200);
res.end('hello world\n');
}).listen(8000);
Or
import https from 'node:https';
import fs from 'node:fs';
const options = {
pfx: fs.readFileSync('test/fixtures/test_cert.pfx'),
passphrase: 'sample',
};
https.createServer(options, (req, res) => {
res.writeHead(200);
res.end('hello world\n');
}).listen(8000);
createServer<Request extends http.IncomingMessage = http.IncomingMessage,Response extends http.ServerResponse = http.ServerResponse,>(options: ServerOptions<Request, Response>,requestListener?: http.RequestListener<Request, Response>,): Server<Request, Response>