import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { AppController } from './app.controller';
import { Neo4jModule } from './neo4j/neo4j.module';
import { AuthModule } from './auth/auth.module';
import { UserModule } from './user/user.module';
import { Neo4jConfig } from './neo4j/neo4j-cfg.interface';
import { AppService } from './app.service';
import { StdZhModule } from './std_zh/std_zh.module';

@Module({ 
  imports: [
    ConfigModule.forRoot({ isGlobal: true }),
    Neo4jModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (configService: ConfigService): Neo4jConfig => ({
        scheme: configService.get('NEO_SCHEME'),
        host: configService.get('NEO_HOST'),
        port: configService.get('NEO_PORT'),
        username: configService.get('NEO_USER'),
        password: configService.get('NEO_PASS'),
        database: configService.get('NEO_DB'),
      }),
    }),
    AuthModule,
    UserModule,
    StdZhModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
