Node.js provides two built-in modules for creating servers:
http → creates non-secure HTTP servers
https → creates secure HTTPS servers
A secure server requires:
SSL/TLS certificates (key and cert)
The built-in Node.js module designed to handle these: https
Syntax for a secure server:
const https = require( ' https ' );
const fs = require( ' fs ' );
const options = {
key: fs.readFileSync( ' key.pem ' ),
cert: fs.readFileSync( ' cert.pem ' )
};
https.createServer(options, (req, res) = > {
res.write( ' Secure Server ' );
res.end();
}).listen(443);
A is incorrect: No built-in module named secure-server exists.
B is incorrect: tls provides low-level TLS sockets, not HTTP/HTTPS servers.
C is incorrect: http only creates an insecure server.
D is correct: https is the built-in module required for secure web servers.
JavaScript Knowledge References (text-only)
Node.js exposes built-in modules http and https for server creation.
Secure servers require the https module, which supports TLS/SSL.
The tls module is lower-level and not used for full HTTP servers.
==================================================
Submit