Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("should get meta on a class", () => {
expect(Metadata.get("metadatakey1", Test)).to.equal("test1");
});
static getParams(target: Type, propertyKey: string | symbol): ParamMetadata[] {
return Metadata.has(PARAM_METADATA, target, propertyKey) ? Metadata.get(PARAM_METADATA, target, propertyKey) : [];
}
constructor(options: IHandlerOptions) {
const {target, token, method, type = HandlerType.FUNCTION} = options;
this.type = type;
this.handler = method ? target.prototype[method] : target;
if (method) {
this.target = target;
this.token = token!;
this.methodClassName = method;
this.method = method;
this.hasNextFunction = this.hasParamType(ParamTypes.NEXT_FN);
this.hasErrorParam = this.hasParamType(ParamTypes.ERR);
this.injectable = (Metadata.get(PARAM_METADATA, target, method) || []).length > 0;
}
if (!this.injectable) {
this.hasErrorParam = this.handler.length === 4;
this.hasNextFunction = this.handler.length >= 3;
}
}
getConverter(targetType: any): IConverter | undefined {
if (Metadata.has(CONVERTER, targetType)) {
const converter = Metadata.get(CONVERTER, targetType);
if (converter) {
return this.injectorService.get(converter);
}
}
}