Skip to content

Cooperation-org/simple-store-prisma

Repository files navigation

@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-prisma

Prisma 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-stores

Usage

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)findUnique by key; returns undefined if missing
  • set(key, value)upsert (atomic insert-or-update)
  • del(key)deleteMany by 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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors