FileDumpThingutils.ts1 match
13* Simple and reliable approach to detect binary files
14*/
15export function isTextContent(buffer: Uint8Array): boolean {
16// Convert buffer to string and check for null bytes
17const str = new TextDecoder().decode(buffer);
FileDumpThingutils.ts1 match
6* @returns Promise resolving to complete buffer of stdin data
7*/
8export async function readStdinToBuffer(): Promise<Uint8Array> {
9try {
10const buf = new Uint8Array(1024);
FileDumpThingupload.ts2 matches
5const API_URL = `https://filedumpthing.val.run/api/upload`;
67async function main() {
8try {
9// Get filename from args or use a temporary name (will be replaced with appropriate extension)
71}
7273// Run the main function only once
74if (import.meta.main) {
75main();
FileDumpThingREADME.md1 match
5556- **Shared**: Code shared between frontend and backend
57- `utils.ts`: Shared types and utility functions
58- `mimetype.ts`: MIME type detection for various file formats
59
FileDumpThingmimetype.ts2 matches
2223// Helper to get mime type from filename
24export function getMimeType(fileName: string): string {
25const fileExtension = fileName.split('.').pop()?.toLowerCase() || '';
26return mimeTypes[fileExtension] || 'application/octet-stream';
2829// Get MIME type with special handling for video files
30export function getContentTypeHeaders(key: string): Record<string, string> {
31const fileExtension = key.split('.').pop()?.toLowerCase() || '';
32const mimeType = getMimeType(key);
FileDumpThingFileDumper.tsx1 match
5import { ContentState } from "../../shared/utils.ts";
67export function FileDumper() {
8const [content, setContent] = useState<ContentState>({ type: "text", value: "" });
9const [uploadedUrl, setUploadedUrl] = useState("");
FileDumpThingApp.tsx1 match
3import { FileDumper } from "./FileDumper.tsx";
45export function App() {
6return (
7<div>
xxxclearinghouse_validatorindex.ts18 matches
62};
6364// Main validation function
65export default async function validateUserRequest(requestData: any): Promise<ValidationResult> {
66try {
67// Input sanitization and basic validation
121122// Input sanitization
123function sanitizeInput(requestData: any): any {
124const sanitized = {
125query: '',
181182// Rate limiting check
183async function checkRateLimit(userId: string): Promise<ValidationResult> {
184try {
185const rateLimitKey = `rate_limit_${userId}`;
228229// Query validation
230function validateQuery(query: string): ValidationResult {
231// Check length
232if (query.length < CONFIG.MIN_QUERY_LENGTH) {
270271// Website validation
272function validateWebsites(websites: string[]): ValidationResult {
273if (websites.length === 0) {
274return {
302303// Discount validation
304function validateDiscount(minimumDiscount: number): ValidationResult {
305if (minimumDiscount < CONFIG.MIN_DISCOUNT || minimumDiscount > CONFIG.MAX_DISCOUNT) {
306return {
314315// Content appropriateness validation
316function validateContent(query: string): ValidationResult {
317// Add any additional content validation here
318// For adult products, we need to ensure appropriate terminology
338339// Request logging for monitoring
340async function logRequest(requestData: any): Promise<void> {
341try {
342const logEntry = {
364}
365366// Utility function to get validation statistics
367export async function getValidationStats(): Promise<any> {
368try {
369const logs: any[] = await blob.getJSON('recent_validation_logs') || [];
386}
387388// Helper function to get top queries
389function getTopQueries(logs: any[]): any[] {
390const queryCounts = logs.reduce((counts, log) => {
391counts[log.query] = (counts[log.query] || 0) + 1;
399}
400401// Helper function to get requests per hour
402function getRequestsPerHour(logs: any[]): number {
403if (logs.length === 0) return 0;
404
411}
412413// Cleanup function to remove old rate limit data
414export async function cleanupRateLimits(): Promise<void> {
415try {
416// This would typically be called by a scheduled job
417// For now, it's just a utility function
418console.log('Rate limit cleanup completed');
419} catch (error) {
xxxclearinghouse_urlscraperindex.ts9 matches
68};
6970// Advanced scraping function with error handling and rate limiting
71async function scrapeWebsite(query: string, websiteUrl: string): Promise<ScrapingResult> {
72const startTime = Date.now();
73const results: ScrapingResult = {
162}
163164// HTML parsing function using regex patterns (since DOMParser isn't available in server context)
165async function parseProductsFromHTML(html: string, siteConfig: any, baseUrl: string): Promise<any[]> {
166const products: any[] = [];
167
192193// Extract product data using regex patterns
194async function extractProductData(productHtml: string, siteConfig: any, baseUrl: string): Promise<any> {
195const product: any = {
196source: new URL(baseUrl).hostname,
250}
251252// Main export function
253export default async function urlScrapeTemplate(query: string, website: string): Promise<ScrapingResult> {
254try {
255// Input validation
297}
298299// Utility function for testing
300export async function testScrapeTemplate(): Promise<void> {
301const testSites = [
302'lovehoney.com.au',
46];
4748export default async function orchestrator(request: Request): Promise<Response> {
49// CORS handling
50if (request.method === 'OPTIONS') {
223224// Simplified request validation
225async function validateRequest(requestBody: any): Promise<ProcessedRequest> {
226try {
227// Default values
267}
268269// Simplified scraping function that calls our URL scrape template
270async function scrapeWebsite(query: string, website: string): Promise<any> {
271// This would normally import and call the actual URL scrape template
272// For now, we'll simulate the call with a simplified version
313314// Product consolidation and deduplication
315async function consolidateProducts(products: any[], minimumDiscount: number): Promise<any[]> {
316if (!products || products.length === 0) {
317return [];
356357// Generate a unique product ID
358function generateProductId(product: any): string {
359const source = product.source || 'unknown';
360const title = product.title || 'untitled';
365366// Calculate summary statistics
367function calculateSummary(results: ScrapingResult[], products: any[]): any {
368const successfulSites = results.filter(r => r.status === 'success').length;
369const totalProducts = products.length;
387388// Health check endpoint
389export async function healthCheck(): Promise<Response> {
390return new Response(JSON.stringify({
391status: 'healthy',