summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/https.ts
diff options
context:
space:
mode:
authorLeo Kettmeir <crowlkats@toaxl.com>2023-06-13 04:15:08 +0200
committerGitHub <noreply@github.com>2023-06-13 04:15:08 +0200
commitb4ae37a617e5e2a1c248d0d1ac66dcead11e04cd (patch)
tree7d604b5dcc37f054e1de37eb50afe1cb3571a9de /ext/node/polyfills/https.ts
parentd2c638464d108b945440429cfba0594c20089d76 (diff)
feat(node): HTTPS server (#19362)
Diffstat (limited to 'ext/node/polyfills/https.ts')
-rw-r--r--ext/node/polyfills/https.ts45
1 files changed, 40 insertions, 5 deletions
diff --git a/ext/node/polyfills/https.ts b/ext/node/polyfills/https.ts
index dfd8f24d9..b0b800416 100644
--- a/ext/node/polyfills/https.ts
+++ b/ext/node/polyfills/https.ts
@@ -10,14 +10,49 @@ import {
} from "ext:deno_node/http.ts";
import { Agent as HttpAgent } from "ext:deno_node/_http_agent.mjs";
import { createHttpClient } from "ext:deno_fetch/22_http_client.js";
+import {
+ type ServerHandler,
+ ServerImpl as HttpServer,
+} from "ext:deno_node/http.ts";
+import { validateObject } from "ext:deno_node/internal/validators.mjs";
+import { kEmptyObject } from "ext:deno_node/internal/util.mjs";
+import { Buffer } from "ext:deno_node/buffer.ts";
+
+export class Server extends HttpServer {
+ constructor(opts, requestListener?: ServerHandler) {
+ if (typeof opts === "function") {
+ requestListener = opts;
+ opts = kEmptyObject;
+ } else if (opts == null) {
+ opts = kEmptyObject;
+ } else {
+ validateObject(opts, "options");
+ }
+
+ if (opts.cert && Array.isArray(opts.cert)) {
+ notImplemented("https.Server.opts.cert array type");
+ }
-export class Server {
- constructor() {
- notImplemented("https.Server.prototype.constructor");
+ if (opts.key && Array.isArray(opts.key)) {
+ notImplemented("https.Server.opts.key array type");
+ }
+
+ super(opts, requestListener);
+ }
+
+ _additionalServeOptions() {
+ return {
+ cert: this._opts.cert instanceof Buffer
+ ? this._opts.cert.toString()
+ : this._opts.cert,
+ key: this._opts.key instanceof Buffer
+ ? this._opts.key.toString()
+ : this._opts.key,
+ };
}
}
-export function createServer() {
- notImplemented("https.createServer");
+export function createServer(opts, requestListener?: ServerHandler) {
+ return new Server(opts, requestListener);
}
interface HttpsRequestOptions extends RequestOptions {