Module Setup
GeoAIModule is a dynamic NestJS module. Use forRoot for synchronous config and forRootAsync when config depends on environment variables or other services.
forRoot (synchronous)
typescript
import { Module } from '@nestjs/common';
import { GeoAIModule } from 'geo-ai-nest';
@Module({
imports: [
GeoAIModule.forRoot({
siteName: 'My Store',
siteUrl: 'https://mystore.com',
provider: {
Products: [
{ title: 'Widget', url: '/products/widget', description: 'A great widget' },
],
Blog: [
{ title: 'Hello World', url: '/blog/hello', description: 'First post' },
],
},
crawlers: 'all',
cache: '24h',
crawlTracking: true,
}),
],
})
export class AppModule {}forRootAsync (async)
Use forRootAsync when your config depends on environment variables or other services:
typescript
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { GeoAIModule } from 'geo-ai-nest';
@Module({
imports: [
ConfigModule.forRoot(),
GeoAIModule.forRootAsync({
imports: [ConfigModule],
useFactory: (config: ConfigService) => ({
siteName: config.get('SITE_NAME'),
siteUrl: config.get('SITE_URL'),
provider: new MyContentProvider(),
crawlers: 'all',
cache: config.get('GEO_CACHE_TTL', '24h'),
crawlTracking: true,
}),
inject: [ConfigService],
}),
],
})
export class AppModule {}forRootAsync also supports useClass and useExisting via the GeoAIOptionsFactory interface.