Skip to content

Commit 0387454

Browse files
authored
Merge pull request #4 from mmkal/explicit-keys-test
Explicit keys test
2 parents ecb022f + 6e036fe commit 0387454

11 files changed

+6799
-12
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cache:
66
notifications:
77
email: true
88
node_js:
9-
- '7'
9+
- '8'
1010
- '6'
1111
before_script:
1212
- npm prune

.vscode/tasks.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"version": "0.1.0",
3-
"command": "tsc",
3+
"command": "npm",
44
"isShellCommand": true,
55
"showOutput": "always",
6-
"args": ["--sourceMap", "--watch", "--project"],
6+
"args": ["run"],
77
"tasks": [
88
{
9-
"taskName": ".",
9+
"taskName": "build",
1010
"problemMatcher": "$tsc-watch",
1111
"showOutput": "always",
12+
"args": ["--", "--sourceMap", "--watch"],
1213
"isBuildCommand": true,
1314
"isBackground": true
1415
},

README.md

+58-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,60 @@
11
# handy-redis
2-
A wrapper around node_redis with Promise and TypeScript support.
2+
A wrapper around [node_redis](https://npmjs.com/package/redis) with Promise and TypeScript support.
33

4-
[![Build Status](https://travis-ci.org/mmkal/hodor.svg?branch=master)](https://travis-ci.org/mmkal/handy-redis)
4+
[![Build Status](https://travis-ci.org/mmkal/handy-redis.svg?branch=master)](https://travis-ci.org/mmkal/handy-redis)
5+
6+
## Why
7+
8+
[node_redis](https://npmjs.com/package/redis) doesn't support Promises out-of-the-box - you have to use bluebird's `promisifyAll`, which has the side effect of removing all TypeScript/intellisense support from the package.
9+
10+
This package exclusively uses Promises, and the TypeScript types are generated from the official redis documentation and examples, so it's much easier to know what parameters a command expects.
11+
12+
## Using
13+
14+
```cli
15+
npm install --save handy-redis
16+
```
17+
18+
ES6/TypeScript:
19+
```JavaScript
20+
import { createHandyClient } from 'handy-redis';
21+
22+
(async function() {
23+
const client = createHandyClient();
24+
// or, call createHandyClient(opts) using opts for https://npmjs.com/package/redis
25+
// or, call createHandyClient(oldClient) where oldClient is an existing node_redis client.
26+
27+
await client.set('foo', 'bar');
28+
const foo = await client.get('foo');
29+
console.log(foo);
30+
})();
31+
```
32+
33+
Vanilla JS:
34+
```JavaScript
35+
const handyRedis = require('handy-redis');
36+
37+
const client = handyRedis.createHandyClient();
38+
39+
client
40+
.set('foo', 'bar')
41+
.then(() => client.get('foo'))
42+
.then(foo => console.log(foo));
43+
```
44+
45+
The package is published with TypeScript types, with the redis documentation and response type attached to each command:
46+
![](./docs/intellisense.png)
47+
48+
## Development
49+
50+
Most of the package is generated by running sample commands from the redis documentation repo.
51+
52+
```cli
53+
git clone https://github.com/mmkal/handy-redis --recursive
54+
npm install
55+
npm test
56+
```
57+
58+
`npm test` triggers `npm run build` before running the tests - and the `build` script generates the client before using TypeScript to compile it.
59+
60+
If you cloned without `--recursive` you'll need to run `git submodule update --init` to get the redis-doc repo locally.

docs/intellisense.png

52.9 KB
Loading

0 commit comments

Comments
 (0)