Constructor
# new AdminModule()
Nest Module
Nest module which is responsible for an AdminJS integration
Methods
# static createAdmin(options) → {DynamicModule}
Creates admin in a synchronous way
Parameters:
Name | Type | Description |
---|---|---|
options |
AdminModuleOptions
|
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
|
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 { }