Skip to content

Commit

Permalink
feat: adding redis APL (#374)
Browse files Browse the repository at this point in the history
* feat: first commit with redis

* feat: changeset added

* fix: redis version more broad and return package manager

* fix: using external redis client and adding some docs

* fix: testfile

* fix: removing not needed mock client functions

* fix: set the redis state on mocked client connect and disconnect

* fix:: making the docs more clear. Connect not needed manually.

* fix: no longer use the process.env for the cache key

* fix: ading redis to dev dependencies

* feat: real client test

* fix: using only redis sub methods actually needed

* fix: integrate redis in tsup build pipeline

* feat: adding integration test for redis

* docs: adding docs on integration test

* fix: type checking is failing so we need to use the src
  • Loading branch information
JannikZed authored Jan 20, 2025
1 parent 7a22607 commit 7b51201
Show file tree
Hide file tree
Showing 9 changed files with 683 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-otters-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@saleor/app-sdk": minor
---

Adding REDIS as APL provider
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,32 @@ the command:
```bash
pnpm lint
```

### Running Integration Tests

To run the integration tests (e.g., Redis APL tests), follow these steps:

1. Start a Redis container:

```bash
docker run --name saleor-app-sdk-redis -p 6379:6379 -d redis:7-alpine
```

2. Run the integration tests:

```bash
pnpm test:integration
```

3. (Optional) Clean up the Redis container:

```bash
docker stop saleor-app-sdk-redis
docker rm saleor-app-sdk-redis
```

Note: If your Redis instance is running on a different host or port, you can set the `REDIS_URL` environment variable:

```bash
REDIS_URL=redis://custom-host:6379 pnpm test:integration
```
15 changes: 13 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"copy-readme": "cp README.md dist/README.md",
"publish:ci-prod": "pnpm publish && pnpm exec changeset tag && git push --follow-tags",
"publish:ci-dev": "pnpm exec changeset version --snapshot pr && pnpm publish --tag dev --no-git-checks",
"lint-staged": "lint-staged"
"lint-staged": "lint-staged",
"test:integration": "INTEGRATION=1 vitest run test/integration"
},
"keywords": [],
"author": "",
Expand All @@ -25,7 +26,8 @@
"graphql": ">=16.6.0",
"next": ">=12",
"react": ">=17",
"react-dom": ">=17"
"react-dom": ">=17",
"redis": ">=4"
},
"dependencies": {
"@opentelemetry/api": "^1.7.0",
Expand Down Expand Up @@ -70,6 +72,7 @@
"prettier": "2.7.1",
"react": "^18.2.0",
"react-dom": "18.2.0",
"redis": "^4.7.0",
"tsm": "^2.2.2",
"tsup": "^6.2.3",
"typescript": "4.9.5",
Expand All @@ -80,6 +83,9 @@
"peerDependenciesMeta": {
"@vercel/kv": {
"optional": true
},
"redis": {
"optional": true
}
},
"lint-staged": {
Expand All @@ -98,6 +104,11 @@
"import": "./APL/index.mjs",
"require": "./APL/index.js"
},
"./APL/redis": {
"types": "./APL/redis/index.d.ts",
"import": "./APL/redis/index.mjs",
"require": "./APL/redis/index.js"
},
"./APL/vercel-kv": {
"types": "./APL/vercel-kv/index.d.ts",
"import": "./APL/vercel-kv/index.mjs",
Expand Down
82 changes: 82 additions & 0 deletions pnpm-lock.yaml

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

3 changes: 3 additions & 0 deletions src/APL/redis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { RedisAPL } from "./redis-apl";

export { RedisAPL };
Loading

0 comments on commit 7b51201

Please sign in to comment.