@nestjs/common#CustomDecorator TypeScript Examples

The following examples show how to use @nestjs/common#CustomDecorator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: mqtt.decorator.ts    From nest-mqtt with MIT License 6 votes vote down vote up
export function Subscribe(topicOrOptions): CustomDecorator {
  if (typeof topicOrOptions === 'string' || Array.isArray(topicOrOptions)) {
    return SetMetadata(MQTT_SUBSCRIBE_OPTIONS, {
      topic: topicOrOptions,
    });
  } else {
    return SetMetadata(MQTT_SUBSCRIBE_OPTIONS, topicOrOptions);
  }
}
Example #2
Source File: fetch.resources.decorator.ts    From nestjs-keycloak-admin with MIT License 5 votes vote down vote up
FetchResources = (): CustomDecorator<string> =>
  SetMetadata<string, boolean>(META_FETCH_RESOURCES, true)
Example #3
Source File: public.decorator.ts    From nestjs-keycloak-admin with MIT License 5 votes vote down vote up
Public = (): CustomDecorator<string> => SetMetadata<string, boolean>(META_PUBLIC, true)
Example #4
Source File: resource.decorator.ts    From nestjs-keycloak-admin with MIT License 5 votes vote down vote up
DefineResource = (resource: string): CustomDecorator<string> =>
  SetMetadata<string, string>(META_RESOURCE, resource)
Example #5
Source File: resource.enforcer.decorator.ts    From nestjs-keycloak-admin with MIT License 5 votes vote down vote up
EnforceResource = (options: EnforceResourceOptions): CustomDecorator<string> =>
  SetMetadata<string, EnforceResourceOptions>(META_RESOURCE_ENFORCER, options)
Example #6
Source File: roles.decorator.ts    From nestjs-keycloak-admin with MIT License 5 votes vote down vote up
Roles = (option: RoleDecoratorOption): CustomDecorator<string> =>
  SetMetadata<string, RoleDecoratorOption>(META_ROLES, option)
Example #7
Source File: scope.decorator.ts    From nestjs-keycloak-admin with MIT License 5 votes vote down vote up
DefineScope = (scope: string): CustomDecorator<string> =>
  SetMetadata<string, string>(META_SCOPE, scope)
Example #8
Source File: roles.decorator.ts    From codeclannigeria-backend with MIT License 5 votes vote down vote up
Roles = (...roles: UserRole[]): CustomDecorator<typeof UserRole> =>
  SetMetadata(UserRole, roles)
Example #9
Source File: use-ability.ts    From nest-casl with MIT License 5 votes vote down vote up
export function UseAbility<Subject = AnyObject, Request = AuthorizableRequest>(
  action: string,
  subject: AnyClass<Subject>,
  subjectHook?: AnyClass<SubjectBeforeFilterHook<Subject, Request>> | SubjectBeforeFilterTuple<Subject, Request>,
): CustomDecorator {
  return SetMetadata(CASL_META_ABILITY, { action, subject, subjectHook });
}
Example #10
Source File: role.decorator.ts    From nestjs-starter-rest-api with MIT License 5 votes vote down vote up
Roles = (...roles: ROLE[]): CustomDecorator<string> =>
  SetMetadata(ROLES_KEY, roles)
Example #11
Source File: roles.decorator.ts    From MyAPI with MIT License 5 votes vote down vote up
Roles = (...roles: DefaultRole[]): CustomDecorator<string> => {
  return SetMetadata('roles', roles)
}
Example #12
Source File: roles.decorator.ts    From office-hours with GNU General Public License v3.0 5 votes vote down vote up
Roles = (...roles: string[]): CustomDecorator<string> =>
  SetMetadata('roles', roles)