Creates, configures, and debugs `@hapi/hapi` servers โ implements routes, plugins, auth schemes, validation, caching, and request lifecycle hooks. Use when building HTTP APIs, setting up stale-while-revalidate caching, registering server methods, configuring views, managing startup sequences, or troubleshooting response marshalling.
Installation
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Creates, configures, and debugs `@hapi/hapi` servers โ implements routes, plugins, auth schemes, validation, caching, and request lifecycle hooks. Use when building HTTP APIs, setting up stale-while-revalidate caching, registering server methods, configuring views, managing startup sequences, or troubleshooting response marshalling.
Auth is three layers - scheme โ strategy โ default; see server auth
Validate at the route - Use joi schemas on params, query, payload, headers; see validation
Type routes with Refs - Use ServerRoute<Refs> with ONLY the keys you need (Params, Query, Payload, etc.); omitted keys keep defaults. See route scaffold
Auth three-layer pattern:
server.auth.scheme('custom', schemeImpl); // 1. scheme (how to authenticate)
server.auth.strategy('session', 'custom', options); // 2. strategy (configured instance)
server.auth.default('session'); // 3. default (apply to all routes)
Scheme authenticate MUST return h.authenticated() with both credentials AND artifacts:
return h.authenticated({
credentials: { user: { id, name }, scope: ['user'] },
artifacts: { token } // always include artifacts for raw auth data
});