Skip to content

[Community Docs] Update custom hooks guide with around hooks patterns - #56

Open
TeaBreeze00 wants to merge 1 commit into
mainfrom
docs/contrib/20260331T010425Z-update-custom-hooks-guide-with-around-ho
Open

[Community Docs] Update custom hooks guide with around hooks patterns#56
TeaBreeze00 wants to merge 1 commit into
mainfrom
docs/contrib/20260331T010425Z-update-custom-hooks-guide-with-around-ho

Conversation

@TeaBreeze00

Copy link
Copy Markdown
Collaborator

Community Documentation Contribution

Submitted via: FeathersJS MCP Server (submit_documentation tool)
Contributor: Test User
Target version: v6
Category: hooks
File: docs/v6_docs/guides/custom-hooks.md
Type: Update to existing doc

Validation Results

  • ✅ Schema validation passed
  • ✅ Path restrictions passed
  • ✅ Content sanitization passed
  • ✅ Markdown lint passed
  • ✅ No near-duplicates detected

Description

Added around hooks section and updated examples for v6


This PR was automatically generated by the FeathersJS MCP Server contributor pipeline.
Please review the content carefully before merging.

Copilot AI review requested due to automatic review settings March 31, 2026 01:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the v6 “Custom Hooks” guide to introduce around hooks usage and add a short example for composing multiple hooks.

Changes:

  • Updates the guide title and refreshes the intro/example content.
  • Adds an “Around hooks (v6+)” section with a duration-logging around hook example.
  • Adds a “Composing multiple hooks” section with a composition snippet.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -1,4 +1,4 @@
# Custom Hooks
# Custom Hooks (Updated)

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The document title includes an editorial marker "(Updated)". Please keep the H1 as the stable guide title (e.g., just "Custom Hooks") and avoid versioning/status notes in the heading.

Suggested change
# Custom Hooks (Updated)
# Custom Hooks

Copilot uses AI. Check for mistakes.
```

## Around hooks (v6+)
## Around hooks (v6+ — NEW SECTION)

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section header includes "— NEW SECTION", which reads like an internal note. Please remove this so the published heading is just the topic (e.g., "Around hooks (v6+)").

Suggested change
## Around hooks (v6+ — NEW SECTION)
## Around hooks (v6+)

Copilot uses AI. Check for mistakes.
call, giving you control of both the before and after phases:

```typescript
export const logDuration = async (context: HookContext, next: Function) => {

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The around hook example types next as Function. Elsewhere in the v6 docs the recommended type is NextFunction (for correct typing and to document the intended contract). Update the example signature accordingly and ensure the type is imported in the snippet.

Suggested change
export const logDuration = async (context: HookContext, next: Function) => {
import type { HookContext, NextFunction } from '../declarations';
export const logDuration = async (context: HookContext, next: NextFunction) => {

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +50

```typescript
import { hooks } from '@feathersjs/hooks';

const composed = hooks([validateData, addTimestamp, logDuration]);

Copilot AI Mar 31, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Composing multiple hooks" snippet introduces hooks imported from @feathersjs/hooks, but there’s no surrounding explanation of what this helper is or how composed is then registered on a service. Consider aligning this with the existing docs patterns (composing via arrays passed to app.service(...).hooks(...)) or explicitly explain the dependency/API and show how to apply composed in a hooks registration.

Suggested change
```typescript
import { hooks } from '@feathersjs/hooks';
const composed = hooks([validateData, addTimestamp, logDuration]);
Using the `hooks` helper from `@feathersjs/hooks`, you can compose several hooks
into a single reusable around hook and then register it like any other hook:
```typescript
import { hooks } from '@feathersjs/hooks';
// Compose multiple hooks into a single reusable around hook
const composed = hooks([validateData, addTimestamp, logDuration]);
// Register the composed hook on a service
app.service('messages').hooks({
around: {
all: [composed],
},
});

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants