hapi

Compose Hapi v21+ servers with TypeScript generics and Joi validation.

3|Updated Mar 8, 2026
One-click install
npx skills add https://github.com/avifenesh/glidemq-hapi --skill hapi-avifenesh
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hapi
Source: https://github.com/avifenesh/glidemq-hapi/tree/main/.claude/skills/hapi
Command: npx skills add https://github.com/avifenesh/glidemq-hapi --skill hapi-avifenesh

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Hapi’s power comes with a lot of architectural moving parts, and this Skill helps you wire servers, routes, auth, validation, lifecycle extensions, and testing patterns together correctly and consistently.

Core Features & Use Cases

  • Guide Hapi server composition: structure a server with decorations, methods, plugins, and a clear request lifecycle strategy.
  • Make requests safe and predictable: validate route params, query, payload, and headers using Joi with consistent error handling.
  • Type routes end-to-end in TypeScript: apply ServerRoute<Refs> generics so request.params, request.query, request.payload, auth, and lifecycle methods remain strongly typed.
  • Use auth with proper layering: model scheme → strategy → default, configure route auth modes, and apply scope/entity access control patterns.
  • Operational confidence: follow startup/shutdown lifecycle rules and use server.inject()-style testing patterns for fast assertions.

Quick Start

Use the hapi skill to plan how to register plugins, validate inputs, configure route auth, and type your handlers for a new REST endpoint.

Frequently Asked Questions about hapi

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I type Hapi route handlers in TypeScript so request params and payload are strongly typed?

To type Hapi routes in TypeScript, apply the ServerRoute<Refs> generics to your route definitions. This ensures request.params, request.query, request.payload, and auth artifacts remain strongly typed throughout the request lifecycle.

What is the best way to validate Hapi request inputs using Joi?

The best way to validate Hapi request inputs is by attaching Joi schemas to the route's validate options for params, query, payload, and headers. This provides consistent validation and automatic error handling during the request lifecycle.

How does Hapi authentication layering work when configuring route access?

Hapi auth layering works by defining an authentication scheme, applying it to a strategy, and setting a default strategy. You then configure route auth modes and apply scope or entity access rules to control endpoint access.

Can I use Hapi server decorations and methods to structure a plugin-driven API?

Yes, you can structure a Hapi server with decorations and custom methods to organize plugin-driven architectures. This approach coordinates server lifecycle hooks and pre-handlers effectively across your REST API endpoints.

How do I test Hapi server routes without starting the network listener?

To test Hapi server routes without a network listener, use the server.inject() method. This simulates HTTP requests internally, allowing fast assertions against route handlers, validation, and request lifecycle behavior.