setSlug
Source Code | DocumentationExtracts URL route parameters (slugs) and sets them on params.query. For example, given a route /stores/:storeId, this hook copies the resolved storeId value from params.route into the query. Only applies to the rest provider.
ts
import { setSlug } from 'feathers-utils/hooks';Example
ts
import { setSlug } from 'feathers-utils/hooks'
app.service('stores/:storeId/products').hooks({
before: { all: [setSlug('storeId')] }
})Type declaration
Show Type Declarations
ts
/**
* Extracts URL route parameters (slugs) and sets them on `params.query`.
* For example, given a route `/stores/:storeId`, this hook copies the resolved
* `storeId` value from `params.route` into the query. Only applies to the `rest` provider.
*
* @example
* ```ts
*
*
* app.service('stores/:storeId/products').hooks({
* before: { all: [setSlug('storeId')] }
* })
* ```
*
* @see https://utils.feathersjs.com/hooks/set-slug.html
*/
export declare const setSlug: <H extends HookContext = HookContext>(
slug: string,
fieldName?: string,
) => (context: H, next?: NextFunction) => any| Argument | Type | Description |
|---|---|---|
| slug | string | |
| fieldName | string |
| type | methods | multi |
|---|---|---|
| before, after, around | all | yes |
