mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-29 00:51:29 +08:00
fixed failing tests
This commit is contained in:
29
types/koa-redis-cache/index.d.ts
vendored
29
types/koa-redis-cache/index.d.ts
vendored
@@ -1,14 +1,15 @@
|
||||
// Type definitions for koa-redis-cache 3.0.1
|
||||
// Type definitions for koa-redis-cache 3.0
|
||||
// Project: https://github.com/coderhaoxin/koa-redis-cache
|
||||
// Definitions by: Dima Mukhin <https://github.com/dimamukhin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as Koa from "koa";
|
||||
import * as Redis from "redis";
|
||||
|
||||
type onErrorCallback = (error: Error) => void;
|
||||
|
||||
type getPrefixCallback = (ctx: Koa.Context) => String;
|
||||
type getPrefixCallback = (ctx: Koa.Context) => string;
|
||||
|
||||
declare namespace cache {
|
||||
interface CacheOptions {
|
||||
@@ -16,36 +17,36 @@ declare namespace cache {
|
||||
* redis key prefix, default is koa-redis-cache:
|
||||
* If a function is supplied, its signature should be function(ctx) {} and it should return a string to use as the redis key prefix
|
||||
*/
|
||||
prefix?: String | getPrefixCallback;
|
||||
prefix?: string | getPrefixCallback;
|
||||
|
||||
/**
|
||||
* redis expire time (second), default is 30 * 60 (30 min)
|
||||
*/
|
||||
expire?: Number;
|
||||
expire?: number;
|
||||
|
||||
/**
|
||||
* if the passParam exists in the query string, skip the cache
|
||||
*/
|
||||
passParam?: String;
|
||||
passParam?: string;
|
||||
|
||||
/**
|
||||
* max length of body size (in bytes) to cache.
|
||||
* if the size of the body exceeds maxLength, the body will not be cached.
|
||||
* default is: Infinity
|
||||
*/
|
||||
maxLength?: Number;
|
||||
maxLength?: number;
|
||||
|
||||
/**
|
||||
* the routes to cache, default is ['(.*)'].
|
||||
* can be set to an array of routes (String), or an array of RouteOptions
|
||||
* can be set to an array of routes (string), or an array of RouteOptions
|
||||
*/
|
||||
routes?: Array<RouteOptions> | Array<String>;
|
||||
routes?: RouteOptions[] | string[];
|
||||
|
||||
/**
|
||||
* the routes to exclude, default is [].
|
||||
* example: ['/api/(.*)', '/view/:id']
|
||||
*/
|
||||
exclude?: Array<String>;
|
||||
exclude?: string[];
|
||||
|
||||
/**
|
||||
* callback function for error, default is function() {}
|
||||
@@ -62,29 +63,29 @@ declare namespace cache {
|
||||
/**
|
||||
* the route to cache, example: '/api/(.*)'
|
||||
*/
|
||||
route: String;
|
||||
route: string;
|
||||
|
||||
/**
|
||||
* expiration time in seconds for cached responses for the route
|
||||
*/
|
||||
expire?: Number;
|
||||
expire?: number;
|
||||
}
|
||||
|
||||
interface RedisOptions {
|
||||
/**
|
||||
* host name of the redis server, default: 'localhost'
|
||||
*/
|
||||
host?: String,
|
||||
host?: string;
|
||||
|
||||
/**
|
||||
* port number of the redis server, default: 6379
|
||||
*/
|
||||
port?: Number,
|
||||
port?: number;
|
||||
|
||||
/**
|
||||
* node_redis options
|
||||
*/
|
||||
options?: Redis.ClientOpts
|
||||
options?: Redis.ClientOpts;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as cache from 'koa-redis-cache';
|
||||
|
||||
const app = new Koa();
|
||||
|
||||
const routeOptions: Array<cache.RouteOptions> = [
|
||||
const routeOptions: cache.RouteOptions[] = [
|
||||
{
|
||||
route: '/api/test',
|
||||
expire: 60
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
|
||||
Reference in New Issue
Block a user