How to use the @tsed/core.Metadata.set function in @tsed/core

To help you get started, we’ve selected a few @tsed/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TypedProject / ts-express-decorators / test / units / core / class / Metadata.spec.ts View on Github external
it("should return unique provide from property key", () => {
      Metadata.set("controller", "test", Test);
      Metadata.set("controller", "test2", Test2);
      Metadata.set("controller", "test", Test);

      const result = Metadata.getTargetsFromPropertyKey("controller");

      expect(result).to.be.an("array");
      // expect(result.length).to.equal(2);
      expect(result.indexOf(Test) > -1).to.be.true;
      expect(result.indexOf(Test2) > -1).to.be.true;

      const result2 = Metadata.getTargetsFromPropertyKey("controller2");

      expect(result2).to.be.an("array");
      expect(result2.length).to.equal(0);
    });
  });
github TypedProject / ts-express-decorators / test / units / core / class / Metadata.spec.ts View on Github external
it("should return unique provide from property key", () => {
      Metadata.set("controller", "test", Test);
      Metadata.set("controller", "test2", Test2);
      Metadata.set("controller", "test", Test);

      const result = Metadata.getTargetsFromPropertyKey("controller");

      expect(result).to.be.an("array");
      // expect(result.length).to.equal(2);
      expect(result.indexOf(Test) > -1).to.be.true;
      expect(result.indexOf(Test2) > -1).to.be.true;

      const result2 = Metadata.getTargetsFromPropertyKey("controller2");

      expect(result2).to.be.an("array");
      expect(result2.length).to.equal(0);
    });
  });
github TypedProject / ts-express-decorators / test / units / core / class / Metadata.spec.ts View on Github external
it("should set meta on instance", () => {
      expect(Metadata.set("metadatakey2", "test2", new Test())).to.equal(undefined);
      expect(Metadata.has("metadatakey2", Test)).to.be.true;
    });
github TypedProject / ts-express-decorators / packages / common / src / mvc / registries / EndpointRegistry.ts View on Github external
static getOwnEndpoints(target: Type) {
    if (!this.hasEndpoints(target)) {
      Metadata.set("endpoints", [], target);
    }

    return Metadata.getOwn("endpoints", target);
  }
github TypedProject / ts-express-decorators / packages / common / src / mvc / registries / EndpointRegistry.ts View on Github external
static get(target: Type, method: string | symbol): EndpointMetadata {
    if (!this.has(target, method)) {
      const endpoint = new EndpointMetadata(target, method);
      this.getOwnEndpoints(target).push(endpoint);
      Metadata.set("endpoints", endpoint, target, method);
    }

    return Metadata.getOwn("endpoints", target, method);
  }