0
0
Expressframework~10 mins

Third-party middleware installation in Express - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Express package.

Express
const express = require('[1]');
Drag options to blanks, or click blank then click option'
Ahttp
Bfs
Cexpress
Dpath
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'http' instead of 'express' will import the Node.js HTTP module, not Express.
Using 'fs' or 'path' imports file system or path utilities, not Express.
2fill in blank
medium

Complete the code to install the 'cors' middleware in the Express app.

Express
const cors = require('[1]');
Drag options to blanks, or click blank then click option'
Acors
Bbody-parser
Cmorgan
Dhelmet
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'helmet' imports security middleware, not CORS.
Using 'morgan' imports logging middleware, not CORS.
3fill in blank
hard

Fix the error in applying the 'cors' middleware to the Express app.

Express
app.use([1]());
Drag options to blanks, or click blank then click option'
Acors.apply
Bcors
Ccors()
Dcors.use
Attempts:
3 left
💡 Hint
Common Mistakes
Putting parentheses inside the blank causes a syntax error.
Using 'cors.apply' or 'cors.use' are not valid middleware references.
4fill in blank
hard

Fill both blanks to import and use the 'helmet' middleware correctly.

Express
const [1] = require('[2]');
app.use(helmet());
Drag options to blanks, or click blank then click option'
Ahelmet
Bcors
Dmorgan
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'cors' or 'morgan' instead of 'helmet' will import the wrong middleware.
Mismatching variable and package names causes errors.
5fill in blank
hard

Fill all three blanks to import, configure, and use the 'body-parser' middleware for JSON data.

Express
const [1] = require('[2]');
app.use([3].json());
Drag options to blanks, or click blank then click option'
AbodyParser
Bbody-parser
Dcors
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'cors' instead of 'body-parser' imports the wrong middleware.
Not calling the .json() method will not parse JSON bodies.