npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

check-my-headers

v0.1.2

Published

Fast and simple way to check any HTTP Headers

Downloads

52

Readme

About

Fast and simple way to check any HTTP Headers

Usage

Command line

Using Node.js's npx to run a one-off scan of a website:

npx check-my-headers https://example.com 

The CLI will gracefully handle cases where the URL to scan is missing or wrong:

$ npx check-my-headers
👋  Welcome to [email protected]
😬  Missing argument URL!
👉  Example: check-my-headers https://github.com/ulisesgascon/check-my-headers

Module

Using check-my-headers in your project.

const checkMyHeaders = require('check-my-headers')

checkMyHeaders("http://example.com")
.then(({ messages, headers, status }) => {
    console.log(`Status code: ${status}`)
    console.log(`Messages:`)
    console.log(messages)
    console.log("Current headers:")
    console.log(headers)
})

Output:

Status code: 200
Messages:
[
  { msg: 'Remove field: server', type: 'error' },
  { msg: 'Missing field: content-security-policy', type: 'error' },
  { msg: 'Missing field: referrer-policy', type: 'error' },
  { msg: 'Missing field: strict-transport-security', type: 'error' },
  { msg: 'Missing field: x-xss-protection', type: 'error' },
  { msg: 'Missing field: x-content-type-options', type: 'error' },
  { msg: 'Missing field: access-control-allow-origin', type: 'warn' },
  { msg: 'Missing field: access-control-allow-methods', type: 'warn' },
  { msg: 'Missing field: access-control-allow-headers', type: 'warn' },
  { msg: 'Missing field: link', type: 'warn' },
  { msg: 'Deprecated field: expires', type: 'warn' },
  { msg: 'Extra field: etag', type: 'info' },
  { msg: 'Extra field: last-modified', type: 'info' },
  { msg: 'Extra field: vary', type: 'info' },
  { msg: 'Extra field: x-cache', type: 'info' },
  { msg: 'Extra field: connection', type: 'info' }
]
Current headers:
{
  age: '534610',
  'cache-control': 'max-age=604800',
  'content-type': 'text/html; charset=UTF-8',
  date: 'Wed, 12 Feb 2020 19:37:45 GMT',
  etag: '"3147526947+ident"',
  expires: 'Wed, 19 Feb 2020 19:37:45 GMT',
  'last-modified': 'Thu, 17 Oct 2019 07:18:26 GMT',
  server: 'ECS (nyb/1D2A)',
  vary: 'Accept-Encoding',
  'x-cache': 'HIT',
  'content-length': '1256',
  connection: 'close'
}

Docker

Use Docker Hub:

# Pull the image from Docker Hub:
docker pull ulisesgascon/check-my-headers:latest

# Run container:
docker run --rm -e SCAN_URL="https://www.github.com/" ulisesgascon/check-my-headers:latest

SCAN_URL is an environment variable and its value must be replaced with the desired URL during Docker run. Docker container will exit once the scan has been completed.

To build and run the container locally:

# Clone Repo:
git clone https://github.com/ulisesgascon/check-my-headers.git

# Change to repo's cloned directory:
cd check-my-headers

# Build Image locally:
docker build --no-cache -t ulisesgascon/check-my-headers:latest .

# Run container:
docker run --rm -e SCAN_URL="https://www.github.com/" ulisesgascon/check-my-headers:latest

Install

You can install globally via:

npm install -g check-my-headers

Test

You can run them:

npm run test:coverage

Contributing

Please consult CONTRIBUTING for guidelines on contributing to this project.

Author

check-my-headers © Ulises Gascón, Released under the MIT License.