Skip to content

Conversation

@chronark
Copy link

  • refactor(adapters): switch from abstract classes to interfaces
  • feat(adapters): add upstash-rest adapater

I've chosen to go without dependencies here, because the @upstash/redis client is not as low level as the existing interfaces require and aims to provide a better typescript dx compared to existing clients like ioredis.

Instead this simply uses fetch and provides a small wrapper to implement the existing interfaces without having to convert types back and forth.

Caveat: If you're on node<18, you need a fetch polyfill.

So far I tried it with one of the example in the readme. and it worked great but we need to update the tests as well in order to test against upstash instead of a local redis db.

import { Upstash, Redbase } from 'redbase'



interface User {
  id: number
  name: string
}
interface Post {
  content: string
  userId: number
}

const redis = new Upstash({ url, token })
const users = new Redbase<User>('myProject-user', { redis })
const posts = new Redbase<Post>('myProject-post', { redis })

@chronark chronark changed the title Adapter Upstash Adapter Mar 19, 2023
@alexanderatallah
Copy link
Owner

looks good from a first pass - is there a way to do tests using a mock upstash API, or one that wraps ioredis?

@alexanderatallah alexanderatallah self-assigned this Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants