Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[*.{js,jsx,ts,tsx,json,md}]
indent_style = space
indent_size = 2

[*.{yml,yaml}]
indent_style = space
indent_size = 2
4 changes: 2 additions & 2 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
uses: hoverkraft-tech/compose-action@v2.0.2
with:
compose-file: './compose.yaml'
compose-flags: '--profile cluster'
up-flags: '-d'
down-flags: '-v'
- run: docker compose exec cluster-m1 redis-cli -a mycluster --cluster create 127.0.0.1:7380 127.0.0.1:7381 127.0.0.1:7382 --cluster-yes
- run: pnpm install --frozen-lockfile
- run: pnpm -F "@nestjs-labs/nestjs-redis" run lint
- run: pnpm -F "@nestjs-labs/nestjs-redis" run test
- run: pnpm -F "@nestjs-labs/nestjs-redis" run test:e2e
# - run: pnpm -F "@nestjs-labs/nestjs-redis" run test:e2e
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.DS_Store
.idea

# Logs
logs
*.log
Expand Down Expand Up @@ -127,4 +130,4 @@ dist
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.pnp.*
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ If you prefre [node-redis](https://github.com/redis/node-redis), check out [this

```sh
# with npm
npm install @nestjs-labs/nestjs-redis ioredis
npm install @nestjs-labs/nestjs-redis redis
# with yarn
yarn add @nestjs-labs/nestjs-redis ioredis
yarn add @nestjs-labs/nestjs-redis redis
# with pnpm
pnpm add @nestjs-labs/nestjs-redis ioredis
pnpm add @nestjs-labs/nestjs-redis redis
```

## Usage
Expand Down Expand Up @@ -239,6 +239,7 @@ Distributed under the MIT License. See `LICENSE` for more information.

## Acknowledgments

- [node-redis](https://github.com/redis/node-redis)
- [Full-Featured Redis Client - ioredis](https://github.com/luin/ioredis)
- [Official Redis Documentation](https://redis.io/)
- [Official Redis Docker Image](https://hub.docker.com/_/redis)
Expand Down
119 changes: 103 additions & 16 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,107 @@
# sudo docker compose exec cluster-m1 redis-cli -a mycluster --cluster create 127.0.0.1:7380 127.0.0.1:7381 127.0.0.1:7382 --cluster-yes
---
# image tag 8.0-RC2-pre is the one matching the 8.0 GA release
x-client-libs-stack-image: &client-libs-stack-image
image: 'redislabs/client-libs-test:${CLIENT_LIBS_TEST_STACK_IMAGE_TAG:-8.0.2}'

x-client-libs-image: &client-libs-image
image: 'redislabs/client-libs-test:${CLIENT_LIBS_TEST_IMAGE_TAG:-8.0.2}'

services:
redis:
image: redis/redis-stack-server:latest
network_mode: host
<<: *client-libs-image
container_name: redis-standalone
environment:
- TLS_ENABLED=yes
- REDIS_CLUSTER=no
- PORT=6379
- TLS_PORT=6666
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""}
ports:
- 6379:6379
- 6666:6666 # TLS port
volumes:
- './dockers/standalone:/redis/work'
profiles:
- standalone
- sentinel
- replica
- all-stack
- all

replica:
<<: *client-libs-image
container_name: redis-replica
depends_on:
- redis
environment:
- TLS_ENABLED=no
- REDIS_CLUSTER=no
- PORT=6380
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --replicaof redis 6379 --protected-mode no --save ""}
ports:
- 6380:6380
volumes:
- './dockers/replica:/redis/work'
profiles:
- replica
- all-stack
- all

cluster:
<<: *client-libs-image
container_name: redis-cluster
environment:
- REDIS_CLUSTER=yes
- NODES=6
- REPLICAS=1
- TLS_ENABLED=yes
- PORT=16379
- TLS_PORT=27379
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""}
ports:
- '16379-16384:16379-16384'
- '27379-27384:27379-27384'
volumes:
- './dockers/cluster:/redis/work'
profiles:
- cluster
- all-stack
- all

sentinel:
<<: *client-libs-image
container_name: redis-sentinel
depends_on:
- redis
environment:
- REDIS_CLUSTER=no
- NODES=3
- PORT=26379
command: ${REDIS_EXTRA_ARGS:---sentinel}
ports:
- 26379:26379
- 26380:26380
- 26381:26381
volumes:
- './dockers/sentinel.conf:/redis/config-default/redis.conf'
- './dockers/sentinel:/redis/work'
profiles:
- sentinel
- all-stack
- all

redis-stack:
<<: *client-libs-stack-image
container_name: redis-stack
environment:
- 'REDIS_ARGS=--port 6380 --requirepass myredis --appendonly yes'
cluster-m1:
image: redis:latest
network_mode: host
command: 'redis-server --port 7380 --requirepass mycluster --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000 --appendonly yes'
cluster-m2:
image: redis:latest
network_mode: host
command: 'redis-server --port 7381 --requirepass mycluster --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000 --appendonly yes'
cluster-m3:
image: redis:latest
network_mode: host
command: 'redis-server --port 7382 --requirepass mycluster --cluster-enabled yes --cluster-config-file nodes.conf --cluster-node-timeout 5000 --appendonly yes'
- REDIS_CLUSTER=no
- PORT=6379
command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --save ""}
ports:
- 6479:6379
volumes:
- './dockers/redis-stack:/redis/work'
profiles:
- standalone
- all-stack
- all
5 changes: 5 additions & 0 deletions dockers/sentinel.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sentinel resolve-hostnames yes
sentinel monitor redis-py-test redis 6379 2
sentinel down-after-milliseconds redis-py-test 5000
sentinel failover-timeout redis-py-test 60000
sentinel parallel-syncs redis-py-test 1
13 changes: 10 additions & 3 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export default tseslint.config(
ignores: ['packages/global.d.ts', '**/dist/', '**/*.mjs']
},
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
tseslint.configs.stylisticTypeChecked,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
files: jestFiles,
...jest.configs['flat/recommended'],
Expand All @@ -27,7 +27,14 @@ export default tseslint.config(
globals: globals.jest
}
},
eslintPluginPrettierRecommended,
{
...eslintPluginPrettierRecommended,
rules: {
'prettier/prettier': 'off',
'arrow-parens': ['error', 'always'],
'@typescript-eslint/no-base-to-string': 'off'
}
},
{
linterOptions: {
reportUnusedDisableDirectives: 'error'
Expand Down
4 changes: 4 additions & 0 deletions examples/nest-redis-example/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
99 changes: 99 additions & 0 deletions examples/nest-redis-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<p align="center">
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
</p>

[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
[circleci-url]: https://circleci.com/gh/nestjs/nest

<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
<p align="center">
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
</p>
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->

## Description

[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.

## Project setup

```bash
$ pnpm install
```

## Compile and run the project

```bash
# development
$ pnpm run start

# watch mode
$ pnpm run start:dev

# production mode
$ pnpm run start:prod
```

## Run tests

```bash
# unit tests
$ pnpm run test

# e2e tests
$ pnpm run test:e2e

# test coverage
$ pnpm run test:cov
```

## Deployment

When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.

If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:

```bash
$ pnpm install -g mau
$ mau deploy
```

With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.

## Resources

Check out a few resources that may come in handy when working with NestJS:

- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).

## Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).

## Stay in touch

- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
- Website - [https://nestjs.com](https://nestjs.com/)
- Twitter - [@nestframework](https://twitter.com/nestframework)

## License

Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
34 changes: 34 additions & 0 deletions examples/nest-redis-example/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// @ts-check
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{
ignores: ['eslint.config.mjs'],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.node,
...globals.jest,
},
sourceType: 'commonjs',
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
},
},
);
8 changes: 8 additions & 0 deletions examples/nest-redis-example/nest-cli.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
Loading
Loading