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

@ar4mirez/hapi-handlers

v4.0.1

Published

Autoload Handlers for HapiJS.

Readme

@ar4mirez/hapi-handlers

npm version CI Node.js License: MIT

Plugin to autoload handlers for hapi.js based on glob patterns.

Note: This package was previously published as hapi-handlers. The scoped package @ar4mirez/hapi-handlers is the actively maintained version.

Requirements

  • Node.js >= 18.0.0
  • @hapi/hapi >= 21.0.0

Installation

npm install @ar4mirez/hapi-handlers

Usage

Basic Registration

const Hapi = require('@hapi/hapi');

const init = async () => {
    const server = Hapi.server({ port: 3000 });

    await server.register({
        plugin: require('@ar4mirez/hapi-handlers'),
        options: {
            includes: 'path/to/**/*Handler.js'
        }
    });

    // Your handlers are now available
    server.route({
        method: 'GET',
        path: '/hello',
        handler: {
            helloHandler: {
                message: 'Hello World!'
            }
        }
    });

    await server.start();
    console.log('Server running on %s', server.info.uri);
};

init();

Multiple Patterns

await server.register({
    plugin: require('@ar4mirez/hapi-handlers'),
    options: {
        includes: [
            'handlers/**/*.js',
            'api/**/handler.js'
        ],
        ignores: ['**/*.test.js']
    }
});

With Glue/Confidence Manifest

const manifest = {
    server: {
        port: 3000
    },
    register: {
        plugins: [
            {
                plugin: '@ar4mirez/hapi-handlers',
                options: {
                    includes: 'handlers/**/*.js',
                    relativeTo: __dirname
                }
            }
        ]
    }
};

Options

includes (required)

  • Type: string | string[]
  • Description: The glob pattern(s) to match handler files.
// Single pattern
includes: 'handlers/**/*.js'

// Multiple patterns
includes: ['handlers/**/*.js', 'api/**/handler.js']

ignores

  • Type: string | string[]
  • Description: Pattern(s) to exclude from matching.
ignores: ['**/*.test.js', '**/*.spec.js']

relativeTo

  • Type: string
  • Default: process.cwd()
  • Description: The base directory for resolving patterns.
relativeTo: __dirname

Handler Signature

Handler files should export a function that returns a hapi handler function:

// handlers/userHandler.js
'use strict';

module.exports = (route, options) => {
    // route: the hapi route configuration
    // options: options passed from route handler config

    return (request, h) => {
        return {
            message: options.message || 'Default message',
            user: request.params.id
        };
    };
};

Using the Handler

server.route({
    method: 'GET',
    path: '/user/{id}',
    handler: {
        userHandler: {
            message: 'User details'
        }
    }
});

Async Handlers

module.exports = (route, options) => {
    return async (request, h) => {
        const user = await fetchUser(request.params.id);
        return user;
    };
};

Migration from v2/v3

Version 4.0.0 has breaking changes to support hapi v21+:

Plugin Registration

// v2/v3 (hapi v13-v16)
server.register({
    register: require('@ar4mirez/hapi-handlers'),
    options: { ... }
}, callback);

// v4 (hapi v21+)
await server.register({
    plugin: require('@ar4mirez/hapi-handlers'),
    options: { ... }
});

Handler Signature

// v2/v3
module.exports = (route, options) => {
    return (request, reply) => {
        return reply({ message: 'Hello' });
    };
};

// v4
module.exports = (route, options) => {
    return (request, h) => {
        return { message: 'Hello' };
        // or: return h.response({ message: 'Hello' });
    };
};

Server Connection

// v2/v3
const server = new Hapi.Server();
server.connection({ port: 3000 });

// v4
const server = Hapi.server({ port: 3000 });

Contributing

See CONTRIBUTING.md for guidelines.

License

MIT - see LICENSE for details.