-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-farcaster.ts
More file actions
70 lines (58 loc) · 2.43 KB
/
Copy pathtest-farcaster.ts
File metadata and controls
70 lines (58 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/**
* Simple test script for FarcasterService functionality.
* Run with: npx ts-node test-farcaster.ts
*/
// Since we can't easily mock the full NestJS infrastructure,
// this test script demonstrates the expected usage patterns.
console.log('🚀 FarcasterService Test Script');
console.log('================================');
console.log('\n📝 Test Cases Covered:');
console.log('1. Username validation');
console.log('2. FID lookup via FName Registry API (FREE)');
console.log('3. Cast fetching via Warpcast API');
console.log('4. Incremental fetching');
console.log('5. Error handling');
console.log('6. Caching behavior');
console.log('\n🔍 Test Accounts:');
console.log('- dwr.eth (Dan Romero - Warpcast founder)');
console.log('- vitalik.eth (Vitalik Buterin)');
console.log('- jessepollak (Jesse Pollak - Base)');
console.log('\n📱 API Endpoints Used:');
console.log(
'- FName Registry: https://fnames.farcaster.xyz/transfers?name={username}',
);
console.log(
'- Warpcast: https://client.warpcast.com/v2/profile-casts?fid={fid}&limit={limit}',
);
console.log('\n⚡ Configuration:');
console.log('- Rate limiting: 2-3 second delays');
console.log('- FID cache TTL: 24 hours');
console.log('- Casts cache TTL: 1 hour');
console.log('- Batch size: 30 casts');
console.log('- Lookback period: 90 days');
console.log('- Max posts per project: 10');
console.log('- API Keys: None required - completely free!');
console.log('\n🧪 To run actual tests:');
console.log('1. Start the NestJS application: npm run start:dev');
console.log('2. Use the FarcasterService in a controller or service');
console.log('3. Test with real Farcaster usernames');
console.log('\n📋 Example Usage:');
console.log(`
// In a NestJS service or controller:
const casts = await this.farcasterService.getRecentCasts('dwr.eth');
console.log(\`Found \${casts.length} casts\`);
// Incremental fetching:
const timestamp = new Date('2024-01-01');
const newCasts = await this.farcasterService.getRecentCastsIncremental('vitalik.eth', timestamp);
// Validation:
const isValid = this.farcasterService.isValidFarcasterUsername('user.eth');
`);
console.log('\n✅ FarcasterService implementation complete!');
console.log(
' - Type definitions: src/modules/social-media/dto/farcaster-types.dto.ts',
);
console.log(
' - Service implementation: src/modules/social-media/services/farcaster.service.ts',
);
console.log(' - Environment config: .env.example (Farcaster section)');
export {};