Class

AdminModule

@admin-bro/nestjs~AdminModule()

Constructor

# new AdminModule()

Nest Module

Nest module which is responsible for an AdminBro integration

View Source admin-bro-nestjs/src/admin.module.ts, line 16

Methods

# static createAdmin(options)

Creates admin in an synchronous way

Parameters:
Name Type Description
options AdminModuleOptions

View Source admin-bro-nestjs/src/admin.module.ts, line 33

Example
import { Module } from '@nestjs/common';
import { AdminModule } from '@admin-bro/nestjs';

@Module({
  imports: [
    AdminModule.createAdmin({
       rootPath: '/admin',
       resources: [],
    }),
  ],
})
export class AppModule {}

# static createAdminAsync(options)

Creates admin in an synchronous way

Parameters:
Name Type Description
options AdminModuleFactory

View Source admin-bro-nestjs/src/admin.module.ts, line 67

Example
@Module({
  imports: [
    MongooseModule.forRoot('mongodb://localhost:27017/test'),
    AdminModule.createAdminAsync({
      imports: [
        MongooseSchemasModule, // importing module that exported model we want to inject
      ],
      inject: [
        getModelToken('Admin'), // using mongoose function to inject dependency
      ],
      useFactory: (adminModel: Model<Admin>) => ({ // injected dependecy will appear as an argument
        adminBroOptions: {
          rootPath: '/admin',
          resources: [
            { resource: adminModel },
          ],
        },
      }),
    }),
    MongooseSchemasModule,
    ],
 })
 export class AppModule { }