@tomsd/redis-client 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,367 @@
1
+ // renaming standard-with-typescript -> eslint-config-love
2
+
3
+ const rules = {
4
+ '@typescript-eslint/adjacent-overload-signatures': ['error'],
5
+ '@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
6
+ '@typescript-eslint/await-thenable': ['error'],
7
+ '@typescript-eslint/ban-ts-comment': ['error', {
8
+ 'ts-expect-error': 'allow-with-description',
9
+ 'ts-ignore': true,
10
+ 'ts-nocheck': true,
11
+ 'ts-check': false,
12
+ minimumDescriptionLength: 3
13
+ }],
14
+ '@typescript-eslint/ban-tslint-comment': ['error'],
15
+ '@typescript-eslint/no-empty-object-type': 'error',
16
+ '@typescript-eslint/no-unsafe-function-type': 'error',
17
+ '@typescript-eslint/no-wrapper-object-types': 'error',
18
+ '@typescript-eslint/block-spacing': ['error', 'always'],
19
+ '@typescript-eslint/brace-style': ['error', '1tbs', { allowSingleLine: true }],
20
+ '@typescript-eslint/class-literal-property-style': ['error', 'fields'],
21
+ '@typescript-eslint/comma-dangle': ['error', {
22
+ arrays: 'never',
23
+ objects: 'never',
24
+ imports: 'never',
25
+ exports: 'never',
26
+ functions: 'never',
27
+ enums: 'ignore',
28
+ generics: 'ignore',
29
+ tuples: 'ignore'
30
+ }],
31
+ '@typescript-eslint/comma-spacing': ['error', { before: false, after: true }],
32
+ '@typescript-eslint/consistent-generic-constructors': ['error', 'constructor'],
33
+ '@typescript-eslint/consistent-indexed-object-style': ['error', 'record'],
34
+ '@typescript-eslint/consistent-type-assertions': [
35
+ 'error',
36
+ {
37
+ assertionStyle: 'as',
38
+ objectLiteralTypeAssertions: 'never'
39
+ }
40
+ ],
41
+ '@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
42
+ '@typescript-eslint/consistent-type-exports': ['error', {
43
+ fixMixedExportsWithInlineTypeSpecifier: true
44
+ }],
45
+ '@typescript-eslint/consistent-type-imports': ['error', {
46
+ prefer: 'type-imports',
47
+ disallowTypeAnnotations: true,
48
+ fixStyle: 'inline-type-imports'
49
+ }],
50
+ '@typescript-eslint/dot-notation': ['error',
51
+ {
52
+ allowIndexSignaturePropertyAccess: false,
53
+ allowKeywords: true,
54
+ allowPattern: '',
55
+ allowPrivateClassPropertyAccess: false,
56
+ allowProtectedClassPropertyAccess: false
57
+ }
58
+ ],
59
+ '@typescript-eslint/explicit-function-return-type': ['error', {
60
+ allowExpressions: true,
61
+ allowHigherOrderFunctions: true,
62
+ allowTypedFunctionExpressions: true,
63
+ allowDirectConstAssertionInArrowFunctions: true
64
+ }],
65
+ '@typescript-eslint/func-call-spacing': ['error', 'never'],
66
+ '@typescript-eslint/indent': ['error', 2, {
67
+ SwitchCase: 1,
68
+ VariableDeclarator: 1,
69
+ outerIIFEBody: 1,
70
+ MemberExpression: 1,
71
+ FunctionDeclaration: { parameters: 1, body: 1 },
72
+ FunctionExpression: { parameters: 1, body: 1 },
73
+ CallExpression: { arguments: 1 },
74
+ ArrayExpression: 1,
75
+ ObjectExpression: 1,
76
+ ImportDeclaration: 1,
77
+ flatTernaryExpressions: false,
78
+ ignoreComments: false,
79
+ ignoredNodes: [
80
+ 'TemplateLiteral *',
81
+ 'JSXElement',
82
+ 'JSXElement > *',
83
+ 'JSXAttribute',
84
+ 'JSXIdentifier',
85
+ 'JSXNamespacedName',
86
+ 'JSXMemberExpression',
87
+ 'JSXSpreadAttribute',
88
+ 'JSXExpressionContainer',
89
+ 'JSXOpeningElement',
90
+ 'JSXClosingElement',
91
+ 'JSXFragment',
92
+ 'JSXOpeningFragment',
93
+ 'JSXClosingFragment',
94
+ 'JSXText',
95
+ 'JSXEmptyExpression',
96
+ 'JSXSpreadChild'
97
+ ],
98
+ offsetTernaryExpressions: true
99
+ }],
100
+ '@typescript-eslint/key-spacing': ['error', { beforeColon: false, afterColon: true }],
101
+ '@typescript-eslint/keyword-spacing': ['error', { before: true, after: true }],
102
+ '@typescript-eslint/member-delimiter-style': [
103
+ 'error',
104
+ {
105
+ multiline: { delimiter: 'none' },
106
+ singleline: { delimiter: 'comma', requireLast: false }
107
+ }
108
+ ],
109
+ '@typescript-eslint/method-signature-style': ['error'],
110
+ '@typescript-eslint/naming-convention': ['error', {
111
+ selector: 'variableLike',
112
+ leadingUnderscore: 'allow',
113
+ trailingUnderscore: 'allow',
114
+ format: ['camelCase', 'PascalCase', 'UPPER_CASE']
115
+ }],
116
+ '@typescript-eslint/no-array-constructor': ['error'],
117
+ '@typescript-eslint/no-base-to-string': ['error'],
118
+ '@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: false, ignoreVoidOperator: false }],
119
+ '@typescript-eslint/no-dupe-class-members': ['error'],
120
+ '@typescript-eslint/no-dynamic-delete': ['error'],
121
+ '@typescript-eslint/no-empty-interface': ['error', { allowSingleExtends: true }],
122
+ '@typescript-eslint/no-extra-non-null-assertion': ['error'],
123
+ '@typescript-eslint/no-extra-parens': ['error', 'functions'],
124
+ '@typescript-eslint/no-extraneous-class': ['error', { allowWithDecorator: true }],
125
+ '@typescript-eslint/no-floating-promises': ['error'],
126
+ '@typescript-eslint/no-for-in-array': ['error'],
127
+ '@typescript-eslint/no-implied-eval': ['error'],
128
+ '@typescript-eslint/no-invalid-void-type': ['error'],
129
+ '@typescript-eslint/no-loss-of-precision': ['error'],
130
+ '@typescript-eslint/no-misused-new': ['error'],
131
+ '@typescript-eslint/no-misused-promises': ['error'],
132
+ '@typescript-eslint/no-namespace': ['error'],
133
+ '@typescript-eslint/no-non-null-asserted-optional-chain': ['error'],
134
+ '@typescript-eslint/no-non-null-assertion': ['error'],
135
+ '@typescript-eslint/no-redeclare': ['error', { builtinGlobals: false }],
136
+ '@typescript-eslint/no-this-alias': ['error', { allowDestructuring: true }],
137
+ '@typescript-eslint/only-throw-error': ['error'],
138
+ '@typescript-eslint/no-unnecessary-boolean-literal-compare': ['error'],
139
+ '@typescript-eslint/no-unnecessary-type-assertion': ['error'],
140
+ '@typescript-eslint/no-unnecessary-type-constraint': ['error'],
141
+ '@typescript-eslint/no-unsafe-argument': ['error'],
142
+ '@typescript-eslint/no-unused-expressions': ['error', {
143
+ allowShortCircuit: true,
144
+ allowTernary: true,
145
+ allowTaggedTemplates: true,
146
+ enforceForJSX: false
147
+ }],
148
+ '@typescript-eslint/no-unused-vars': ['error', {
149
+ args: 'none',
150
+ caughtErrors: 'none',
151
+ ignoreRestSiblings: true,
152
+ vars: 'all'
153
+ }],
154
+ '@typescript-eslint/no-use-before-define': ['error', {
155
+ functions: false,
156
+ classes: false,
157
+ enums: false,
158
+ variables: false,
159
+ typedefs: false
160
+ }],
161
+ '@typescript-eslint/no-useless-constructor': ['error'],
162
+ '@typescript-eslint/no-var-requires': ['error'],
163
+ '@typescript-eslint/non-nullable-type-assertion-style': ['error'],
164
+ '@typescript-eslint/object-curly-spacing': ['error', 'always'],
165
+ '@typescript-eslint/prefer-function-type': ['error'],
166
+ '@typescript-eslint/prefer-includes': ['error'],
167
+ '@typescript-eslint/prefer-nullish-coalescing': ['error', { ignoreConditionalTests: false, ignoreMixedLogicalExpressions: false }],
168
+ '@typescript-eslint/prefer-optional-chain': ['error'],
169
+ '@typescript-eslint/prefer-promise-reject-errors': ['error'],
170
+ '@typescript-eslint/prefer-readonly': ['error'],
171
+ '@typescript-eslint/prefer-reduce-type-parameter': ['error'],
172
+ '@typescript-eslint/prefer-return-this-type': ['error'],
173
+ '@typescript-eslint/prefer-ts-expect-error': ['error'],
174
+ '@typescript-eslint/promise-function-async': ['error'],
175
+ '@typescript-eslint/quotes': ['error', 'single', { avoidEscape: true, allowTemplateLiterals: false }],
176
+ '@typescript-eslint/require-array-sort-compare': ['error', { ignoreStringArrays: true }],
177
+ '@typescript-eslint/restrict-plus-operands': ['error', { skipCompoundAssignments: false }],
178
+ '@typescript-eslint/restrict-template-expressions': ['error', { allowNumber: true }],
179
+ '@typescript-eslint/return-await': ['error', 'always'],
180
+ '@typescript-eslint/semi': ['error', 'never'],
181
+ '@typescript-eslint/space-before-blocks': ['error', 'always'],
182
+ '@typescript-eslint/space-before-function-paren': ['error', 'always'],
183
+ '@typescript-eslint/space-infix-ops': ['error'],
184
+ '@typescript-eslint/strict-boolean-expressions': ['error', {
185
+ allowString: false,
186
+ allowNumber: false,
187
+ allowNullableObject: false,
188
+ allowNullableBoolean: false,
189
+ allowNullableString: false,
190
+ allowNullableNumber: false,
191
+ allowAny: false
192
+ }],
193
+ '@typescript-eslint/triple-slash-reference': ['error', { lib: 'never', path: 'never', types: 'never' }],
194
+ '@typescript-eslint/type-annotation-spacing': ['error'],
195
+ '@typescript-eslint/unbound-method': ['error', { ignoreStatic: false }],
196
+
197
+ 'accessor-pairs': ['error', { setWithoutGet: true, getWithoutSet: false, enforceForClassMembers: true }],
198
+ 'array-bracket-spacing': ['error', 'never'],
199
+ 'array-callback-return': ['error', {
200
+ allowImplicit: false,
201
+ allowVoid: false,
202
+ checkForEach: false
203
+ }],
204
+ 'arrow-spacing': ['error', { before: true, after: true }],
205
+ 'comma-style': ['error', 'last'],
206
+ 'computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }],
207
+ 'constructor-super': ['error'],
208
+ curly: ['error', 'multi-line'],
209
+ 'default-case-last': ['error'],
210
+ 'dot-location': ['error', 'property'],
211
+ 'eol-last': ['error'],
212
+ eqeqeq: ['error', 'always', { null: 'ignore' }],
213
+ 'generator-star-spacing': ['error', { before: true, after: true }],
214
+ 'multiline-ternary': ['error', 'always-multiline'],
215
+ 'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }],
216
+ 'new-parens': ['error'],
217
+ 'no-async-promise-executor': ['error'],
218
+ 'no-caller': ['error'],
219
+ 'no-case-declarations': ['error'],
220
+ 'no-class-assign': ['error'],
221
+ 'no-compare-neg-zero': ['error'],
222
+ 'no-cond-assign': ['error'],
223
+ 'no-const-assign': ['error'],
224
+ 'no-constant-condition': ['error', { checkLoops: false }],
225
+ 'no-control-regex': ['error'],
226
+ 'no-debugger': ['error'],
227
+ 'no-delete-var': ['error'],
228
+ 'no-dupe-args': ['error'],
229
+ 'no-dupe-keys': ['error'],
230
+ 'no-duplicate-case': ['error'],
231
+ 'no-useless-backreference': ['error'],
232
+ 'no-empty': ['error', { allowEmptyCatch: true }],
233
+ 'no-empty-character-class': ['error'],
234
+ 'no-empty-pattern': ['error'],
235
+ 'no-eval': ['error'],
236
+ 'no-ex-assign': ['error'],
237
+ 'no-extend-native': ['error'],
238
+ 'no-extra-bind': ['error'],
239
+ 'no-extra-boolean-cast': ['error'],
240
+ 'no-fallthrough': ['error'],
241
+ 'no-floating-decimal': ['error'],
242
+ 'no-func-assign': ['error'],
243
+ 'no-global-assign': ['error'],
244
+ 'no-import-assign': ['error'],
245
+ 'no-invalid-regexp': ['error'],
246
+ 'no-irregular-whitespace': ['error'],
247
+ 'no-iterator': ['error'],
248
+ 'no-labels': ['error', { allowLoop: false, allowSwitch: false }],
249
+ 'no-lone-blocks': ['error'],
250
+ 'no-misleading-character-class': ['error'],
251
+ 'no-prototype-builtins': ['error'],
252
+ 'no-useless-catch': ['error'],
253
+ 'no-mixed-operators': ['error', {
254
+ groups: [
255
+ ['==', '!=', '===', '!==', '>', '>=', '<', '<='],
256
+ ['&&', '||'],
257
+ ['in', 'instanceof']
258
+ ],
259
+ allowSamePrecedence: true
260
+ }],
261
+ 'no-mixed-spaces-and-tabs': ['error'],
262
+ 'no-multi-spaces': ['error'],
263
+ 'no-multi-str': ['error'],
264
+ 'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
265
+ 'no-new': ['error'],
266
+ 'no-new-func': ['error'],
267
+ 'no-new-object': ['error'],
268
+ 'no-new-symbol': ['error'],
269
+ 'no-new-wrappers': ['error'],
270
+ 'no-obj-calls': ['error'],
271
+ 'no-octal': ['error'],
272
+ 'no-octal-escape': ['error'],
273
+ 'no-proto': ['error'],
274
+ 'no-regex-spaces': ['error'],
275
+ 'no-return-assign': ['error', 'except-parens'],
276
+ 'no-self-assign': ['error', { props: true }],
277
+ 'no-self-compare': ['error'],
278
+ 'no-sequences': ['error'],
279
+ 'no-shadow-restricted-names': ['error'],
280
+ 'no-sparse-arrays': ['error'],
281
+ 'no-tabs': ['error'],
282
+ 'no-template-curly-in-string': ['error'],
283
+ 'no-this-before-super': ['error'],
284
+ 'no-trailing-spaces': ['error'],
285
+ 'no-undef-init': ['error'],
286
+ 'no-unexpected-multiline': ['error'],
287
+ 'no-unmodified-loop-condition': ['error'],
288
+ 'no-unneeded-ternary': ['error', { defaultAssignment: false }],
289
+ 'no-unreachable': ['error'],
290
+ 'no-unreachable-loop': ['error'],
291
+ 'no-unsafe-finally': ['error'],
292
+ 'no-unsafe-negation': ['error'],
293
+ 'no-useless-call': ['error'],
294
+ 'no-useless-computed-key': ['error'],
295
+ 'no-useless-escape': ['error'],
296
+ 'no-useless-rename': ['error'],
297
+ 'no-useless-return': ['error'],
298
+ 'no-var': ['warn'],
299
+ 'no-void': ['error', { allowAsStatement: true }],
300
+ 'no-whitespace-before-property': ['error'],
301
+ 'no-with': ['error'],
302
+ 'object-curly-newline': ['error', { multiline: true, consistent: true }],
303
+ 'object-property-newline': ['error', { allowMultiplePropertiesPerLine: true, allowAllPropertiesOnSameLine: false }],
304
+ 'object-shorthand': ['warn', 'properties'],
305
+ 'one-var': ['error', { initialized: 'never' }],
306
+ 'operator-linebreak': ['error', 'after', { overrides: { '?': 'before', ':': 'before', '|>': 'before' } }],
307
+ 'padded-blocks': ['error', { blocks: 'never', switches: 'never', classes: 'never' }],
308
+ 'prefer-const': ['error', { destructuring: 'all', ignoreReadBeforeAssign: false }],
309
+ 'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }],
310
+ 'quote-props': ['error', 'as-needed'],
311
+ 'rest-spread-spacing': ['error', 'never'],
312
+ 'semi-spacing': ['error', { before: false, after: true }],
313
+ 'space-in-parens': ['error', 'never'],
314
+ 'space-unary-ops': ['error', { words: true, nonwords: false }],
315
+ 'spaced-comment': ['error', 'always', {
316
+ line: { markers: ['*package', '!', '/', ',', '='] },
317
+ block: { balanced: true, markers: ['*package', '!', ',', ':', '::', 'flow-include'], exceptions: ['*'] }
318
+ }],
319
+ 'symbol-description': ['error'],
320
+ 'template-curly-spacing': ['error', 'never'],
321
+ 'template-tag-spacing': ['error', 'never'],
322
+ 'unicode-bom': ['error', 'never'],
323
+ 'use-isnan': ['error', {
324
+ enforceForSwitchCase: true,
325
+ enforceForIndexOf: true
326
+ }],
327
+ 'valid-typeof': ['error', { requireStringLiterals: true }],
328
+ 'wrap-iife': ['error', 'any', { functionPrototypeMethods: true }],
329
+ 'yield-star-spacing': ['error', 'both'],
330
+ yoda: ['error', 'never'],
331
+
332
+ 'import/export': ['error'],
333
+ 'import/first': ['error'],
334
+ 'import/no-absolute-path': ['error', { esmodule: true, commonjs: true, amd: false }],
335
+ 'import/no-duplicates': ['error'],
336
+ 'import/no-named-default': ['error'],
337
+ 'import/no-webpack-loader-syntax': ['error'],
338
+
339
+ 'n/handle-callback-err': ['error', '^(err|error)$'],
340
+ 'n/no-callback-literal': ['error'],
341
+ 'n/no-deprecated-api': ['error'],
342
+ 'n/no-exports-assign': ['error'],
343
+ 'n/no-new-require': ['error'],
344
+ 'n/no-path-concat': ['error'],
345
+ 'n/process-exit-as-throw': ['error'],
346
+
347
+ 'promise/param-names': ['error']
348
+ }
349
+
350
+ const config = {
351
+ plugins: [
352
+ '@typescript-eslint',
353
+ 'import',
354
+ 'n',
355
+ 'promise'
356
+ ],
357
+ parser: '@typescript-eslint/parser',
358
+ parserOptions: {
359
+ project: true
360
+ },
361
+ rules: {
362
+ ...rules
363
+ }
364
+
365
+ }
366
+
367
+ module.exports = config;
package/.eslintrc.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "env": {
3
+ "es2021": true,
4
+ "node": true
5
+ },
6
+ "extends": [
7
+ "./.eslintrc-love-temp.cjs",
8
+ "prettier"
9
+ ],
10
+ "overrides": [],
11
+ "parserOptions": {
12
+ "ecmaVersion": "latest",
13
+ "sourceType": "module",
14
+ "project": "tsconfig.json"
15
+ },
16
+ "rules": {}
17
+ }
package/README.md CHANGED
@@ -3,6 +3,19 @@
3
3
  It's a wrapper of [ioredis](https://www.npmjs.com/package/ioredis).
4
4
  See [redis-client.netlify.app](https://redis-client.netlify.app/) also.
5
5
 
6
+ ![npm](https://img.shields.io/npm/v/@tomsd/redis-client?style=for-the-badge&logo=npm)
7
+ ![NPM](https://img.shields.io/npm/l/@tomsd/redis-client?style=for-the-badge&logo=npm)
8
+ ![release date](https://img.shields.io/github/release-date/tomsdoo/redis-client?style=for-the-badge&logo=npm)
9
+ ![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/@tomsd/redis-client?style=for-the-badge&logo=npm)
10
+
11
+ ![ci](https://img.shields.io/github/actions/workflow/status/tomsdoo/redis-client/ci.yml?style=social&logo=github)
12
+ ![checks](https://img.shields.io/github/check-runs/tomsdoo/redis-client/main?style=social&logo=github)
13
+ ![top language](https://img.shields.io/github/languages/top/tomsdoo/redis-client?style=social&logo=typescript)
14
+ ![Maintenance](https://img.shields.io/maintenance/yes/2024?style=social&logo=github)
15
+ ![depends on ioredis@5](https://img.shields.io/badge/ioredis-ioredis@5-informational?style=social&logo=redis)
16
+ ![depends on node greater or equal 18](https://img.shields.io/badge/node.js-%3E%3D%2018-lightyellow?style=social&logo=nodedotjs)
17
+
18
+
6
19
  ## Installation
7
20
 
8
21
  ``` shell
package/dist/cjs/index.js CHANGED
@@ -48,7 +48,7 @@ class Redis {
48
48
  [this.keyProp]: (0, uuid_1.v4)(),
49
49
  ...value,
50
50
  };
51
- // @ts-expect-error
51
+ // @ts-expect-error prop name
52
52
  const key = savingObj[this.keyProp];
53
53
  return this.expireSeconds !== undefined
54
54
  ? await redis
@@ -1,4 +1,4 @@
1
- import IORedis, { RedisOptions } from "ioredis";
1
+ import IORedis, { type RedisOptions } from "ioredis";
2
2
  interface EasyRedisConfig {
3
3
  keyProp?: string;
4
4
  expireSeconds?: number;
package/dist/esm/index.js CHANGED
@@ -27,8 +27,8 @@ export class Redis {
27
27
  return this.redis;
28
28
  }
29
29
  getKeys() {
30
- var _a, _b, _c;
31
30
  return __awaiter(this, void 0, void 0, function* () {
31
+ var _a, _b, _c;
32
32
  const keyFilter = `${(_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.keyPrefix) !== null && _c !== void 0 ? _c : ""}*`;
33
33
  const sliceKey = (s) => { var _a, _b, _c, _d; return s.slice((_d = (_c = (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.keyPrefix) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0); };
34
34
  return yield this.getRedis()
@@ -53,7 +53,7 @@ export class Redis {
53
53
  const redis = this.getRedis();
54
54
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
55
55
  const savingObj = Object.assign({ [this.keyProp]: uuid() }, value);
56
- // @ts-expect-error
56
+ // @ts-expect-error prop name
57
57
  const key = savingObj[this.keyProp];
58
58
  return this.expireSeconds !== undefined
59
59
  ? yield redis
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tomsd/redis-client",
3
- "version": "1.0.1",
4
- "description": "It's a wrapper of uiredis.",
3
+ "version": "1.0.2",
4
+ "description": "It's a wrapper of ioredis.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/esm/index.d.ts",
@@ -13,11 +13,9 @@
13
13
  "lint": "npm run lint:src && npm run lint:test",
14
14
  "lint:src": "eslint src/**/*.ts",
15
15
  "lint:test": "eslint __test__/**/*.ts",
16
- "prepare": "husky install",
17
- "start-redis": "npm run build-redis && npm run serve-redis",
18
- "build-redis": "docker image build -f Dockerfile -t redis-alpine-image:v1.0.0 .",
19
- "serve-redis": "docker run --name redis-alpine-instance -p 6379:6379 --rm -d redis-alpine-image:v1.0.0",
20
- "stop-redis": "docker container stop redis-alpine-instance",
16
+ "prepare": "husky",
17
+ "start-redis": "docker run --rm -d -p 6379:6379 --name redis-instance redis:alpine",
18
+ "stop-redis": "docker container stop redis-instance",
21
19
  "serve:doc": "mdbook --serve --directory docs",
22
20
  "test": "jest"
23
21
  },
@@ -45,28 +43,27 @@
45
43
  },
46
44
  "homepage": "https://github.com/tomsdoo/redis-client#readme",
47
45
  "devDependencies": {
48
- "@babel/core": "^7.20.12",
49
- "@babel/preset-env": "^7.20.2",
50
- "@babel/preset-typescript": "^7.18.6",
51
- "@tomsd/md-book": "^1.0.2",
52
- "@types/uuid": "^9.0.0",
53
- "@typescript-eslint/eslint-plugin": "^5.48.0",
54
- "babel-jest": "^29.3.1",
55
- "eslint": "^8.31.0",
56
- "eslint-config-prettier": "^8.6.0",
57
- "eslint-config-standard-with-typescript": "^26.0.0",
58
- "eslint-plugin-import": "^2.26.0",
59
- "eslint-plugin-n": "^15.6.0",
60
- "eslint-plugin-promise": "^6.1.1",
61
- "husky": "^8.0.3",
62
- "jest": "^29.3.1",
63
- "lint-staged": "^13.1.0",
64
- "prettier": "^2.8.2",
65
- "ts-node": "^10.9.1",
66
- "typescript": "^4.9.4"
46
+ "@babel/core": "7.26.0",
47
+ "@babel/preset-env": "7.26.0",
48
+ "@babel/preset-typescript": "7.26.0",
49
+ "@tomsd/md-book": "1.3.3",
50
+ "@types/uuid": "10.0.0",
51
+ "@typescript-eslint/eslint-plugin": "8.16.0",
52
+ "babel-jest": "29.7.0",
53
+ "eslint": "8.57.1",
54
+ "eslint-config-prettier": "9.1.0",
55
+ "eslint-plugin-import": "2.31.0",
56
+ "eslint-plugin-n": "17.14.0",
57
+ "eslint-plugin-promise": "7.2.1",
58
+ "husky": "9.1.7",
59
+ "jest": "29.7.0",
60
+ "lint-staged": "15.2.10",
61
+ "prettier": "3.4.1",
62
+ "ts-node": "10.9.2",
63
+ "typescript": "5.7.2"
67
64
  },
68
65
  "dependencies": {
69
- "ioredis": "^5.2.4",
70
- "uuid": "^9.0.0"
66
+ "ioredis": "5.4.1",
67
+ "uuid": "11.0.3"
71
68
  }
72
69
  }
@@ -0,0 +1,13 @@
1
+ import { clients } from "./common";
2
+
3
+ (async () => {
4
+ console.log(
5
+ await clients.articleRedis.set({
6
+ title: "john's article",
7
+ body: "body",
8
+ author: "john@test.test",
9
+ })
10
+ );
11
+ })()
12
+ .then(() => process.exit())
13
+ .catch(() => process.exit());
@@ -0,0 +1,12 @@
1
+ import { clients } from "./common";
2
+
3
+ (async () => {
4
+ console.log(
5
+ await clients.userRedis.set({
6
+ name: "john",
7
+ email: "john@test.test",
8
+ })
9
+ )
10
+ })()
11
+ .then(() => process.exit())
12
+ .catch(() => process.exit());
@@ -0,0 +1,31 @@
1
+ import { Redis } from "../src/";
2
+
3
+ interface User {
4
+ email: string;
5
+ name: string;
6
+ }
7
+
8
+ interface Article {
9
+ _id: string;
10
+ author: string;
11
+ title: string;
12
+ body: string;
13
+ }
14
+
15
+ export const clients = {
16
+ userRedis: new Redis<User>({
17
+ keyProp: "email",
18
+ options: {
19
+ port: 6379,
20
+ host: "localhost",
21
+ keyPrefix: "user",
22
+ },
23
+ }),
24
+ articleRedis: new Redis<Article>({
25
+ options: {
26
+ port: 6379,
27
+ host: "localhost",
28
+ keyPrefix: "article",
29
+ },
30
+ }),
31
+ };
@@ -0,0 +1,20 @@
1
+ import { clients } from "./common";
2
+
3
+ (async () => {
4
+ const beforeKeys = await clients.articleRedis.getKeys();
5
+
6
+ const [ key, ...rest ] = beforeKeys;
7
+
8
+ console.log(
9
+ await clients.articleRedis.del(key)
10
+ );
11
+
12
+ const afterKeys = await clients.articleRedis.getKeys();
13
+ console.log({
14
+ beforeKeyCount: beforeKeys.length,
15
+ afterKeyCount: afterKeys.length,
16
+ });
17
+
18
+ })()
19
+ .then(() => process.exit())
20
+ .catch(() => process.exit());
@@ -0,0 +1,19 @@
1
+ import { clients } from "./common";
2
+
3
+ (async () => {
4
+ const beforeKeys = await clients.userRedis.getKeys();
5
+
6
+ const [ key, ...rest ] = beforeKeys;
7
+
8
+ console.log(
9
+ await clients.userRedis.del(key)
10
+ );
11
+
12
+ const afterKeys = await clients.userRedis.getKeys();
13
+ console.log({
14
+ beforeKeyCount: beforeKeys.length,
15
+ afterKeyCount: afterKeys.length,
16
+ });
17
+ })()
18
+ .then(() => process.exit())
19
+ .catch(() => process.exit());
@@ -0,0 +1,13 @@
1
+ import { clients } from "./common";
2
+
3
+ (async () => {
4
+ const keys = await clients.articleRedis.getKeys();
5
+
6
+ for(const key of keys) {
7
+ console.log(
8
+ await clients.articleRedis.get(key)
9
+ );
10
+ }
11
+ })()
12
+ .then(() => process.exit())
13
+ .catch(() => process.exit());
@@ -0,0 +1,14 @@
1
+ import { clients } from "./common";
2
+
3
+ (async () => {
4
+ const keys = await clients.userRedis.getKeys();
5
+
6
+ for(const key of keys) {
7
+ console.log(
8
+ await clients.userRedis.get(key)
9
+ );
10
+ }
11
+ })()
12
+ .then(() => process.exit())
13
+ .catch(() => process.exit());
14
+
package/tryit/seed.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { clients } from "./common";
2
+
3
+ const users = [
4
+ "alice",
5
+ "bob",
6
+ "charlie",
7
+ ]
8
+ .map(name => ({
9
+ name,
10
+ email: `${name}@test.test`,
11
+ }));
12
+
13
+ const articles = users.map(user => ({
14
+ title: `${user.name}'s article`,
15
+ body: "some body",
16
+ author: user.email,
17
+ }));
18
+
19
+ (async () => {
20
+ for(const user of users){
21
+ await clients.userRedis.set(user);
22
+ }
23
+
24
+ for(const article of articles){
25
+ await clients.articleRedis.set(article);
26
+ }
27
+
28
+ })()
29
+ .then(() => {
30
+ process.exit();
31
+ })
32
+ .catch((e) => {
33
+ console.log(e);
34
+ process.exit();
35
+ });