Skip to content

Instantly share code, notes, and snippets.

View Salakar's full-sized avatar
🎯
Darting around the place 24/7

Mike Diarmid Salakar

🎯
Darting around the place 24/7
View GitHub Profile
@Salakar
Salakar / bluesky.ts
Created November 20, 2024 01:22
Bluesky Sessions with Cloudflare KV
import { AtpAgent, AtpSessionData, RichText } from "@atproto/api";
import { AppContext } from "types";
class WorkerSessionManager {
constructor(private readonly ctx: AppContext) {}
async getSession(identifier: string): Promise<AtpSessionData | null> {
const sessionStr = await this.ctx.env.KVCACHE.get(`session:${identifier}`);
return sessionStr ? JSON.parse(sessionStr) : null;
}