Skip to content

Commit 6e036fe

Browse files
committed
docs: 'why' and 'development' sections
1 parent 5d5e0c3 commit 6e036fe

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

README.md

+43-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +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.
511

612
## Using
713

814
```cli
915
npm install --save handy-redis
1016
```
1117

18+
ES6/TypeScript:
1219
```JavaScript
13-
import { createClient } from 'handy-redis';
20+
import { createHandyClient } from 'handy-redis';
1421

1522
(async function() {
16-
const client = createClient(); // or call createClient(opts) using opts for https://npmjs.com/package/redis
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.
1726

1827
await client.set('foo', 'bar');
1928
const foo = await client.get('foo');
29+
console.log(foo);
2030
})();
2131
```
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)