Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
"@biomejs/biome": "^1.3.0",
"crypto-js": "^4.1.1"
}
}
}
155 changes: 155 additions & 0 deletions pkg/commands/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
export { type AppendCommand } from "./append";
export { type BitCountCommand } from "./bitcount";
export { type BitOpCommand } from "./bitop";
export { type BitPosCommand } from "./bitpos";
export { type CopyCommand } from "./copy";
export { type DBSizeCommand } from "./dbsize";
export { type DecrCommand } from "./decr";
export { type DecrByCommand } from "./decrby";
export { type DelCommand } from "./del";
export { type EchoCommand } from "./echo";
export { type EvalCommand } from "./eval";
export { type EvalshaCommand } from "./evalsha";
export { type ExistsCommand } from "./exists";
export { type ExpireCommand } from "./expire";
export { type ExpireAtCommand } from "./expireat";
export { type FlushAllCommand } from "./flushall";
export { type FlushDBCommand } from "./flushdb";
export { type GeoAddCommand, GeoAddCommandOptions, GeoMember } from "./geo_add";
export { type GeoDistCommand } from "./geo_dist";
export { type GeoHashCommand } from "./geo_hash";
export { type GeoPosCommand } from "./geo_pos";
export { type GeoSearchCommand } from "./geo_search";
export { type GeoSearchStoreCommand } from "./geo_search_store";
export { type GetCommand } from "./get";
export { type GetBitCommand } from "./getbit";
export { type GetDelCommand } from "./getdel";
export { type GetRangeCommand } from "./getrange";
export { type GetSetCommand } from "./getset";
export { type HDelCommand } from "./hdel";
export { type HExistsCommand } from "./hexists";
export { type HGetCommand } from "./hget";
export { type HGetAllCommand } from "./hgetall";
export { type HIncrByCommand } from "./hincrby";
export { type HIncrByFloatCommand } from "./hincrbyfloat";
export { type HKeysCommand } from "./hkeys";
export { type HLenCommand } from "./hlen";
export { type HMGetCommand } from "./hmget";
export { type HMSetCommand } from "./hmset";
export { type HRandFieldCommand } from "./hrandfield";
export { type HScanCommand } from "./hscan";
export { type HSetCommand } from "./hset";
export { type HSetNXCommand } from "./hsetnx";
export { type HStrLenCommand } from "./hstrlen";
export { type HValsCommand } from "./hvals";
export { type IncrCommand } from "./incr";
export { type IncrByCommand } from "./incrby";
export { type IncrByFloatCommand } from "./incrbyfloat";
export { type JsonArrAppendCommand } from "./json_arrappend";
export { type JsonArrIndexCommand } from "./json_arrindex";
export { type JsonArrInsertCommand } from "./json_arrinsert";
export { type JsonArrLenCommand } from "./json_arrlen";
export { type JsonArrPopCommand } from "./json_arrpop";
export { type JsonArrTrimCommand } from "./json_arrtrim";
export { type JsonClearCommand } from "./json_clear";
export { type JsonDelCommand } from "./json_del";
export { type JsonForgetCommand } from "./json_forget";
export { type JsonGetCommand } from "./json_get";
export { type JsonMGetCommand } from "./json_mget";
export { type JsonNumIncrByCommand } from "./json_numincrby";
export { type JsonNumMultByCommand } from "./json_nummultby";
export { type JsonObjKeysCommand } from "./json_objkeys";
export { type JsonObjLenCommand } from "./json_objlen";
export { type JsonRespCommand } from "./json_resp";
export { type JsonSetCommand } from "./json_set";
export { type JsonStrAppendCommand } from "./json_strappend";
export { type JsonStrLenCommand } from "./json_strlen";
export { type JsonToggleCommand } from "./json_toggle";
export { type JsonTypeCommand } from "./json_type";
export { type KeysCommand } from "./keys";
export { type LIndexCommand } from "./lindex";
export { type LInsertCommand } from "./linsert";
export { type LLenCommand } from "./llen";
export { type LMoveCommand } from "./lmove";
export { type LPopCommand } from "./lpop";
export { type LPushCommand } from "./lpush";
export { type LPushXCommand } from "./lpushx";
export { type LRangeCommand } from "./lrange";
export { type LRemCommand } from "./lrem";
export { type LSetCommand } from "./lset";
export { type LTrimCommand } from "./ltrim";
export { type MGetCommand } from "./mget";
export { type MSetCommand } from "./mset";
export { type MSetNXCommand } from "./msetnx";
export { type PersistCommand } from "./persist";
export { type PExpireCommand } from "./pexpire";
export { type PExpireAtCommand } from "./pexpireat";
export { type PingCommand } from "./ping";
export { type PSetEXCommand } from "./psetex";
export { type PTtlCommand } from "./pttl";
export { type PublishCommand } from "./publish";
export { type RandomKeyCommand } from "./randomkey";
export { type RenameCommand } from "./rename";
export { type RenameNXCommand } from "./renamenx";
export { type RPopCommand } from "./rpop";
export { type RPushCommand } from "./rpush";
export { type RPushXCommand } from "./rpushx";
export { type SAddCommand } from "./sadd";
export { type ScanCommand, ScanCommandOptions } from "./scan";
export { type SCardCommand } from "./scard";
export { type ScriptExistsCommand } from "./script_exists";
export { type ScriptFlushCommand } from "./script_flush";
export { type ScriptLoadCommand } from "./script_load";
export { type SDiffCommand } from "./sdiff";
export { type SDiffStoreCommand } from "./sdiffstore";
export { type SetCommand, SetCommandOptions } from "./set";
export { type SetBitCommand } from "./setbit";
export { type SetExCommand } from "./setex";
export { type SetNxCommand } from "./setnx";
export { type SetRangeCommand } from "./setrange";
export { type SInterCommand } from "./sinter";
export { type SInterStoreCommand } from "./sinterstore";
export { type SIsMemberCommand } from "./sismember";
export { type SMembersCommand } from "./smembers";
export { type SMIsMemberCommand } from "./smismember";
export { type SMoveCommand } from "./smove";
export { type SPopCommand } from "./spop";
export { type SRandMemberCommand } from "./srandmember";
export { type SRemCommand } from "./srem";
export { type SScanCommand } from "./sscan";
export { type StrLenCommand } from "./strlen";
export { type SUnionCommand } from "./sunion";
export { type SUnionStoreCommand } from "./sunionstore";
export { type TimeCommand } from "./time";
export { type TouchCommand } from "./touch";
export { type TtlCommand } from "./ttl";
export { Type, type TypeCommand } from "./type";
export { type UnlinkCommand } from "./unlink";
export { type XAddCommand } from "./xadd";
export { type XRangeCommand } from "./xrange";
export {
ScoreMember,
ZAddCommandOptions,
ZAddCommandOptionsWithIncr,
type ZAddCommand,
} from "./zadd";
export { type ZCardCommand } from "./zcard";
export { type ZCountCommand } from "./zcount";
export { type ZDiffStoreCommand } from "./zdiffstore";
export { type ZIncrByCommand } from "./zincrby";
export { type ZInterStoreCommand, ZInterStoreCommandOptions } from "./zinterstore";
export { type ZLexCountCommand } from "./zlexcount";
export { type ZMScoreCommand } from "./zmscore";
export { type ZPopMaxCommand } from "./zpopmax";
export { type ZPopMinCommand } from "./zpopmin";
export { type ZRangeCommand, ZRangeCommandOptions } from "./zrange";
export { type ZRankCommand } from "./zrank";
export { type ZRemCommand } from "./zrem";
export { type ZRemRangeByLexCommand } from "./zremrangebylex";
export { type ZRemRangeByRankCommand } from "./zremrangebyrank";
export { type ZRemRangeByScoreCommand } from "./zremrangebyscore";
export { type ZRevRankCommand } from "./zrevrank";
export { type ZScanCommand } from "./zscan";
export { type ZScoreCommand } from "./zscore";
export { type ZUnionCommand, ZUnionCommandOptions } from "./zunion";
export { type ZUnionStoreCommand, ZUnionStoreCommandOptions } from "./zunionstore";
20 changes: 10 additions & 10 deletions pkg/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ export class Redis {
use = <TResult = unknown>(
middleware: (
r: UpstashRequest,
next: <TResult = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult>>,
) => Promise<UpstashResponse<TResult>>,
next: <TResult = unknown>(req: UpstashRequest) => Promise<UpstashResponse<TResult>>
) => Promise<UpstashResponse<TResult>>
) => {
const makeRequest = this.client.request.bind(this.client);
this.client.request = (req: UpstashRequest) => middleware(req, makeRequest) as any;
Expand Down Expand Up @@ -447,7 +447,7 @@ export class Redis {
...sourceKeys: string[]
) =>
new BitOpCommand([op as any, destinationKey, sourceKey, ...sourceKeys], this.opts).exec(
this.client,
this.client
);

/**
Expand Down Expand Up @@ -633,12 +633,12 @@ export class Redis {
<TData extends Record<string, unknown>>(
key: string,
count: number,
withValues: boolean,
withValues: boolean
): Promise<Partial<TData>>;
} = <TData extends string | string[] | Record<string, unknown>>(
key: string,
count?: number,
withValues?: boolean,
withValues?: boolean
) => new HRandFieldCommand<TData>([key, count, withValues] as any, this.opts).exec(this.client);

/**
Expand Down Expand Up @@ -1067,19 +1067,19 @@ export class Redis {
| [
key: string,
opts: ZAddCommandOptions | ZAddCommandOptionsWithIncr,
...scoreMemberPairs: [ScoreMember<TData>, ...ScoreMember<TData>[]],
...scoreMemberPairs: [ScoreMember<TData>, ...ScoreMember<TData>[]]
]
) => {
if ("score" in args[1]) {
return new ZAddCommand<TData>(
[args[0], args[1] as ScoreMember<TData>, ...(args.slice(2) as any)],
this.opts,
this.opts
).exec(this.client);
}

return new ZAddCommand<TData>(
[args[0], args[1] as any, ...(args.slice(2) as any)],
this.opts,
this.opts
).exec(this.client);
};
/**
Expand Down Expand Up @@ -1146,13 +1146,13 @@ export class Redis {
key: string,
min: `(${string}` | `[${string}` | "-" | "+",
max: `(${string}` | `[${string}` | "-" | "+",
opts: { byLex: true } & ZRangeCommandOptions,
opts: { byLex: true } & ZRangeCommandOptions
]
| [
key: string,
min: number | `(${number}` | "-inf" | "+inf",
max: number | `(${number}` | "-inf" | "+inf",
opts: { byScore: true } & ZRangeCommandOptions,
opts: { byScore: true } & ZRangeCommandOptions
]
) => new ZRangeCommand<TData>(args as any, this.opts).exec(this.client);

Expand Down
8 changes: 5 additions & 3 deletions platforms/cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { VERSION } from "../version";
type Env = {
UPSTASH_DISABLE_TELEMETRY?: string;
};

export type * from "../pkg/commands/types";
export type { Requester, UpstashRequest, UpstashResponse };
/**
* Connection credentials for upstash redis.
Expand Down Expand Up @@ -82,7 +84,7 @@ export class Redis extends core.Redis {
UPSTASH_REDIS_REST_TOKEN: string;
UPSTASH_DISABLE_TELEMETRY?: string;
},
opts?: Omit<RedisConfigCloudflare, "url" | "token">,
opts?: Omit<RedisConfigCloudflare, "url" | "token">
): Redis {
// @ts-ignore These will be defined by cloudflare
const url = env?.UPSTASH_REDIS_REST_URL ?? UPSTASH_REDIS_REST_URL;
Expand All @@ -92,12 +94,12 @@ export class Redis extends core.Redis {

if (!url) {
throw new Error(
"Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`",
"Unable to find environment variable: `UPSTASH_REDIS_REST_URL`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_URL`"
);
}
if (!token) {
throw new Error(
"Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`",
"Unable to find environment variable: `UPSTASH_REDIS_REST_TOKEN`. Please add it via `wrangler secret put UPSTASH_REDIS_REST_TOKEN`"
);
}
return new Redis({ ...opts, url, token }, env);
Expand Down
1 change: 1 addition & 0 deletions platforms/fastly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { HttpClient } from "../pkg/http";
import * as core from "../pkg/redis";
import { VERSION } from "../version";

export type * from "../pkg/commands/types";
export type { Requester, UpstashRequest, UpstashResponse };

/**
Expand Down
2 changes: 1 addition & 1 deletion platforms/nodejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (typeof atob === "undefined") {
return Buffer.from(b64, "base64").toString("utf-8");
};
}

export type * from "../pkg/commands/types";
export type { Requester, UpstashRequest, UpstashResponse };

/**
Expand Down