hapi

As a Hapi.js expert, help developers build production-grade APIs with this configuration-first enterprise framework for Node.js. Hapi.js provides built-in input validation (Joi), authentication strategies, a plugin architecture, caching, rate limiting, and comprehensive request lifecycle hooks—suited for teams that need structure, security, and testability without relying heavily on third-party middleware.

Last repository push
GitHub Stars
219
Forks
38
Issues / PRs
7

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "hapi" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-ad1e164fbffd0527764f68e567af070ce2be643a9caf8bea52fa0c242a072909. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

As a Hapi.js expert, help developers build production-grade APIs with this configuration-first enterprise framework for Node.js. Hapi.js provides built-in input validation (Joi), authentication strategies, a plugin architecture, caching, rate limiting, and comprehensive request lifecycle hooks—suited for teams that need structure, security, and testability without relying heavily on third-party middleware.

0 Downloads

Introduction source: third_party · TerminalSkills · 1.0.0 Reference

SkillPi interpretation

Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: hapi
description: >-
  You are an expert in Hapi.js, the configuration-centric enterprise
  framework for Node.js. You help developers build production APIs with
  built-in input validation (Joi), authentication strategies, plugin
  architecture, caching, rate limiting, and comprehensive request lifecycle
  hooks — designed for teams that need structure, security, and testability
  without third-party middleware sprawl.
license: Apache-2.0
compatibility: ''
metadata:
  author: terminal-skills
  version: 1.0.0
  category: Backend Development
  tags:
    - node
    - web-framework
    - enterprise
    - validation
    - auth
    - api
    - plugins

Hapi — Enterprise Node.js Framework

You are an expert in Hapi.js, the configuration-centric enterprise framework for Node.js. You help developers build production APIs with built-in input validation (Joi), authentication strategies, plugin architecture, caching, rate limiting, and comprehensive request lifecycle hooks — designed for teams that need structure, security, and testability without third-party middleware sprawl.

Core Capabilities

Server and Routes

import Hapi from "@hapi/hapi";
import Joi from "joi";

const server = Hapi.server({ port: 3000, host: "0.0.0.0",
  routes: { cors: { origin: ["*"], credentials: true }, validate: { failAction: "error" } },
});

// Route with built-in validation
server.route({
  method: "POST",
  path: "/api/users",
  options: {
    tags: ["api", "users"],
    description: "Create a new user",
    validate: {
      payload: Joi.object({
        name: Joi.string().min(2).max(100).required(),
        email: Joi.string().email().required(),
        role: Joi.string().valid("user", "admin").default("user"),
      }),
    },
    response: {
      schema: Joi.object({
        id: Joi.string().uuid(),
        name: Joi.string(),
        email: Joi.string(),
        role: Joi.string(),
        createdAt: Joi.date(),
      }),
    },
    auth: "jwt",
  },
  handler: async (request, h) => {
    const user = await db.users.create(request.payload);
    return h.response(user).code(201);
  },
});

// Auth strategy
await server.register(require("@hapi/jwt"));
server.auth.strategy("jwt", "jwt", {
  keys: process.env.JWT_SECRET,
  verify: { aud: "my-app", iss: "auth-service", sub: false },
  validate: (artifacts) => ({
    isValid: true,
    credentials: { user: artifacts.decoded.payload },
  }),
});
server.auth.default("jwt");

// Plugin
const usersPlugin: Hapi.Plugin<{}> = {
  name: "users",
  version: "1.0.0",
  register: async (server) => {
    server.route([
      { method: "GET", path: "/api/users", handler: listUsers },
      { method: "GET", path: "/api/users/{id}", handler: getUser },
      { method: "PUT", path: "/api/users/{id}", handler: updateUser },
      { method: "DELETE", path: "/api/users/{id}", handler: deleteUser },
    ]);
  },
};
await server.register(usersPlugin);

await server.start();

Installation

npm install @hapi/hapi @hapi/joi @hapi/jwt @hapi/inert @hapi/vision

Best Practices

  1. Joi validation — Validate all input (params, query, payload, headers) at the route level; rejects bad input before handler
  2. Plugins for modularity — Group related routes/logic into plugins; each plugin is self-contained and testable
  3. Auth strategies — Register auth strategies (JWT, cookie, OAuth) via plugins; apply per-route or as default
  4. Response validation — Validate outgoing responses in development; catches schema drift early
  5. Server methods — Use server.method() for cached, shared functions; built-in caching with TTL
  6. Lifecycle hooks — Use onPreAuth, onPreHandler, onPostHandler for cross-cutting concerns (logging, metrics)
  7. Error handling — Use @hapi/boom for HTTP errors; consistent error format across all routes
  8. Testing — Use server.inject() for integration tests; no HTTP overhead, test routes directly

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供 Hapi.js 企业级 Node.js 框架的完整开发能力
  • 涵盖生产级 API 开发的核心功能:验证、认证、插件架构、缓存等
  • 面向后端开发者解决实际开发痛点,实用价值高
Trigger Precision95/100

Highlights

  • description 在顶层和正文中均有完整且一致的描述
  • 触发词精准覆盖 Hapi.js 核心特性,边界清晰
Structure and Standards90/100

Areas to improve

  • 缺少 When to Use 章节 Reported severity: Minor

    文档结构完整但缺少明确的使用场景说明章节

    Recommendation: 建议添加 When to Use 章节,说明适合使用该 Skill 的具体场景

Execution Reliability88/100

Areas to improve

  • 缺少端到端完整示例 Reported severity: Minor

    提供了代码片段但缺少一个完整的端到端可运行示例

    Recommendation: 建议补充一个完整的端到端示例,展示从服务器启动到路由处理的完整流程

Highlights

  • 代码示例语法正确,依赖包明确
  • 参数使用合理,覆盖了主要使用场景
  • 提供了实用的最佳实践指导
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

  • Install or fetch external dependencies

    Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.

    Mentioned in main document · lines 106
  • Accounts, secrets or authorization

    Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.

    Mentioned in main document · lines 39, 80, 113

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.