file module import { CacheKey , ReflectMetadata } from '@nestjs/common' ; import * as lodash from 'lodash' ; import * as META from '../common/constants/meta.constant' ; interface ICacheOption { ttl ? : number ; key ? : string ; } function description example HttpCache example HttpCache export function HttpCache ( option ) ; export function HttpCache ( key , ttl ? ) ; export function HttpCache ( ... args ) { const option = args [ 0 ] ; const isOption = ( value ) : value is ICacheOption => lodash . isObject ( value ) ; const key = isOption ( option ) ? option . key : option ; const ttl = isOption ( option ) ? option . ttl : ( args [ 1 ] || null ) ; return ( _ , __ , descriptor ) => { if ( key ) { CacheKey ( key ) ( descriptor . value ) ; } if ( ttl ) { ReflectMetadata ( META . HTTP_CACHE_TTL_METADATA , ttl ) ( descriptor . value ) ; } return descriptor ; } ; }