{"_id":"@authok/nestjs-redis","_rev":"2-6d5bf7ccd208f9bde2ed029ab200dcb9","name":"@authok/nestjs-redis","dist-tags":{"latest":"1.3.4"},"versions":{"1.3.3":{"name":"@authok/nestjs-redis","version":"1.3.3","keywords":["nestjs","nest","redis","nestjs-redis"],"author":{"name":"skunight"},"license":"MIT","_id":"@authok/nestjs-redis@1.3.3","maintainers":[{"name":"newtalentxp","email":"newtalentxp@126.com"}],"homepage":"https://github.com/skunight/nestjs-redis#readme","bugs":{"url":"https://github.com/skunight/nestjs-redis/issues"},"dist":{"shasum":"c61080bdc1ac41098cd62bcb370c799f7d0fb305","tarball":"https://registry.npmjs.org/@authok/nestjs-redis/-/nestjs-redis-1.3.3.tgz","fileCount":22,"integrity":"sha512-blSoqVfiNogr9E9Se+mdY1pKLgi4dX+jkdA3acwbiPnU0LsVRboKghT/0bQiVqiA8RiUDHjoPYmAh+yWyARphw==","signatures":[{"sig":"MEUCIA/a8V3vOkp0/b1716iLGO+HVh0UhYnIFU64VBxpGt0xAiEA6p4RrFlyr9dDD24rRfM9FEfPlRKJCfkvpu6f07BoLcU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":24398,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh7iykCRA9TVsSAnZWagAAOOkP/A6gQfADUWWR3fwb/2fP\n5qOvdBY4fSQwrbDNOS0B419GVznfcnuDtgYpjAb4y4XvQVnUT96QjwOAB3dM\nMyVJ0Yji10u4RsoTEA2b/jjfAg+NR300D9Q13iM7+uJP6+8YqQK7yJTXn3kV\nArr5QiqIvSL5M7AkvYXnaX+JppjBbYra17Ycc9TI6Itly3zyYcR1JebWQNtD\n4w81WuwOZC/TwI+7qW5QBvdjKcJt1pa5Te1F308/V65Gnla9sh2pE6uliJaa\n8tPRxvBL4z1XmTpwAWDcxEmbTA2y19mdwwCEXdYwGWK/Iq4D3tsT9YcI9h6a\nWOroAzbW74d2YTrAmVTh9KExFfBLGF5X5+seaH8Hiia6hUtfTrglMemOCGm7\nMyv+8o1ZavU5XoLVhFMhkeOzLn+bKbnE+7hY+8iPW7Z4lLHVtJBSF9vQXvm6\n2NAH6SiBfRnEDXjacbsKHnt6PanVXN3AVLhgLZzMbidiQ+ypxfWde8csz8t+\ndSYE0VV5X8vWxmYmgeZobrS/LTQUfcUxi3EEG2wCiKcui9lv7IR+qHQ/DwWY\nxV8SNtC8EuX9+f3mA36WjcWwdj064h8LO3Dtw0+hrlEb4CnkNzvVW1S4IgYz\ns6BqrKEnEvCaWGzD+YCgMpyTutlqF7hDRliLiLZR6my4O8ey0XExEo03IMTx\nFAHV\r\n=uC5m\r\n-----END PGP SIGNATURE-----\r\n"},"types":"./index.d.ts","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"gitHead":"0b1f99ac8ec0c7f2ae64f8cd30b32b7ad324cfaf","scripts":{"lint":"eslint -c .eslintrc.js","test":"jest","build":"rimraf dist && tsc -p tsconfig.json","test:cov":"jest --coverage","test:e2e":"jest --config ./test/jest-e2e.json","precommit":"lint-staged","prepublish":"yarn run build","test:watch":"jest --watch","publish-public":"yarn publish --access public"},"_npmUser":{"name":"newtalentxp","email":"newtalentxp@126.com"},"repository":{"url":"git+https://github.com/skunight/nestjs-redis.git","type":"git"},"_npmVersion":"8.1.2","description":"a NestJS ioRedis module","directories":{},"_nodeVersion":"16.13.1","dependencies":{"rxjs":"^6","uuid":"^8","ioredis":"^4","@types/uuid":"*","@nestjs/core":"^7.4.4","@nestjs/common":"^7.4.4","@types/ioredis":"*","reflect-metadata":"*"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^26","eslint":"*","rimraf":"*","ts-jest":"^26","prettier":"^2","typescript":"^4","@types/node":"*","@nestjs/testing":"^7","eslint-plugin-jest":"^24","eslint-config-prettier":"^6","eslint-plugin-prettier":"^3","@typescript-eslint/parser":"^4","cz-conventional-changelog":"^3","@typescript-eslint/eslint-plugin":"^4"},"_npmOperationalInternal":{"tmp":"tmp/nestjs-redis_1.3.3_1642998948167_0.5995024278764911","host":"s3://npm-registry-packages"}},"1.3.4":{"name":"@authok/nestjs-redis","version":"1.3.4","description":"a NestJS ioRedis module","author":{"name":"skunight"},"license":"MIT","repository":{"type":"git","url":"https://github.com/authok/nestjs-redis.git"},"scripts":{"build":"rimraf dist && tsc -p tsconfig.json","precommit":"lint-staged","prepublish":"yarn run build","publish-public":"yarn publish --access public","test":"jest","test:watch":"jest --watch","test:cov":"jest --coverage","test:e2e":"jest --config ./test/jest-e2e.json","lint":"eslint -c .eslintrc.js"},"dependencies":{"@nestjs/common":"^10.2.6","@nestjs/core":"^10.2.6","@types/ioredis":"*","@types/uuid":"*","ioredis":"^5.4.1","reflect-metadata":"*","rxjs":"^6","uuid":"^8"},"devDependencies":{"@nestjs/testing":"^10.2.6","@types/node":"*","@typescript-eslint/eslint-plugin":"^4","@typescript-eslint/parser":"^4","cz-conventional-changelog":"^3","eslint":"*","eslint-config-prettier":"^6","eslint-plugin-jest":"^24","eslint-plugin-prettier":"^3","jest":"^29.7.0","prettier":"^2","rimraf":"*","ts-jest":"^29.2.4","typescript":"^5.5.4"},"keywords":["nestjs","nest","redis","nestjs-redis"],"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"licenseText":"MIT License\n\nCopyright (c) 2018 KnowYourself\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@authok/nestjs-redis@1.3.4","dist":{"shasum":"20044fdcb4661158055a3b4411549fe3189b04f1","integrity":"sha512-vzcgWUbDU+1hAQs+m+0M7i5RQOeGwuIh8li4MfQMi3gZs/sULwPQ7KJlL5t6vt+XFwrG/qT49kudCLVkhPJfHA==","tarball":"https://registry.npmjs.org/@authok/nestjs-redis/-/nestjs-redis-1.3.4.tgz","fileCount":24,"unpackedSize":24824,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAesPbmSXrRniGc90BWIKQViHuo6rfET+sHLDwXeL4OBAiAfOuHuo9ytz/51kKFRWSLjIi05ugEMVfFciXbMgahaHg=="}]},"_npmUser":{"name":"newtalentxp","email":"newtalentxp@126.com"},"directories":{},"maintainers":[{"name":"newtalentxp","email":"newtalentxp@126.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nestjs-redis_1.3.4_1723406298661_0.16930309631949836"},"_hasShrinkwrap":false}},"time":{"created":"2022-01-24T04:35:48.108Z","modified":"2024-08-11T19:58:19.077Z","1.3.3":"2022-01-24T04:35:48.328Z","1.3.4":"2024-08-11T19:58:18.790Z"},"author":{"name":"skunight"},"license":"MIT","keywords":["nestjs","nest","redis","nestjs-redis"],"repository":{"type":"git","url":"https://github.com/authok/nestjs-redis.git"},"description":"a NestJS ioRedis module","maintainers":[{"name":"newtalentxp","email":"newtalentxp@126.com"}],"readme":"\n# Nestjs Redis\n\nRedis component for NestJs.\n\n\n### Installation\n\n**Yarn**\n```bash\nyarn add nestjs-redis\n```\n\n**NPM**\n```bash\nnpm install nestjs-redis --save\n```\n\n### Getting Started\nLet's register the RedisModule in `app.module.ts`\n\n```typescript\nimport { Module } from '@nestjs/common'\nimport { RedisModule} from 'nestjs-redis'\n\n@Module({\n    imports: [\n        RedisModule.register(options)\n    ],\n})\nexport class AppModule {}\n```\nWith Async\n```typescript\nimport { Module } from '@nestjs/common';\nimport { RedisModule} from 'nestjs-redis'\n\n@Module({\n    imports: [\n        RedisModule.forRootAsync({\n            useFactory: (configService: ConfigService) => configService.get('redis'),         // or use async method\n            //useFactory: async (configService: ConfigService) => configService.get('redis'),\n            inject:[ConfigService]\n        }),\n    ],\n})\nexport class AppModule {}\n```\nAnd the config file look like this\nWith single client\n```typescript\nexport default {\n    host: process.env.REDIS_HOST,\n    port: parseInt(process.env.REDIS_PORT),\n    db: parseInt(process.env.REDIS_DB),\n    password: process.env.REDIS_PASSWORD,\n    keyPrefix: process.env.REDIS_PRIFIX,\n}\nOr\nexport default {\n    url: 'redis://:authpassword@127.0.0.1:6380/4',\n}\n```\nWith custom error handler\n```typescript\nexport default {\n    url: 'redis://:authpassword@127.0.0.1:6380/4',\n    onClientReady: (client) => {\n      client.on('error', (err) => {}\n    )},\n}\n```\nWith multi client\n```typescript\nexport default [\n    {\n        name:'test1',\n        url: 'redis://:authpassword@127.0.0.1:6380/4',\n    },\n    {\n        name:'test2',\n        host: process.env.REDIS_HOST,\n        port: parseInt(process.env.REDIS_PORT),\n        db: parseInt(process.env.REDIS_DB),\n        password: process.env.REDIS_PASSWORD,\n        keyPrefix: process.env.REDIS_PRIFIX,\n    },\n]\n```\nAnd use in your service\n```typescript\nimport { Injectable } from '@nestjs/common';\nimport { RedisService } from 'nestjs-redis';\n\n@Injectable()\nexport class TestService {\n  constructor(\n    private readonly redisService: RedisService,\n  ) { }\n  async root(): Promise<boolean> {\n    const client = await this.redisService.getClient('test')\n    return true\n  }\n}\n```\nOptions\n```typescript\ninterface RedisOptions {\n    /**\n     * client name. default is a uuid, unique.\n     */\n    name?: string;\n    url?: string;\n    port?: number;\n    host?: string;\n    /**\n     * 4 (IPv4) or 6 (IPv6), Defaults to 4.\n     */\n    family?: number;\n    /**\n     * Local domain socket path. If set the port, host and family will be ignored.\n     */\n    path?: string;\n    /**\n     * TCP KeepAlive on the socket with a X ms delay before start. Set to a non-number value to disable keepAlive.\n     */\n    keepAlive?: number;\n    connectionName?: string;\n    /**\n     * If set, client will send AUTH command with the value of this option when connected.\n     */\n    password?: string;\n    /**\n     * Database index to use.\n     */\n    db?: number;\n    /**\n     * When a connection is established to the Redis server, the server might still be loading\n     * the database from disk. While loading, the server not respond to any commands.\n     * To work around this, when this option is true, ioredis will check the status of the Redis server,\n     * and when the Redis server is able to process commands, a ready event will be emitted.\n     */\n    enableReadyCheck?: boolean;\n    keyPrefix?: string;\n    /**\n     * When the return value isn't a number, ioredis will stop trying to reconnect.\n     * Fixed in: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/15858\n     */\n    retryStrategy?(times: number): number | false;\n    /**\n     * By default, all pending commands will be flushed with an error every\n     * 20 retry attempts. That makes sure commands won't wait forever when\n     * the connection is down. You can change this behavior by setting\n     * `maxRetriesPerRequest`.\n     *\n     * Set maxRetriesPerRequest to `null` to disable this behavior, and\n     * every command will wait forever until the connection is alive again\n     * (which is the default behavior before ioredis v4).\n     */\n    maxRetriesPerRequest?: number | null;\n    /**\n     * 1/true means reconnect, 2 means reconnect and resend failed command. Returning false will ignore\n     * the error and do nothing.\n     */\n    reconnectOnError?(error: Error): boolean | 1 | 2;\n    /**\n     * By default, if there is no active connection to the Redis server, commands are added to a queue\n     * and are executed once the connection is \"ready\" (when enableReadyCheck is true, \"ready\" means\n     * the Redis server has loaded the database from disk, otherwise means the connection to the Redis\n     * server has been established). If this option is false, when execute the command when the connection\n     * isn't ready, an error will be returned.\n     */\n    enableOfflineQueue?: boolean;\n    /**\n     * The milliseconds before a timeout occurs during the initial connection to the Redis server.\n     * default: 10000.\n     */\n    connectTimeout?: number;\n    /**\n     * After reconnected, if the previous connection was in the subscriber mode, client will auto re-subscribe these channels.\n     * default: true.\n     */\n    autoResubscribe?: boolean;\n    /**\n     * If true, client will resend unfulfilled commands(e.g. block commands) in the previous connection when reconnected.\n     * default: true.\n     */\n    autoResendUnfulfilledCommands?: boolean;\n    lazyConnect?: boolean;\n    tls?: tls.ConnectionOptions;\n    sentinels?: Array<{ host: string; port: number; }>;\n    name?: string;\n    /**\n     * Enable READONLY mode for the connection. Only available for cluster mode.\n     * default: false.\n     */\n    readOnly?: boolean;\n    /**\n     * If you are using the hiredis parser, it's highly recommended to enable this option.\n     * Create another instance with dropBufferSupport disabled for other commands that you want to return binary instead of string\n     */\n    dropBufferSupport?: boolean;\n    /**\n     * Whether to show a friendly error stack. Will decrease the performance significantly.\n     */\n    showFriendlyErrorStack?: boolean;\n}\n```\nThat's it!\n","readmeFilename":"README.md"}