UNPKG

@multiplatform.one/typegraphql

Version:
71 lines (68 loc) 2.03 kB
import { __name } from "./chunk-SHUYVCID.js"; // src/decorate.ts import { container as Container, Lifecycle, container } from "tsyringe"; import { createMethodDecorator as typeGraphqlCreateMethodDecorator } from "type-graphql"; function applyMethodDecorators(...decorators) { return (target, propertyKey, descriptor) => { let result; for (const decorator of decorators) { result = decorator(target, propertyKey, descriptor); } return result; }; } __name(applyMethodDecorators, "applyMethodDecorators"); function applyParamDecorators(...decorators) { return (target, propertyKey, parameterIndex) => { let result; for (const decorator of decorators) { result = decorator(target, propertyKey, parameterIndex); } return result; }; } __name(applyParamDecorators, "applyParamDecorators"); function applyPropertyDecorators(...decorators) { return (target, propertyKey) => { let result; for (const decorator of decorators) { result = decorator(target, propertyKey); } return result; }; } __name(applyPropertyDecorators, "applyPropertyDecorators"); function applyClassDecorators(...decorators) { return (target) => { let result; for (const decorator of decorators) { result = decorator(target); } return result; }; } __name(applyClassDecorators, "applyClassDecorators"); function createMethodDecorator(resolver, _container = Container) { container.register(resolver, { useClass: resolver }, { lifecycle: Lifecycle.ContainerScoped }); return typeGraphqlCreateMethodDecorator(resolver); } __name(createMethodDecorator, "createMethodDecorator"); function getMetadata(metadataKeyOrDecorator, target) { const metadataKey = metadataKeyOrDecorator.KEY ?? metadataKeyOrDecorator; return Reflect.getMetadata(metadataKey, target); } __name(getMetadata, "getMetadata"); export { applyMethodDecorators, applyParamDecorators, applyPropertyDecorators, applyClassDecorators, createMethodDecorator, getMetadata };