@linked-claims/simple-store-prisma
v0.1.0
Published
Prisma-backed SimpleStore for ATProto OAuth (state + session persistence)
Readme
@linked-claims/simple-store-prisma
Prisma-backed SimpleStore for ATProto OAuth — drop-in persistent storage for NodeOAuthClient state and sessions.
Install
npm install @linked-claims/simple-store-prismaPrisma schema
Add two models (or rename to taste) with the shape { key: String @id, value: Json }:
model OauthState {
key String @id
value Json
}
model OauthSession {
key String @id
value Json
}Then run:
npx prisma migrate dev --name add-oauth-storesUsage
import { createPrismaSimpleStore } from '@linked-claims/simple-store-prisma'
import { NodeOAuthClient } from '@atproto/oauth-client-node'
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
const client = new NodeOAuthClient({
stateStore: createPrismaSimpleStore(prisma.oauthState),
sessionStore: createPrismaSimpleStore(prisma.oauthSession),
// ...other options
})API
createPrismaSimpleStore<V>(delegate)
Creates a SimpleStore<string, V> backed by a Prisma model delegate.
get(key)—findUniqueby key; returnsundefinedif missingset(key, value)—upsert(atomic insert-or-update)del(key)—deleteManyby key (no-op if missing)clear()—deleteMany()with no filter
PrismaJsonKvDelegate
Minimal interface matching any Prisma delegate for a { key, value } model. No dependency on @prisma/client — works with any Prisma version.
License
MIT
