JAVASCRIPT-DEVELOPER-I practice question 1 of 30
A developer wants to set up a secure web server withNode.js. The developer creates a directory locally called app-server, and the first file is app-server/index.js Without using any third-party libraries, what should the developer add to index.js to create the secure web server?
Full set: 219 questionsDomain Server-Side JavaScript
To create a secure web server in Node.js without third-party libraries, the built-in https module is required. This module provides the functionality to create an HTTPS server, which is the standard for secure web communication. It is an implementation of the HTTP protocol over a TLS/SSL encrypted connection. The https.createServer() method is used to instantiate a new secure server, which requires SSL certificate details to operate. This directly fulfills the requirement of setting up a "secure web server" using Node.js core functionalities.
B. secure-server is not a built-in core module in Node.js. Using it would require installing a third-party library, which violates the problem's constraint.
C. The tls module provides the underlying Transport Layer Security protocol, but it is a lower-level API for secure streams, not a high-level web server implementation.
D. The http module creates a standard, unencrypted HTTP server. This is inherently insecure and does not meet the requirement for a "secure web server".
1. Node.js v20.12.2 Documentation, HTTPS: The official documentation explicitly states, "The https module provides an implementation of the TLS/SSL protocol for Node.js." The primary method for creating a secure server is https.createServer().
Reference: Node.js Documentation, https module, Introduction section. (https://nodejs.org/api/https.html)
2. Node.js v20.12.2 Documentation, HTTP: This documentation describes the http module for creating standard web servers, which are unencrypted by default, confirming why option D is incorrect.
Reference: Node.js Documentation, http module, http.createServer() section. (https://nodejs.org/api/http.html#httpcreateserveroptions-requestlistener)
3. Node.js v20.12.2 Documentation, TLS (Transport Layer Security): This source clarifies that the tls module provides the underlying security protocol upon which https is built, making https the correct high-level abstraction for a web server.
Reference: Node.js Documentation, tls module, Class: tls.Server section. (https://nodejs.org/api/tls.html#class-tlsserver)
4. Salesforce Trailhead, JavaScript Developer I Cert Prep: Server-Side JavaScript: This module establishes that knowledge of core Node.js modules is a key objective for the certification, including how to handle web requests.
Reference: Trailhead, "Understand Server-Side JavaScript with Node.js" unit. (https://trailhead.salesforce.com/content/learn/modules/javascriptdevelopericertificationprepserversidejavascript/understand-server-side-javascript-with-nodejs)
Keep practicing
Take the free JAVASCRIPT-DEVELOPER-I practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other JAVASCRIPT-DEVELOPER-I practice questions
- Question 3Given two expressions var1 and var2. What are two valid ways to return the logical AND of…
- Question 4A test has a dependency on database.query. During the test the dependency is replaced wit…
- Question 5Refer to code below: function Person() { this.firstName = ’John’; } Person.prototype ={ J…
- Question 6A developer has an ErrorHandler module that contains multiple functions. What kind of exp…
- Question 8Refer to the code below: const event = new CustomEvent( //Missing Code ); obj.dispatchEve…
- Question 9Refer to the code below: Let foodMenu1 = [‘pizza’, ‘burger’, ‘French fries’]; Let finalMe…
