How do you install a specific version of a package using npm?
- npm install
@ - npm get
@ - npm add
@ - npm update
@
To install a specific version of a package using npm, you should use the npm install @ command. This allows you to specify the exact version you want to install. The other options do not provide the same functionality or may not work as expected.
Which method of the response object is used to end the response process in an HTTP server?
- response.end()
- response.finish()
- response.complete()
- response.stop()
The response.end() method is used to end the response process in an HTTP server. It finalizes the response and sends it to the client. The other options are not valid methods for ending the response.
How do you include partial views in EJS templates?
- <%- include('partial') %>
- <% include('partial') %>
- <% partial('partial') %>
- <%- partial('partial') %>
In EJS, you can include partial views using the <%- include('partial') %> syntax. This allows you to reuse and insert content from other EJS files into your main template, helping you create modular and maintainable views. The other options are not the correct syntax for including partials in EJS.
How can you send JSON data as a response using the http module in Node.js?
- response.sendJSON(jsonDat
- response.write(JSON.stringify(jsonData))
- response.json(jsonData)
- response.send(jsonData)
To send JSON data as a response using the http module in Node.js, you should use response.write(JSON.stringify(jsonData)). This method writes the JSON data as a string to the response. The other options are not valid methods for sending JSON data in the http module.
The ______ command can be used to update the package.json file to match the actual versions installed in the node_modules directory.
- npm install
- npm update
- npm sync
- npm check
The npm update command can be used to update the package.json file to match the actual versions installed in the node_modules directory. This command will update the version numbers of packages in package.json based on the versions currently installed.
To optimize CRUD operations in a high-write-load scenario, employing ______ strategies like write-behind caching can be effective.
- Caching
- Synchronization
- Scaling
- Indexing
To optimize CRUD operations, caching strategies like write-behind caching can be effective, where data is cached and written back to the database asynchronously. Caching reduces the need to access the database for every write operation, improving performance.
You are designing a system with a high read/write ratio, requiring efficient database interactions. How would you configure Sequelize or Mongoose to minimize database load and optimize performance?
- Implement caching mechanisms.
- Use Sequelize's "findOneAndUpdate" method.
- Disable indexing on database columns.
- Increase the database connection pool size.
To optimize performance with a high read/write ratio, implementing caching mechanisms is a common strategy. Options 2, 3, and 4 are not recommended for this purpose. "findOneAndUpdate" is not related to optimizing read/write efficiency. Disabling indexing can harm performance, and increasing the connection pool size alone won't optimize database interactions.
In order to secure user passwords, it is best practice to store them using a ________ algorithm.
- Hashing
- Encryption
- Decryption
- Salting
To secure user passwords, it's best practice to store them using a hashing algorithm. Hashing takes the password and transforms it into a fixed-size string of characters (hash) using a one-way function. This makes it difficult to reverse-engineer the password from the stored hash.
How can you prevent replay attacks when using OAuth 2.0?
- Use Nonce Values
- Use Long-lived Tokens
- Use Weak Passwords
- Use Static Client IDs
Preventing replay attacks in OAuth 2.0 involves using Nonce values (number used once) to ensure that each request is unique and can't be replayed. Nonces are typically used with authorization codes to add an extra layer of security. The other options are not effective in preventing replay attacks.
Which method is commonly used in Node.js to handle errors in callbacks?
- try...catch
- process.exit()
- console.error()
- callback(error)
In Node.js, it's common to handle errors in callbacks by passing an error object as the first argument to the callback function. This allows the callback to check if an error occurred during the asynchronous operation and take appropriate action. The other options (try...catch, process.exit(), and console.error()) are not used to handle errors in callbacks but serve different purposes.