當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Store.fromMethod方法代碼示例

本文整理匯總了TypeScript中@tsed/core.Store.fromMethod方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Store.fromMethod方法的具體用法?TypeScript Store.fromMethod怎麽用?TypeScript Store.fromMethod使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@tsed/core.Store的用法示例。


在下文中一共展示了Store.fromMethod方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: before

 before(() => {
   ReturnsArray({
     description: "Success",
     type: Test
   })(Test, "test4", descriptorOf(Test, "test4"));
   this.store = Store.fromMethod(Test, "test4");
 });
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:7,代碼來源:returnsArray.spec.ts

示例2: 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

示例3: it

    it("should set the responses", () => {
      // WHEN
      Responses(400, {
        description: "Bad Request"
      })(Test);

      // THEN
      const store = Store.fromMethod(Test, "test");

      store.get("responses").should.deep.eq({
        "400": {
          description: "Bad Request"
        }
      });
    });
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:15,代碼來源:responses.spec.ts

示例4: it

    it("should set the operation", () => {
      // WHEN
      Operation({
        security: [
          {"auth": ["scope"]}
        ]
      })(Test);

      // THEN
      const store = Store.fromMethod(Test, "test");

      store.get("operation").should.deep.eq({
        security: [
          {"auth": ["scope"]}
        ]
      });
    });
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:17,代碼來源:operation.spec.ts

示例5: before

 before(() => {
   MulterOptions({dest: "/"})(Test.prototype, "test", descriptorOf(Test.prototype, "test"));
   this.store = Store.fromMethod(Test.prototype, "test");
 });
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:4,代碼來源:multerOptions.spec.ts

示例6: return

  return (target: any, propertyKey: string, parameterIndex: number): void => {
    const type = getDecoratorType([target, propertyKey, parameterIndex], true);

    switch (type) {
      default:
        throw new Error("MultipartFile is only supported on parameters");

      case "parameter":
        const store = Store.fromMethod(target, propertyKey);
        const multiple = Metadata.getParamTypes(target, propertyKey)[parameterIndex] === Array;
        const options = typeof name === "object" ? name : undefined;
        const added = store.has("multipartAdded");

        name = (typeof name === "object" ? undefined : name)!;

        // create endpoint metadata
        store.merge("consumes", ["multipart/form-data"]).set("multipartAdded", true);
        store
          .merge("responses", {
            "400": {
              description: `<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field>  [fieldName]
                            Example: File too long file1`
            }
          })
          .set("multipartAdded", true);

        if (!added) {
          // middleware is added
          UseBefore(MultipartFileMiddleware)(target, propertyKey, descriptorOf(target, propertyKey));
        }

        if (name === undefined) {
          store.merge(MultipartFileMiddleware, {
            options,
            any: true
          });

          ParamRegistry.useFilter(multiple ? MultipartFilesFilter : MultipartFileFilter, {
            propertyKey,
            parameterIndex,
            target,
            useConverter: false,
            paramType: ParamTypes.FORM_DATA
          });
        } else {
          const expression = multiple ? (name as string) : name + ".0";

          store.merge(MultipartFileMiddleware, {
            fields: [
              {
                name,
                maxCount
              }
            ],
            options
          });

          ParamRegistry.useFilter(MultipartFilesFilter, {
            expression,
            propertyKey,
            parameterIndex,
            target,
            useConverter: false,
            paramType: ParamTypes.FORM_DATA
          });
        }

        break;
    }
  };
開發者ID:Romakita,項目名稱:ts-express-decorators,代碼行數:70,代碼來源:multipartFile.ts


注:本文中的@tsed/core.Store.fromMethod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。