createServer

external fun <Request : IncomingMessage, Response : ServerResponse<*>> createServer(    requestListener: RequestListener<Request, Response> = definedExternally): Server<Request, Response>(source)
// 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);

Since

v0.3.4

Parameters

options

Accepts options from createServer, createSecureContext and createServer.

requestListener

A listener to be added to the 'request' event.


external fun <Request : IncomingMessage, Response : ServerResponse<*>> createServer(    options: ServerOptions<Request, Response>,     requestListener: RequestListener<Request, Response> = definedExternally): Server<Request, Response>(source)