当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript core.getDecoratorType函数代码示例

本文整理汇总了TypeScript中@tsed/core.getDecoratorType函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getDecoratorType函数的具体用法?TypeScript getDecoratorType怎么用?TypeScript getDecoratorType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getDecoratorType函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: switch

  return <T>(...args: DecoratorParameters): TypedPropertyDescriptor<T> | void => {
    switch (getDecoratorType(args, true)) {
      case "method":
        return Store.decorate((store: Store) => {
          store.set(guardAuth, options);

          if (options.responses) {
            const {responses} = options;
            store.merge("responses", responses);
          }

          if (options.security) {
            const {security} = options;
            store.merge("operation", {security});
          }

          return UseBefore(guardAuth);
        })(...args);

      case "class":
        decorateMethodsOf(args[0], UseAuth(guardAuth, options));
        break;

      default:
        throw new UnsupportedDecoratorType(UseAuth, args);
    }
  };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:27,代码来源:useAuth.ts

示例2:

  return <T>(target: Type<any>, targetKey?: string, descriptor?: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T> | void => {
    if (getDecoratorType([target, targetKey, descriptor]) === "method") {
      EndpointRegistry.useAfter(target, targetKey!, args);

      return descriptor;
    }

    Store.from(target).merge("middlewares", {
      useAfter: args
    });
  };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:11,代码来源:useAfter.ts

示例3: return

 return (...args: any[]) => {
   const type = getDecoratorType(args);
   switch (type) {
     case "method":
       return Operation({title})(...args);
     case "parameter":
       return BaseParameter({title})(...args);
     default:
       originalTitleDecorator(title)(...args);
   }
 };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:11,代码来源:title.ts

示例4: return

 return (...parameters: any[]) => {
   switch (getDecoratorType(parameters)) {
     case "property":
       return PropertyRegistry.decorate((propertyMetadata: PropertyMetadata) => {
         propertyMetadata.store.merge(MONGOOSE_SCHEMA, options as SchemaTypeOpts<any>);
       })(...parameters);
     case "class":
       const [target] = parameters;
       createSchema(target, options as MongooseSchemaOptions);
       break;
   }
 };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:12,代码来源:schema.ts

示例5: return

 return (...args: any[]) => {
   const type = getDecoratorType(args);
   switch (type) {
     case "parameter":
       return BaseParameter({name})(...args);
     case "class":
       Store.from(...args).set("name", name);
       break;
     default:
       throw new Error("Name is only supported on parameters and class");
   }
 };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:12,代码来源:name.ts

示例6: return

 return (...args: any[]) => {
   const type = getDecoratorType(args);
   switch (type) {
     case "parameter":
       return BaseParameter({description})(...args);
     case "method":
       return Operation({description})(...args);
     case "class":
       Store.from(...args).set("description", description);
     default:
       Schema({description})(...args);
   }
 };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:13,代码来源:description.ts

示例7: return

  return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
    const type = getDecoratorType([target, propertyKey, descriptor], true);

    switch (type) {
      default:
        throw new Error("MulterOptions is only supported on method");
      case "method":
        Store.fromMethod(target, propertyKey).merge(MultipartFileMiddleware, {
          options
        });

        return descriptor;
    }
  };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:14,代码来源:multerOptions.ts

示例8: return

  return (...args: any[]) => {
    if (getDecoratorType(args) === "method") {
      fn = args[0][args[1]].bind(args[0]);
    }

    applySchemaOptions(args[0], {
      post: [
        {
          method,
          fn: fn as MongoosePostHookCB<any> | MongoosePostErrorHookCB<any>
        }
      ]
    });
  };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:14,代码来源:postHook.ts

示例9: return

  return (...args: DecoratorParameters) => {
    const type = getDecoratorType(args, true);

    switch (type) {
      case "method":
        return Store.decorate((store: Store) => {
          store.merge("responses", {[status]: response});
        })(...args);

      case "class":
        decorateMethodsOf(args[0], Responses(status, response));
        break;

      default:
        throw new UnsupportedDecoratorType(Responses, args);
    }
  };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:17,代码来源:responses.ts

示例10: return

  return (...args: DecoratorParameters) => {
    const type = getDecoratorType(args, true);

    switch (type) {
      case "method":
        return Store.decorate((store: Store) => {
          store.merge("operation", operation);
        })(...args);

      case "class":
        decorateMethodsOf(args[0], Operation(operation));
        break;

      default:
        throw new UnsupportedDecoratorType(Operation, args);
    }
  };
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:17,代码来源:operation.ts


注:本文中的@tsed/core.getDecoratorType函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。