Complete the code to import the Express framework.
const express = require('[1]');
The Express framework is imported by requiring 'express'.
Complete the code to use the express.json() middleware for parsing JSON input.
app.use([1]());express.json() middleware parses incoming JSON requests.
Fix the error in the validation code to check if the input 'age' is a number.
if (typeof [1] !== 'number') { res.status(400).send('Age must be a number'); }
Input data from JSON body is accessed via req.body.age.
Fill both blanks to sanitize and validate a username input using the 'validator' library.
const sanitizedUsername = validator.[1](req.body.username); if (!validator.[2](sanitizedUsername)) { res.status(400).send('Invalid username'); }
Use escape() to sanitize input and isAlphanumeric() to validate username characters.
Fill all three blanks to create a middleware that validates and sanitizes an email input.
function validateEmail(req, res, next) {
const email = validator.[1](req.body.email);
if (!validator.[2](email)) {
return res.status(400).send('Invalid email');
}
req.body.email = email[3]();
next();
}normalizeEmail() cleans the email, isEmail() validates it, and trim() removes extra spaces.
