at://nekomimi.pet/li.plonk.paste/3lr6l7fhpws2f

Back to Collection

Record JSON

{
  "$type": "li.plonk.paste",
  "code": "import { AtpAgent } from \"@atproto/api\"\nimport type { Plonk } from \"../../types\"\n\nconst createAgent = (pds: string) =\u003e new AtpAgent({ service: pds });\nconst makeAuthenticatedRequest = async (endpoint: string, data: any) =\u003e {\n    const response = await fetch(endpoint, {\n        method: \"POST\",\n        credentials: \"include\",\n        headers: {\n            \"Content-Type\": \"application/json\"\n        },\n        body: JSON.stringify(data)\n    });\n\n    if (!response.ok) {\n        const errorData = await response.json();\n        throw new Error(errorData.error || `Failed to ${endpoint.split('/').pop()}`);\n    }\n\n    return response;\n};\n\n/* Unauthenticated Routes */\nexport const getProfile = async function(did: string, pds: string) {\n    const agent = createAgent(pds);\n\n    const { data } = await agent.com.atproto.repo.getRecord({\n        repo: did,\n        collection: \"app.bsky.actor.profile\",\n        rkey: 'self'\n    });\n\n    return data;\n}\n\nexport const getPlonks = async function(did: string, pds: string) {\n    const agent = createAgent(pds);\n\n    const { data } = await agent.com.atproto.repo.listRecords({\n        repo: did,\n        collection: \"li.plonk.paste\",\n    });\n\n    return data;\n}\n\nexport const getPlonk = async function(did: string, pds: string, rkey: string) {\n    const agent = createAgent(pds);\n\n    const { data } = await agent.com.atproto.repo.getRecord({\n        repo: did,\n        collection: \"li.plonk.paste\",\n        rkey: rkey,\n    });\n\n    return data;\n}\n\n/* Authenticated Routes, uses backend as proxy */\nexport const postPlonk = async function(did: string, pds: string, plonk: Plonk) {\n    return makeAuthenticatedRequest(\"/plonk/post\", { did, pds, ...plonk });\n}\n\nexport const deletePlonk = async function(rkey: string) {\n    return makeAuthenticatedRequest(\"/plonk/delete\", { rkey });\n}",
  "createdAt": "2025-06-09T14:21:12.112Z",
  "lang": "typescript",
  "shortUrl": "yhhzl4ge",
  "title": "Another Test Plonk"
}