import {BootMixin} from '@loopback/boot'; import {ApplicationConfig} from '@loopback/core'; import {RepositoryMixin} from '@loopback/repository'; import {RestApplication} from '@loopback/rest'; import { RestExplorerBindings, RestExplorerComponent, } from '@loopback/rest-explorer'; import {ServiceMixin} from '@loopback/service-proxy'; import path from 'path'; import {MySequence} from './sequence'; import { BearerTokenVerifyProvider } from './providers/bearer-token-verify-provider'; import { AuthenticationComponent, Strategies } from 'loopback4-authentication'; import { AuthorizationBindings, AuthorizationComponent } from 'loopback4-authorization'; import { RedisDataSource, UncoreCentralDataSource } from './datasources'; import { BlockedUserRepository, MigrationRepository, ProviderRepository, RevokedTokenRepository } from './repositories'; import { UserBlockingService } from './services/user-blocking.service'; export {ApplicationConfig}; export class LibraryUncoreCentralApplication extends BootMixin( ServiceMixin(RepositoryMixin(RestApplication)), ) { constructor(options: ApplicationConfig = {}) { super(options); this.service(UserBlockingService) // Set up the custom sequence this.sequence(MySequence); this.dataSource(UncoreCentralDataSource) this.dataSource(RedisDataSource) this.repository(ProviderRepository) this.repository(MigrationRepository) this.repository(RevokedTokenRepository) this.repository(BlockedUserRepository) // Set up default home page this.static('/', path.join(__dirname, '../public')); // Customize @loopback/rest-explorer configuration here this.configure(RestExplorerBindings.COMPONENT).to({ path: '/explorer', }); this.component(RestExplorerComponent); this.component(AuthenticationComponent); this.bind(Strategies.Passport.BEARER_TOKEN_VERIFIER).toProvider( BearerTokenVerifyProvider, ); this.bind(AuthorizationBindings.CONFIG).to({ allowAlwaysPaths: ['/explorer'], }); this.component(AuthorizationComponent); this.projectRoot = __dirname; // Customize @loopback/boot Booter Conventions here this.bootOptions = { controllers: { // Customize ControllerBooter Conventions here dirs: ['controllers'], extensions: ['.controller.js'], nested: true, }, }; } }