1.0.2 • Published 5 months ago

@atcute/jetstream v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@atcute/jetstream

a simple Jetstream client

import { JetstreamSubscription } from '@atcute/jetstream';
import { is } from '@atcute/lexicons';

import { AppBskyFeedPost } from '@atcute/bluesky';

const subscription = new JetstreamSubscription({
	url: 'wss://jetstream2.us-east.bsky.network',
	wantedCollections: ['app.bsky.feed.post'],
});

for await (const event of subscription) {
	if (event.kind === 'commit') {
		const commit = event.commit;

		if (commit.collection !== 'app.bsky.feed.post') {
			continue;
		}

		if (commit.operation === 'create') {
			const record = commit.record;
			if (!is(AppBskyFeedPost.mainSchema, record)) {
				continue;
			}

			console.log(`${record.text}`);
		}
	}
}