import AdminJS from 'adminjs' ; import { Module , DynamicModule , OnModuleInit , Inject } from '@nestjs/common' ; import { HttpAdapterHost } from '@nestjs/core' ; import { serveStaticProvider } from './serve-static.provider' ; import { CONFIG_TOKEN } from './token.constants' ; import { AbstractLoader } from './loaders/abstract.loader' ; import { AdminModuleOptions } from './interfaces/admin-module-options.interface' ; import { AdminModuleFactory } from './interfaces/admin-module-factory.interface' ; import { CustomLoader } from './interfaces/custom-loader.interface' ; summary class name alias memberof @ Module ( { } ) export class AdminModule implements OnModuleInit { constructor ( private readonly httpAdapterHost , private readonly loader , @ Inject ( CONFIG_TOKEN ) private readonly adminModuleOptions ) { } param { AdminModuleOptions } options memberof method name example public static createAdmin ( options ) { return { module : AdminModule , providers : [ { provide : CONFIG_TOKEN , useValue : options , } , options . customLoader ? { provide : AbstractLoader , useClass : options . customLoader , } : serveStaticProvider , ] , } ; } param { AdminModuleFactory } options memberof method name example public static createAdminAsync ( options ) { return { imports : options . imports , module : AdminModule , providers : [ { provide : CONFIG_TOKEN , useFactory : options . useFactory , inject : options . inject , } , options . customLoader ? { provide : AbstractLoader , useClass : options . customLoader , } : serveStaticProvider , ] , } ; } /**
     * Applies given options to AdminJS and initializes it
     */ public onModuleInit ( ) { if ( 'shouldBeInitialized' in this . adminModuleOptions && ! this . adminModuleOptions . shouldBeInitialized ) { return ; } const admin = new AdminJS ( this . adminModuleOptions . adminJsOptions ) ; const { httpAdapter } = this . httpAdapterHost ; this . loader . register ( admin , httpAdapter , { ... this . adminModuleOptions , adminJsOptions : admin . options , } ) ; } }