GIVE ME IMPLEMENTATION OF BELOW UNDERSTAND DEEPLY AND AFTER GIVE ME THE SOLUTION TAKE YOU TIME I want to develop a Dynamic module in nestJS it's about CRUD operation I have framing of code but don't how how to write exactly my idea is as below 1. there will be a module called crud which have all common crud operation 2 .This module will be loaded in every microservie at root level 3. dependency will be managed by end module expalained below 4. This is kind ofmore similar fund with TypeormModule in typeorm npm package https://www.npmjs.com/package/typeorm Though its not same or identical but has some similar funda to work. My programming code blue pring is as below I THINK MAJOR CHALLENGE IS TO DEVELOP CrudModule in crud.module.ts FILE: crud.module.ts @Module({ imports: [], providers: [], exports: [] }) export class CrudModule { static forRoot(options?: CrudModuleOptions): DynamicModule{ } static forFeature(entities?: CrudModuleEntityClassOrSchema[]): DynamicModule{ } static forRootAsync(options: CrudModuleAsyncOptions): DynamicModule{ } } FILE: crud.dynamic.ts export class CrudModuleEntitySchemaOptions{ } export declare class CrudModuleEntitySchema { options: CrudModuleEntitySchemaOptions; readonly "@instanceof": symbol; constructor(options: CrudModuleEntitySchemaOptions); } export type CrudModuleEntityClassOrSchema = Function | CrudModuleEntitySchema; export type CrudModuleOptions = { entities?: CrudModuleEntityClassOrSchema[]; } export interface CrudModuleOptionsFactory { createCrudModuleOptions(): Promise | CrudModuleOptions; } export type CrudModuleAsyncOptions = { name?: string; useExisting?: Type; useClass?: Type; useFactory: (...args: any[]) => Promise | CrudModuleOptions, inject: any[], extraProviders?: Provider[]; } FILE: crud.service.ts export class CrudService { public dataSource!: DataSource; public repository!: Repository; public libraryAppService!: LibraryAppService; constructor( private readonly confService!: ConfService; private readonly logService!: LogService; ) {} inject( dataSource: DataSource, repository: Repository, confService: ConfService, logService: LogService, libraryAppService: LibraryAppService ) { this.repository = repository; this.confService = confService; this.logService = logService; this.libraryAppService = libraryAppService; } checkInjection() { if(this.repository === undefined) throw new InternalServerErrorException('CRUD Repository is not injected.'); } async create(input: IN_DTO): Promise { /** * we can make sure that dependency are injected and availabe for use. * but this will bring some exts overhead but its safe * we are omitting it for now because our useage is under control * at some place where you want to make sure or any dynamaic call you can use as below to make sure * this.checkInjection(); OR yourInstance.checkInjection(); **/ // some logic like.. try{ const post = this.repository.create(input); return (await this.repository.save(post)) as OUT_DTO; } catch(err: any) { this.logService.error(err, err.message); throw new BadRequestException(this.logService.redactSensitive(err.message)); } } } Now, how it will be used in other module is as below other.app.module.ts @Module({ imports: [ CrudModule.forRoot({ // some logic like.. new CrudService(); at this moment not passing // will make this object generic in forFeatureAsync() // not sure this is possible or not .. // or we might not create object here and just do in forFeatureAsync() // as CrudService is generic class }), // originally module is imported and instansiated OtherSubModule ], providers: [], exports: [], }) export class OtherAppModule {} other.sub.module.ts @Module({ imports: [ CrudModule.forFeature(// some relevent code{ // like it will make generic object which is created in forRootAsync new CrudService }) // passing feature related config only ], providers: [OtherSubService], exports: [OtherSubService], }) export class OtherSubModule {} other.sub.service.ts export class OtherSubService{ constructor( private dataSource: DataSource, @InjectRepository(OtherSubEntity) private readonly repository: Repository, private readonly crudService: CrudService, // from crud.service.ts private readonly apiEndpointAuthJwt: ApiEndpointAuthJwtService, private readonly confService: ConfService, private readonly logService: LogService, private readonly libraryAppService: LibraryAppService, ){ this.crudService.inject( dataSource, repository, confService, LogService, libraryAppService ); } async signUp(input: SignupInput | SignupInput[]): Promise { // how crudService will be used const out = await this.crudService.create(input); // set some jwt token related notice in respected field const aNotice = `Login to get JWT access token`; const rNotice = `Login to get JWT refresh token`; if(Array.isArray(out)) { for(let i = 0; i < out.length; i++){ out[i].jwt_access_token = aNotice; out[i].jwt_refresh_token = rNotice; } } else { out.jwt_access_token = aNotice; out.jwt_refresh_token = rNotice; } return out; } } /** * A method to filter keys from an object based on another object. * Returns a new object with only the keys present in the reference object. * * @param {T} input - The object to filter keys from. * @param {any} reference - The object to filter keys with. * @return {Promise>} A new object with only the keys present in the reference object. */ public static async filterInputAsReference(input: any, reference: T): Promise> { return Object.keys(input).reduce((acc, key) => { if (key in reference) { acc[key as keyof T] = input[key as keyof T]; } return acc; }, {} as Partial); }