2.4 KiB
2.4 KiB
Peer Paste Plugin
peer.paste provides temporary, replicated text snippets for the P2NS network.
Overview
- Store paste metadata/content in HyperDB.
- Share via link (
/p/:id) or API (/api/pastes/:id/raw). - Supports expiration, burn-after-read, and max-read limits.
- Includes a websocket-first lightweight web UI with infinite scroll.
- Supports
textandmarkdownformats with client preview. - Uses encryption by default with optional public mode and optional passphrase-derived mode.
- Supports bounded inline attachments metadata/payloads.
Routes
POST /api/pastescreate a new pasteGET /api/pasteslist active pastesGET /api/pastes/minelist active pastes owned by local peerGET /api/pastes/:idget paste metadataGET /api/pastes/:id/rawconsume/read paste contentGET /api/pastes/:id/attachmentslist attachment metadataGET /api/pastes/:id/attachments/:attachmentIdget attachment payloadPUT /api/pastes/:idupdate paste (owner only; authenticated)DELETE /api/pastes/:iddelete paste (owner only; authenticated)GET /api/statsget aggregate service statsGET /api/healthlightweight plugin/db health checkPOST /api/admin/cleanuprun cleanup immediately (authenticated)GET /api/docsinteractive API documentationGET /api/openapi.jsonOpenAPI 3 JSON specificationGET /p/:idhuman-readable paste page
HyperDB Schema
Collection: @peerpaste/pastes
Fields:
id(string, key)content(string)format(string:textormarkdown)language(string)ownerPeerId(string)isPublic(bool)encryptionMode(string)checksum(string)attachmentRefs(stringified JSON array)destroyOnRead(bool)maxReads(uint)readCount(uint)createdAt(uint)expiresAt(uint)
Index:
pastes-by-expiryonexpiresAt
Lifecycle
onInit()ensures DB readiness and starts hourly cleanup.- Cleanup removes expired/consumed pastes and flushes DB.
onShutdown()clears cleanup interval.
Notes
- Content currently replicates via HyperDB, so use reasonable paste size limits.
POSTandPUTvalidate content and enforce a max length.- Raw consumption increments read count and can auto-delete on read constraints.
- The
/api/docsendpoint provides copy/paste-ready endpoint summaries. - The
/api/openapi.jsonendpoint can be imported by API tooling. - Burn-after-first-read entries are hidden from recent active websocket list views.