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 🙏

© 2026 – Pkg Stats / Ryan Hefner

blogtraffic

v1.0.5

Published

The official SDK for handling BlogTraffic.io webhooks and events.

Readme

BlogTraffic Node.js SDK

The official SDK for handling BlogTraffic.io webhooks and events in Node.js applications.

Installation

npm install blogtraffic

Webhook Features

  • Built-in Event Listeners: Easily handle onPublish, onUpdate, and onDelete events.
  • Signature Verification: Automatically verifies webhooks using your HMAC-SHA256 secret.
  • CORS Support: Handles preflight requests automatically.
  • TypeScript Support: Fully typed for a better developer experience.

Usage: Webhook Handler

Next.js (App Router)

The SDK handles all the heavy lifting: CORS, Authorization tokens, Timestamp validation, and Signature verification.

import { createBlogTrafficHandler } from 'blogtraffic';

const handler = createBlogTrafficHandler({
  secret: process.env.BLOGTRAFFIC_SECRET!,
  apiToken: process.env.API_TOKEN!, // Optional: validates Bearer token automatically
  onPublish: async (blog) => {
    // Add your DB logic here
    console.log('Blog added:', blog.title);
  }
});

export async function POST(req: Request) {
  const body = await req.json();
  const headers = Object.fromEntries(req.headers);
  
  const result = await handler({ body, headers, method: req.method });
  
  return new Response(JSON.stringify({ message: result.message }), {
    status: result.status,
    headers: result.headers 
  });
}

// Handle CORS preflight
export async function OPTIONS(req: Request) {
  const result = await handler({ method: 'OPTIONS' });
  return new Response(null, { status: result.status, headers: result.headers });
}

Usage: Blog Client (Data Fetching)

The BlogTrafficClient allows you to fetch your published content directly from the BlogTraffic API.

Authentication: Requires both API token and secret key for secure access.

import { BlogTrafficClient } from 'blogtraffic';

// Initialize with both API token and secret key
const client = new BlogTrafficClient(
  'your-api-token-here',
  'your-secret-key-here'
);

// Fetch all blogs with pagination
const { data, pagination } = await client.getAllBlogs(1, 10);

// Get a single blog by ID
const blog = await client.getBlogById('blog-id-here');

// Get a blog by slug
const blog = await client.getBlogBySlug('hello-world');

// Get blogs by keyword
const { data } = await client.getBlogsByKeyword('javascript', 1, 10);

Methods

| Method | Description | | --- | --- | | getAllBlogs(page, limit) | Returns a paginated list of all blogs. | | getBlogById(blogId) | Returns a single blog by its ID. | | getBlogBySlug(slug) | Returns a single blog by its slug. | | getBlogsByKeyword(keyword, page, limit) | Returns blogs filtered by keyword. |

Express.js

const { createBlogTrafficHandler } = require('blogtraffic');

const handler = createBlogTrafficHandler({
  secret: 'your_secret_here',
  onPublish: (blog) => {
    console.log('Published:', blog.title);
  }
});

app.post('/api/webhook', async (req, res) => {
  const result = await handler(req, res);
  res.status(result.status).send(result.message);
});

Security

Ensure you keep your secret safe. This secret is used to verify that the webhook requests are legitimately sent from BlogTraffic.io.

License

MIT