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

@hefoki/backend

v1.2.0

Published

Tasks and logic for Hefoki

Downloads

16

Readme

Hefoki Backend

The Hefoki Backend module connects other isolated Hefoki NodeJS modules, defines repeated tasks and logic for scraping and incremental static site deployment, provides a command-line interface for these tasks, and defines an AWS Lambda function for cloud execution.

Being a static site hosted on an S3 bucket, Hefoki works by rebuilding a portion of the site from its existing data, comparing this with the pages which are already deployed, reconciling any differences in how pages are linked, and deploying any new or modified files. This is primarily the case for the paginated next and previous links on the daily news pages. Within Hefoki's code, this process of modifying the pages is called "repagination", and the overall partial deployment process is referred to as an "increment" or being "incremental".

NPM Scripts and CLI

start: Unified CLI entrypoint

Runs the main CLI script. Use -- after the command to specify command-line arguments. For example:

npm start -- scrape http://example.com/

headlines:update: Scrape to Database

Calls the Hefoki scraper, to collect headlines from the Wikipedia Current Events Portal, compare the results with those stored in a database (handled by the DynamoDB database adapter), and determine which headlines are new, updating the database to become current.

Usage

To scrape the current events portal and update the database:

npm run scrape

Equivalent to:

npm run start -- headlines update

frontend:increment: Build static site and incrementally deploy to S3

Hefoki is deployed as a static site on an S3 bucket, and built using the Hefoki Frontend Module. The frontend module queries for recent headlines headlines, then compares the files with existing static site files on the public S3 bucket. Only new and updated files are uploaded to S3, but because Hefoki has paginated links, one page with a unique URL for each date of stories, the next/previous links may need to be updated in order to make previous builds work properly with current builds. This script edits the HTML output of the static site build to reflect this, and updates old page links as well.

Usage

npm run frontend:increment

Equivalent to:

npm run start -- frontend increment

Updater Lambda function

The incremental deployment process is able to be deployed to AWS Lambda with the handler exported by src/lambda.js. This function calls the scraper to update the database, rebuilds the static frontend, incrementally deploys to S3, and performs a CloudFront invalidation.

Tasks, Logic, and Facades

The Hefoki backend attempts to divide its functionality into three types of source files:

  • Logic: The code which works with data most directly. Individual functions can also read or write to other sources. These should be defined in src/logic/.

  • Tasks: Classes with a handler that represent a repeated logical action, but should ideally be modular with their data sources and destinations. The class structure makes sure that there is a consistent data structure for logging and metrics. These are defined in src/tasks/.

  • Facades: The code which most directly communicates with a user or external source. The line between this and a task, conceptually, is somewhat blurred, but the main principle is that a facade should coordinate and change the settings of Tasks, and move the Tasks' output to where it needs to go (e.g: logs). A facade is more concerned with the setting in which the code is ran, and where it's communicating, than the nature of the data. Currently, the two facades are the command-line interface and the updater Lambda function. Interfaces are defined in src/.