import { Module as NestModule } from '@nestjs/common' ; import { ModuleMetadata } from '@nestjs/common/interfaces' ; import { apprc } from '../rc' ; import { getCallerPath , getInjectables , getEntities , getAppInjectables } from './utils' ; param opt export const Module = ( opt = { } ) : Function => { const path = getCallerPath ( ) ; const { files , exportProviders } = apprc . bootstrap ; const { orm } = apprc . packages ; const controllers = opt . controllers ? opt . controllers : getInjectables ( path , files . controllers ) ; const providers = opt . providers ? opt . providers : getInjectables ( path , files . providers ) ; const entities = getEntities ( path , files . entities , orm . name ) ; const imports = opt . imports ? opt . imports : [ ] ; const exports = opt . exports ? opt . exports : exportProviders ? providers : [ ] ; return NestModule ( { imports : entities ? [ entities , ... imports ] : imports , controllers , providers , exports , } ) ; } ; param opt export const AppRootModule = ( opt = { imports : [ ] } ) : Function => { const path = getCallerPath ( ) ; const { files , globalsPrefix } = apprc . bootstrap ; const injectables = [ ... files . providers , ... files . pipes , ... files . interceptors , ... files . guards , ... files . filters , ] . map ( ( name ) => `${ globalsPrefix }-${ name }` ) ; const imports = getInjectables ( path , files . modules ) ; const providers = getAppInjectables ( path , injectables ) ; return NestModule ( { imports : [ ... imports , ... opt . imports ] , providers } ) ; } ;