hapi
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "hapi":https://skillpi.com/zh/skills/deepskill-ad1e164fbffd0527764f68e567af070ce2be643a9caf8bea52fa0c242a072909。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
作为 Hapi.js 专家,帮助开发者使用这个 Node.js 的配置优先的企业级框架构建生产级 API。Hapi.js 提供内置输入验证(Joi)、认证策略、插件架构、缓存、速率限制和全面的请求生命周期钩子,适合需要结构性、安全性和可测试性的团队,减少对第三方中间件的依赖。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 实测状态
- 未测试
文件浏览
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
- pluginsHapi — 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
- Joi validation — Validate all input (params, query, payload, headers) at the route level; rejects bad input before handler
- Plugins for modularity — Group related routes/logic into plugins; each plugin is self-contained and testable
- Auth strategies — Register auth strategies (JWT, cookie, OAuth) via plugins; apply per-route or as default
- Response validation — Validate outgoing responses in development; catches schema drift early
- Server methods — Use
server.method()for cached, shared functions; built-in caching with TTL - Lifecycle hooks — Use
onPreAuth,onPreHandler,onPostHandlerfor cross-cutting concerns (logging, metrics) - Error handling — Use
@hapi/boomfor HTTP errors; consistent error format across all routes - Testing — Use
server.inject()for integration tests; no HTTP overhead, test routes directly
当前收录版本
1.0.0
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 Hapi.js 企业级 Node.js 框架的完整开发能力
- 涵盖生产级 API 开发的核心功能:验证、认证、插件架构、缓存等
- 面向后端开发者解决实际开发痛点,实用价值高
亮点
- description 在顶层和正文中均有完整且一致的描述
- 触发词精准覆盖 Hapi.js 核心特性,边界清晰
待提升项
-
缺少 When to Use 章节 原报告严重程度:轻微
文档结构完整但缺少明确的使用场景说明章节
改进建议:建议添加 When to Use 章节,说明适合使用该 Skill 的具体场景
待提升项
-
缺少端到端完整示例 原报告严重程度:轻微
提供了代码片段但缺少一个完整的端到端可运行示例
改进建议:建议补充一个完整的端到端示例,展示从服务器启动到路由处理的完整流程
亮点
- 代码示例语法正确,依赖包明确
- 参数使用合理,覆盖了主要使用场景
- 提供了实用的最佳实践指导
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 106 行 -
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 39, 80, 113 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。