Decorators
geo-ai-nest ships two custom decorators for fine-grained control over AI bot handling and metadata attachment.
@IsAIBot()
Parameter decorator that injects the detected AI bot name (or null) into a handler.
typescript
import { Controller, Get } from '@nestjs/common';
import { IsAIBot } from 'geo-ai-nest';
@Controller('pages')
export class PagesController {
@Get(':slug')
getPage(@IsAIBot() bot: string | null) {
if (bot) {
// Serve AI-optimized content for this bot
console.log(`Request from AI bot: ${bot}`);
}
return { title: 'My Page' };
}
}@GeoAIMeta()
Class/method decorator that attaches GEO metadata to a controller or handler via Reflect.metadata. Useful with custom guards or interceptors that read metadata. Retrieve it with Reflector using the GEO_AI_META_KEY constant ('geo-ai-meta').
typescript
import { Controller, Get } from '@nestjs/common';
import { GeoAIMeta } from 'geo-ai-nest';
@Controller('products')
@GeoAIMeta({ priority: 'high', includeContent: true })
export class ProductsController {
@Get(':id')
getProduct() { /* ... */ }
}