import 'reflect-metadata' ; import { CONFIG_CONFIGURABLE , CONFIG_PARAMS } from '../constants' ; import { applyParamsMetadataDecorator } from '../utils' ; import { ConfigService } from '../module' ; export const Configurable = ( ) : MethodDecorator => { return ( target , key , descriptor ) => { const originalMethod = descriptor . value ; descriptor . value = function ( ... args ) { const paramsMetadata = ( Reflect . getMetadata ( CONFIG_PARAMS , target , key ) || [ ] ) . filter ( ( p ) => { return p . propertyKey === key ; } ) ; return originalMethod . apply ( this , applyParamsMetadataDecorator ( paramsMetadata , args , ConfigService . get ) ) ; } ; Reflect . defineMetadata ( CONFIG_CONFIGURABLE , Reflect . getMetadata ( CONFIG_PARAMS , target , key ) || [ ] , descriptor . value ) ; return descriptor ; } ; } ;