Skip to content

throwIfIsProvider

Source Code | Documentation

See also: isProvider

Throw an error for certain transports.

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

Type declaration

ts
export type ThrowIfIsIsProviderOptions = {
  filter?: PredicateFn
  /**
   * Customize the error that is thrown if the context is a provider and the service does not allow it.
   * If not provided, throws a `MethodNotAllowed` error.
   */
  error?: (context: HookContext) => FeathersError
}
/**
 * Throw an error for certain transports.
 *
 * @see https://utils.feathersjs.com/hooks/throw-if-is-provider.html
 */
export declare const throwIfIsProvider: <H extends HookContext = HookContext>(
  transports: TransportName | TransportName[],
  options?: ThrowIfIsIsProviderOptions,
) => (context: H, next?: HookContext) => Promise<any>
ArgumentTypeDescription
transportsTransportName | TransportName[]
optionsThrowIfIsIsProviderOptions
typemethodsmulti
before, after, aroundcreate, update, patchyes

Released under the MIT License.