hapi

📁 damusix/skills 📅 14 days ago
18
总安装量
17
周安装量
#19577
全站排名
安装命令
npx skills add https://github.com/damusix/skills --skill hapi

Agent 安装分布

opencode 17
github-copilot 17
codex 17
kimi-cli 17
gemini-cli 17
amp 17

Skill 文档

Hapi

Quick Start

const server = Hapi.server({ port: 3000 });
server.route({ method: 'GET', path: '/', handler: () => 'ok' });
await server.start();

Critical Rules

  1. Compose with decorations & methods – Expose services via decorations and reusable logic via methods
  2. Follow the lifecycle – 24-step request flow; see lifecycle overview
  3. Auth is three layers – scheme → strategy → default; see server auth
  4. Validate at the route – Use joi schemas on params, query, payload, headers; see validation
  5. Type routes with Refs – Use ServerRoute<Refs> pattern; see route scaffold

Workflow

  1. Create serverserver overview for constructor options
  2. Register pluginsplugins and plugin structure
  3. Configure authauth schemes and route auth
  4. Define routesroute overview with handlers
  5. Add extensionslifecycle hooks and pre-handlers

Key Patterns

Topic Reference
Request/response objects request, response
Response toolkit (h) toolkit
Sessions (yar) sessions
Caching & CORS cache-cors, server cache, catbox-memory engine, catbox-fs engine, catbox-redis engine
Security headers security
Payload parsing payload
Decorations & methods decorations, methods
MIME types (mimos) mimos
Realms & plugin scoping realm
Response marshalling marshal pipeline
File serving (inert) overview, file handler, directory handler
Basic authentication basic auth
Error handling (Boom) boom errors
Error filtering (Bounce) bounce utility
WebSockets (nes) overview, subscriptions, client
Startup & shutdown startup lifecycle
Events events
Testing (server.inject) network
TypeScript overview typescript
TypeScript auth typing auth-scheme, type-author
JWT authentication jwt overview, validate function, token API
TypeScript plugins plugin-scaffold
Views & templates vision overview, engines, context & layouts