← ClaudeAtlas

feathers-hookslisted

Write and register FeathersJS v5 hooks — pluggable middleware that runs around, before, after, or on error of a service method, for authentication, authorization, validation, logging, populating data, and side effects. Use whenever the user wants to add cross-cutting logic to a Feathers service, mentions a hook, HookContext, next(), context.params / context.data / context.result, authenticate('jwt'), "run before create", "check permissions", "log requests", or asks why a hook isn't firing or runs in the wrong order. Trigger for any Feathers middleware-shaped request even if the word "hook" isn't used.
hassan4702/feathers-plugin · ★ 3 · Data & Documents · score 74
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