import { BootMixin } from '@loopback/boot' ; import { ApplicationConfig , BindingScope } from '@loopback/core' ; import { RestApplication } from '@loopback/rest' ; import { RestExplorerBindings , RestExplorerComponent , } from '@loopback/rest-explorer' ; import path from 'path' ; import { APPLICATION_COUNTER , REQUEST_COUNTER , SERVER_COUNTER } from './keys' ; import { SpyMiddlewareProvider } from './middleware/spy.middleware' ; import { MySequence } from './sequence' ; import { CounterProvider } from './services' ; export { ApplicationConfig } ; export class BindingDemoApplication extends BootMixin ( RestApplication ) { constructor ( options = { } ) { super ( options ) ; this . sequence ( MySequence ) ; this . middleware ( SpyMiddlewareProvider ) ; this . bind ( APPLICATION_COUNTER ) . toProvider ( CounterProvider ) . inScope ( BindingScope . APPLICATION ) ; this . bind ( SERVER_COUNTER ) . toProvider ( CounterProvider ) . inScope ( BindingScope . SERVER ) ; this . bind ( REQUEST_COUNTER ) . toProvider ( CounterProvider ) . inScope ( BindingScope . REQUEST ) ; this . static ( '/' , path . join ( __dirname , '../public' ) ) ; this . configure ( RestExplorerBindings . COMPONENT ) . to ( { path : '/explorer' , } ) ; this . component ( RestExplorerComponent ) ; this . projectRoot = __dirname ; this . bootOptions = { controllers : { dirs : [ 'controllers' ] , extensions : [ '.controller.js' ] , nested : true , } , } ; } }