Merge pull request #27918 from SimonSchick/feat/catbox-redis

feat(catbox-redis): add typings
This commit is contained in:
Ron Buckton
2018-08-08 13:39:36 -07:00
committed by GitHub
5 changed files with 99 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
import * as CatbotRedis from 'catbox-redis';
const cache = new CatbotRedis({
host: 'localhost',
partition: 'test',
port: 2018,
});
cache.get({
segment: 'test',
id: 'test',
});

60
types/catbox-redis/index.d.ts vendored Normal file
View File

@@ -0,0 +1,60 @@
// Type definitions for catbox-redis 4.1
// Project: https://github.com/hapijs/catbox-redis#readme
// Definitions by: Simon Schick <https://github.com/SimonSchick>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
// tslint:disable-next-line
declare module 'catbox-redis' {
import { Redis } from 'ioredis';
import { EnginePrototype, ClientOptions, Client } from 'catbox';
namespace CatboxRedis {
interface CatboxRedisOptions extends ClientOptions {
/**
* Raw client.
*/
client?: Redis;
/**
* the Redis server URL (if url is provided, host, port, and socket are ignored)
*/
url?: string;
/**
* the Redis server hostname.
* Defaults to '127.0.0.1'.
*/
host?: string;
/**
* the Redis server port or unix domain socket path.
* Defaults to 6379.
*/
port?: number;
/**
* the unix socket string to connect to (if socket is provided, host and port are ignored)
*/
socket?: string;
/**
* the Redis authentication password when required.
*/
password?: string;
/**
* the Redis database.
*/
database?: string;
/**
* an array of redis sentinel addresses to connect to.
*/
sentinels?: Array<{
host: string;
}>;
/**
* the name of the sentinel master.
* (Only needed when sentinels is specified)
*/
sentinelName?: string;
}
}
class CatboxRedis extends Client {
constructor(options: CatboxRedis.CatboxRedisOptions);
}
export = CatboxRedis;
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"catbox-redis-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -112,6 +112,9 @@ export interface CachedObject {
export type CacheItem = any;
export interface ClientOptions {
/**
* this will store items under keys that start with this value.
*/
partition: string;
}