Skip to content

paramsFromClient

hooks
Source Code | Documentation

See also: hooks/paramsForServer

Server-side hook that extracts whitelisted properties from query._$client back into context.params. This is the counterpart to paramsForServer, which encodes params on the client side for transport.

ts
  import { 
paramsFromClient
} from 'feathers-utils/hooks';

Example

ts
import { paramsFromClient } from 'feathers-utils/hooks'

// Server-side
app.service('users').hooks({
  before: { all: [paramsFromClient('populateParams')] }
})

Type declaration

Show Type Declarations
ts
export type paramsFromClientOptions = {
  /**
   * @default '_$client'
   */
  keyToHide?: string
}
/**
 * Server-side hook that extracts whitelisted properties from `query._$client` back
 * into `context.params`. This is the counterpart to `paramsForServer`, which encodes
 * params on the client side for transport.
 *
 * @example
 * ```ts
 *
 *
 * // Server-side
 * app.service('users').hooks({
 *   before: { all: [paramsFromClient('populateParams')] }
 * })
 * ```
 *
 * @see https://utils.feathersjs.com/hooks/params-from-client.html
 */
export declare const paramsFromClient: (
  whitelist: MaybeArray<string>,
  options?: paramsFromClientOptions,
) => (context: HookContext, next?: NextFunction) => any
ArgumentTypeDescription
whitelistMaybeArray<string>
optionsparamsFromClientOptions
typemethodsmulti
before, aroundallyes

Released under the MIT License.