Scratch space for learning atproto app development
1import type { Database } from "#/db"; 2import { Firehose } from "#/firehose/firehose"; 3 4export class Ingester { 5 firehose: Firehose | undefined; 6 constructor(public db: Database) {} 7 8 async start() { 9 const firehose = new Firehose({}); 10 11 for await (const evt of firehose.run()) { 12 if (evt.event === "create") { 13 if (evt.collection !== "app.bsky.feed.post") continue; 14 const post: any = evt.record; // @TODO fix types 15 await this.db 16 .insertInto("post") 17 .values({ 18 uri: evt.uri.toString(), 19 text: post.text as string, 20 indexedAt: new Date().toISOString(), 21 }) 22 .execute(); 23 } 24 } 25 } 26 27 destroy() { 28 this.firehose?.destroy(); 29 } 30}