feathers-hookslisted
Install: claude install-skill hassan4702/feathers-plugin
# FeathersJS Hooks
Hooks are transport-independent middleware registered **around / before / after / error** of service methods, without touching the service code. They run in registration order; if one throws, the remaining hooks and the service call are skipped and the error propagates.
## Two hook shapes
**Around hooks** wrap the call and receive `(context, next)`. They must `await next()` to run the rest of the chain. Everything before `await next()` happens on the way in; everything after happens on the way out. Use these for timing, transactions, error wrapping, and the schema resolvers.
```ts
import type { HookContext, NextFunction } from '../declarations'
import { logger } from '../logger'
export const logRuntime = async (context: HookContext, next: NextFunction) => {
const start = Date.now()
await next()
logger.info(`${context.method} on ${context.path} took ${Date.now() - start}ms`)
}
```
**before / after / error hooks** receive only `(context)` — no `next`. Use these for the common cases.
```ts
import type { HookContext } from '../declarations'
export const setTimestamp = async (context: HookContext) => {
context.data = { ...context.data, createdAt: Date.now() }
return context
}
```
A before hook that throws blocks the method. An after hook can transform `context.result`. Always return `context`.
## The hook context
Read-only: `context.app` (call other services via `context.app.service('users')`), `context.service`, `context.path`, `context.met