Skip to content

Commit

Permalink
update vercel kv templates (#960)
Browse files Browse the repository at this point in the history
### Description

Replace `@vercel/kv` by `@upstash/redis` in the following templates:

- `storage/kv-redis-starter`
- `edge-functions/api-rate-limit`
- `storage/kv-redis-nuxt`
- `storage/kv-redis-sveltekit`
- `storage/kv-redis-waiting-room`



### Demo URL

<!--
Provide a URL to a live deployment where we can test your PR. If a demo
isn't possible feel free to omit this section.
-->

### Type of Change

- [ ] New Example
- [ ] Example updates (Bug fixes, new features, etc.)
- [ ] Other (changes to the codebase, but not to examples)

### New Example Checklist

- [ ] 🛫 `npm run new-example` was used to create the example
- [ ] 📚 The template wasn't used but I carefuly read the [Adding a new
example](https://github.com/vercel/examples#adding-a-new-example) steps
and implemented them in the example
- [ ] 📱 Is it responsive? Are mobile and tablets considered?
  • Loading branch information
correttojs authored Oct 22, 2024
1 parent 749fc7e commit d214c14
Show file tree
Hide file tree
Showing 16 changed files with 1,685 additions and 1,863 deletions.
2 changes: 1 addition & 1 deletion edge-functions/api-rate-limit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@upstash/ratelimit": "^0.4.3",
"@vercel/examples-ui": "^1.0.5",
"@vercel/kv": "^0.2.2",
"@upstash/redis": "^1.34.3",
"next": "canary",
"react": "latest",
"react-dom": "latest"
Expand Down
8 changes: 6 additions & 2 deletions edge-functions/api-rate-limit/pages/api/ping.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import type { NextRequest } from 'next/server'
import { Ratelimit } from '@upstash/ratelimit'
import { kv } from '@vercel/kv'
import { Redis } from '@upstash/redis'

const redis = new Redis({
url: process.env.KV_REST_API_URL,
token: process.env.KV_REST_API_TOKEN,
})
const ratelimit = new Ratelimit({
redis: kv,
redis,
// 5 requests from the same IP in 10 seconds
limiter: Ratelimit.slidingWindow(5, '10 s'),
})
Expand Down
Loading

0 comments on commit d214c14

Please sign in to comment.