Back to Freecodecamp

Install and Require Helmet

curriculum/challenges/english/blocks/information-security-with-helmetjs/587d8247367417b2b2512c36.md

latest1.1 KB
Original Source

--description--

Working on these challenges will involve you writing your code using one of the following methods:

  • Clone <a href="https://github.com/freeCodeCamp/boilerplate-infosec/" target="_blank" rel="noopener noreferrer nofollow">this GitHub repo</a> and complete these challenges locally.
  • Use a site builder of your choice to complete the project. Be sure to incorporate all the files from our GitHub repo.

Helmet helps you secure your Express apps by setting various HTTP headers.

--instructions--

All your code for these lessons goes in the myApp.js file between the lines of code we have started you off with. Do not change or delete the code we have added for you.

Helmet version 3.21.3 has already been installed, so require it as helmet in myApp.js.

--hints--

helmet version 3.21.3 should be in package.json

js
const response = await fetch(code + '/_api/package.json');
if (!response.ok) {
  throw Error(await response.text());
}
const data = await response.text();
const packJson = JSON.parse(data);
const helmet = packJson.dependencies.helmet;
assert(helmet === '3.21.3' || helmet === '^3.21.3');