import { Binding , Context , globalInterceptor , inject , Interceptor , InvocationContext , InvocationResult , Provider , ValueOrPromise , } from '@loopback/core' ; import { bindingScope , count , logContext , logContexts } from '../util' ; /**
 * This class will be bound to the application as an `Interceptor` during
 * `boot`
 */ @ globalInterceptor ( 'spy' , { tags : { name : 'Spy' } } , { scope : bindingScope ( 'SpyInterceptor' ) } ) export class SpyInterceptorProvider implements Provider < Interceptor > { constructor ( @ inject . context ( ) resolutionCtx , @ inject . binding ( ) private binding ) { logContexts ( resolutionCtx , binding ) ; } returns value ( ) { return this . intercept . bind ( this ) ; } param invocationCtx param next async intercept ( invocationCtx , next ) { try { logContext ( 'Invocation' , invocationCtx , this . binding ) ; await count ( invocationCtx , 'SpyInterceptor' ) ; const result = await next ( ) ; return result ; } catch ( err ) { console . error ( err ) ; throw err ; } } }