import { NestFactory } from '@nestjs/core';
import { ConfigModule, ConfigService } from '@nestjs/config';
import configuration from '../src/config/configuration';
import { validate } from '../src/config/env.validation';
import { Module } from '@nestjs/common';

@Module({
  imports: [
    ConfigModule.forRoot({
      load: [configuration],
      validate,
    }),
  ],
})
class TestModule {}

async function test() {
  const app = await NestFactory.createApplicationContext(TestModule);
  const config = app.get(ConfigService);
  
  console.log('--- CONFIG RESOLUTION TEST ---');
  console.log('meta.accessToken:', config.get('meta.accessToken') ? 'FOUND' : 'MISSING');
  console.log('META_ACCESS_TOKEN:', config.get('META_ACCESS_TOKEN') ? 'FOUND' : 'MISSING');
  console.log('meta.appId:', config.get('meta.appId') ? 'FOUND' : 'MISSING');
  console.log('META_APP_ID:', config.get('META_APP_ID') ? 'FOUND' : 'MISSING');
  
  await app.close();
}

test().catch(err => {
  console.error('Test failed:', err);
  process.exit(1);
});
