export type ICursorData = { created_at: string id: string } // Encodes the cursor data to a base64 string export function encodeCursor({ id, created_at }: ICursorData): string | null { const jsonData = JSON.stringify({ id, created_at }) if (!id || !created_at) return null return Buffer.from(jsonData).toString('base64') } // Decodes the cursor data from a base64 string export function decodeCursor(cursor: string): ICursorData { const jsonData = Buffer.from(cursor, 'base64').toString('utf-8') console.log({ jsonData }) return JSON.parse(jsonData) }