Skip to content

Commit

Permalink
Setup Redis
Browse files Browse the repository at this point in the history
With Upstash
  • Loading branch information
ruchernchong committed Aug 17, 2024
1 parent 1e0c02e commit a87d35c
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
CLOUDFLARE_API_TOKEN=
MONGODB_URI=
SG_CARS_TRENDS_API_TOKEN=

UPSTASH_REDIS_REST_URL=
UPSTASH_REDIS_REST_TOKEN=
2 changes: 2 additions & 0 deletions .github/workflows/sst.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
MONGODB_URI: ${{ secrets.MONGODB_URI }}
SG_CARS_TRENDS_API_TOKEN: ${{ secrets.SG_CARS_TRENDS_API_TOKEN }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/sst.staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
MONGODB_URI: ${{ secrets.MONGODB_URI }}
SG_CARS_TRENDS_API_TOKEN: ${{ secrets.SG_CARS_TRENDS_API_TOKEN }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@upstash/redis": "^1.34.0",
"axios": "^1.6.2",
"date-fns": "^2.30.0",
"hono": "^4.2.9",
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/config/redis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Redis } from "@upstash/redis";

const redis = new Redis({
url: process.env.UPSTASH_REDIS_REST_URL,
token: process.env.UPSTASH_REDIS_REST_TOKEN,
});

export default redis;
2 changes: 2 additions & 0 deletions sst.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export default $config({
environment: {
MONGODB_URI: process.env.MONGODB_URI,
SG_CARS_TRENDS_API_TOKEN: process.env.SG_CARS_TRENDS_API_TOKEN,
UPSTASH_REDIS_REST_TOKEN: process.env.UPSTASH_REDIS_REST_TOKEN,
UPSTASH_REDIS_REST_URL: process.env.UPSTASH_REDIS_REST_URL,
},
handler: "src/index.handler",
url: {
Expand Down

0 comments on commit a87d35c

Please sign in to comment.