Class

AdminModule

@adminjs/nestjs~AdminModule()

Constructor

# new AdminModule()

Nest Module

Nest module which is responsible for an AdminJS integration

View Source adminjs-nestjs/src/admin.module.ts, line 17

Methods

# static createAdmin(options) → {DynamicModule}

Creates admin in a synchronous way
Parameters:
Name Type Description
options AdminModuleOptions

View Source adminjs-nestjs/src/admin.module.ts, line 155

DynamicModule
Example
import { Module } from '@nestjs/common';
import { AdminModule } from '@adminjs/nestjs';

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

# static createAdminAsync(options) → {DynamicModule}

Creates admin in an asynchronous way
Parameters:
Name Type Description
options AdminModuleFactory

View Source adminjs-nestjs/src/admin.module.ts, line 180

DynamicModule
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
        adminJsOptions: {
          rootPath: '/admin',
          resources: [
            { resource: adminModel },
          ],
        },
      }),
    }),
    MongooseSchemasModule,
    ],
 })
 export class AppModule { }