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

express-open-graph-middleware

v1.0.2

Published

A middleware for detecting open-graph bots and serving them with the appropriate meta tags. Useful for Single-Page-Applications which would otherwise require Facebookbot, Twitterbot, etc. to execute client-side JavaScript, which they do not. Instead, just

Downloads

1

Readme

express-open-graph-middleware

Simple express middleware for detecting requests made by robots that consume open graph tags (Facebook, Twitter, LinkedIn, Pinterest, Slack)

The problem

Websites like Facebook and Twitter use robots that consume Open Graph meta tags in order to render previews of the content on your application. We often want to know if our Express application is getting a request from one of these robots so that we can serve them specifically tailored content.

This solution

This simple middleware will set a flag to let you know that it is a robot sending the request as well as telling you which website/application is sending the request.

Robots Currently Detected

  • Facebook
  • Linkedin
  • Twitter
  • Pinterest
  • Slack

Installation

This module is distributed via [npm][npm] which is bundled with [node][node] and should be installed as one of your project's Dependencies:

npm install --save express-open-graph-middleware

Usage

If a robot is detected two properties will be added to the request object. The 'isOpenGraphRobot' property is a boolean specifying whether the request is coming from a robot. If the request is from a robot, the 'openGraphRobotType' property will specify which robot, currently either 'facebook', 'twitter', 'linkedin', 'pinterest', or 'slack'.

var express = require("express");
var openGraphRobotDetector = require("express-open-graph-middleware");
var app = express();

app.use(openGraphRobotDetector);

app.get("/", function(req, res) {
  // If a robot is detected, the request object will have the following property
  req.isOpenGraphRobot;
  // The robot type will be specified by the company name -- current possible values:  'facebook', 'twitter', 'pinterest', 'linkedin', 'slack'
  req.openGraphRobotType;
});

app.listen(3000);

Roadmap

In the future, I'm looking to make this a full-fledged solution whereby you can respond to the robots with specific open-graph meta tags that are configurable and that come with sensible defaults. Any ideas with regards to the best approach are welcome!

🐛 Bugs

Please file an issue for bugs, missing documentation, or unexpected behavior.

💡 Feature Requests

Please file an issue to suggest new features. Vote on feature requests by adding a 👍. This helps maintainers prioritize what to work on.

LICENSE

MIT