Skip to main content
createServer - node__https.d.ts - Node documentation
function createServer

Usage in Deno

```typescript import { createServer } from "node:node__https.d.ts"; ```
createServer<
Request extends http.IncomingMessage = http.IncomingMessage,
Response extends http.ServerResponse = http.ServerResponse,
>
(requestListener?: http.RequestListener<Request, Response>): Server<Request, Response>
```js // 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 ```js 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); ```

Type Parameters

Request extends http.IncomingMessage = http.IncomingMessage
Response extends http.ServerResponse = http.ServerResponse

Parameters

optional
requestListener: http.RequestListener<Request, Response>
A listener to be added to the `'request'` event.

Return Type

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>

Type Parameters

Request extends http.IncomingMessage = http.IncomingMessage
Response extends http.ServerResponse = http.ServerResponse

Parameters

optional
requestListener: http.RequestListener<Request, Response>

Return Type