File tree 6 files changed +20
-30
lines changed
6 files changed +20
-30
lines changed Original file line number Diff line number Diff line change @@ -19,8 +19,5 @@ NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
19
19
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL = /
20
20
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL = /
21
21
22
- # vercel kv
23
- KV_URL = " redis://default:876b3dd5d7404a7b86e94129d710787b@choice-lark-39044.kv.vercel-storage.com:39044"
24
- KV_REST_API_URL = " https://choice-lark-39044.kv.vercel-storage.com"
25
- KV_REST_API_TOKEN = " AZiEASQgOWM3YjZmMjgtN2IxNy00OGQwLWFjMGUtZDdmNzA0MDdiNzllODc2YjNkZDVkNzQwNGE3Yjg2ZTk0MTI5ZDcxMDc4N2I="
26
- KV_REST_API_READ_ONLY_TOKEN = " ApiEASQgOWM3YjZmMjgtN2IxNy00OGQwLWFjMGUtZDdmNzA0MDdiNzllIIQjhLMp8gB0yAMfPxP_S2Mgg9lrlahMtOg3XzQA5ys="
22
+ UPSTASH_URL = https://uncommon-bat-34546.upstash.io
23
+ UPSTASH_TOKEN = AYbyASQgZDg4Yjg1YzctMzljMS00MWUxLTgzYmQtYmRjYTcwMWU0Y2NiMjM4NTBiN2VkOTdkNDVhY2I1Mzc1NTIwYmI4NzBjZDA=
Original file line number Diff line number Diff line change @@ -15,8 +15,5 @@ NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
15
15
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/
16
16
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/
17
17
18
- # vercel kv
19
- KV_URL="redis://********@choice-lark-39044.kv.vercel-storage.com:39044"
20
- KV_REST_API_URL="********"
21
- KV_REST_API_TOKEN="********"
22
- KV_REST_API_READ_ONLY_TOKEN="********"
18
+ UPSTASH_URL=
19
+ UPSTASH_TOKEN=
Original file line number Diff line number Diff line change 48
48
"@tanstack/react-query-devtools" : " 4.29.15" ,
49
49
"@tanstack/react-query-persist-client" : " 4.29.15" ,
50
50
"@uidotdev/usehooks" : " 2.0.1" ,
51
+ "@upstash/redis" : " 1.21.0" ,
51
52
"@vercel/analytics" : " 1.0.1" ,
52
- "@vercel/kv" : " 0.2.1" ,
53
53
"axios" : " 1.4.0" ,
54
54
"clsx" : " 1.2.1" ,
55
55
"daisyui" : " 3.1.5" ,
110
110
"postcss-prune-var" : " 1.1.1" ,
111
111
"prettier" : " 2.8.8" ,
112
112
"rimraf" : " 5.0.1" ,
113
+ "simple-git-hooks" : " 2.8.1" ,
113
114
"tailwind-scrollbar" : " 3.0.4" ,
114
115
"tailwind-variants" : " 0.1.8" ,
115
116
"tailwindcss" : " ^3.3.2" ,
116
117
"tailwindcss-variable-colors" : " 0.0.1" ,
117
118
"tilg" : " 0.1.1" ,
118
- "simple-git-hooks" : " 2.8.1" ,
119
119
"typescript" : " 5.1.3" ,
120
120
"typewind" : " ^0.1.3" ,
121
121
"zx" : " 7.2.2"
Original file line number Diff line number Diff line change
1
+ import { Redis } from '@upstash/redis'
2
+
3
+ export const redis = new Redis ( {
4
+ url : process . env . UPSTASH_URL ! ,
5
+ token : process . env . UPSTASH_TOKEN ! ,
6
+ } )
Original file line number Diff line number Diff line change @@ -2,9 +2,8 @@ import dayjs from 'dayjs'
2
2
import { NextResponse } from 'next/server'
3
3
import type { NextRequest } from 'next/server'
4
4
5
- import { kv } from '@vercel/kv'
6
-
7
5
import countries from '~/data/countries.json'
6
+ import { redis } from '~/lib/redis.server'
8
7
9
8
import {
10
9
REQUEST_GEO ,
@@ -42,10 +41,10 @@ export default async function middleware(req: NextRequest) {
42
41
if ( countryInfo ) {
43
42
const flag = countryInfo . flag
44
43
requestHeaders . set ( REQUEST_GEO , `${ country } -${ city } -${ flag } ` )
45
- await kv . hset ( 'visitor_geo' , {
44
+ await redis . hset ( 'visitor_geo' , {
46
45
[ new Date ( ) . toISOString ( ) ] : `${ country } -${ city } -${ flag } ` ,
47
46
} )
48
- await kv . sadd ( `visitor_ip_${ dayjs ( ) . format ( 'MM-DD' ) } ` , ip )
47
+ await redis . sadd ( `visitor_ip_${ dayjs ( ) . format ( 'MM-DD' ) } ` , ip )
49
48
}
50
49
}
51
50
You can’t perform that action at this time.
0 commit comments