import { NextRequest, NextResponse } from 'next/server'; import { esClient, INDEX_NAME, initializeIndex } from '@/lib/elasticsearch'; import { generateHashes, detectHashType } from '@/lib/hash'; interface HashDocument { plaintext: string; md5: string; sha1: string; sha256: string; sha512: string; created_at?: string; } // Maximum allowed query length const MAX_QUERY_LENGTH = 1000; // Characters that could be used in NoSQL/Elasticsearch injection attacks const DANGEROUS_PATTERNS = [ /[{}\[\]]/g, // JSON structure characters /\$[a-zA-Z]/g, // MongoDB-style operators /\\u[0-9a-fA-F]{4}/g, // Unicode escapes /