From ed70b4c1ff085b672ba2b40c2823df0073a3890d Mon Sep 17 00:00:00 2001 From: Andreas Thomas Date: Wed, 11 May 2022 09:45:19 +0200 Subject: [PATCH 1/3] client types (#82) * fix: vercel edge runs again * docs * fix: export client types in deno --- mod.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/mod.ts b/mod.ts index 873826dc..32aa247e 100644 --- a/mod.ts +++ b/mod.ts @@ -1,5 +1,6 @@ import { HttpClient } from "./pkg/http.ts"; import * as core from "./pkg/redis.ts"; +export type { Requester, UpstashRequest, UpstashResponse } from "./pkg/http"; /** * Connection credentials for upstash redis. From 8251e292d3f6a410b02f5e0eb653bfe9db7a6920 Mon Sep 17 00:00:00 2001 From: Andreas Thomas Date: Wed, 11 May 2022 17:22:41 +0200 Subject: [PATCH 2/3] Update README.md (#83) * Update README.md * style: fmt --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ce38c594..4da3898d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Upstash Redis -An HTTP/REST based Redis client built on top of -[Upstash REST API](https://docs.upstash.com/features/restapi). +`@upstash/redis` is an HTTP/REST based Redis client for typescript, built on top +of [Upstash REST API](https://docs.upstash.com/features/restapi). [![Tests](https://github.com/upstash/upstash-redis/actions/workflows/tests.yaml/badge.svg)](https://github.com/upstash/upstash-redis/actions/workflows/tests.yaml) ![npm (scoped)](https://img.shields.io/npm/v/@upstash/redis) From 0e80cbf2c35f76afd9b8c773f9bd83956f9430e0 Mon Sep 17 00:00:00 2001 From: Andreas Thomas Date: Thu, 12 May 2022 20:51:00 +0200 Subject: [PATCH 3/3] whitespace (#84) * fix: vercel edge runs again * docs * feat: add warning for whitespace in variables --- mod.ts | 21 ++++++++++++++++++++- platforms/cloudflare.ts | 18 ++++++++++++++++++ platforms/fastly.ts | 18 ++++++++++++++++++ platforms/nodejs.ts | 18 ++++++++++++++++++ 4 files changed, 74 insertions(+), 1 deletion(-) diff --git a/mod.ts b/mod.ts index 32aa247e..cde13cdc 100644 --- a/mod.ts +++ b/mod.ts @@ -1,6 +1,6 @@ import { HttpClient } from "./pkg/http.ts"; import * as core from "./pkg/redis.ts"; -export type { Requester, UpstashRequest, UpstashResponse } from "./pkg/http"; +export type { Requester, UpstashRequest, UpstashResponse } from "./pkg/http.ts"; /** * Connection credentials for upstash redis. @@ -33,6 +33,25 @@ export class Redis extends core.Redis { * ``` */ constructor(config: RedisConfigDeno) { + if ( + config.url.startsWith(" ") || + config.url.endsWith(" ") || + /\r|\n/.test(config.url) + ) { + console.warn( + "The redis url contains whitespace or newline, which can cause errors!", + ); + } + if ( + config.token.startsWith(" ") || + config.token.endsWith(" ") || + /\r|\n/.test(config.token) + ) { + console.warn( + "The redis token contains whitespace or newline, which can cause errors!", + ); + } + const client = new HttpClient({ baseUrl: config.url, headers: { authorization: `Bearer ${config.token}` }, diff --git a/platforms/cloudflare.ts b/platforms/cloudflare.ts index f3d7674c..9683c55b 100644 --- a/platforms/cloudflare.ts +++ b/platforms/cloudflare.ts @@ -38,6 +38,24 @@ export class Redis extends core.Redis { * ``` */ constructor(config: RedisConfigCloudflare) { + if ( + config.url.startsWith(" ") || + config.url.endsWith(" ") || + /\r|\n/.test(config.url) + ) { + console.warn( + "The redis url contains whitespace or newline, which can cause errors!", + ); + } + if ( + config.token.startsWith(" ") || + config.token.endsWith(" ") || + /\r|\n/.test(config.token) + ) { + console.warn( + "The redis token contains whitespace or newline, which can cause errors!", + ); + } const client = defaultRequester({ baseUrl: config.url, headers: { authorization: `Bearer ${config.token}` }, diff --git a/platforms/fastly.ts b/platforms/fastly.ts index 99db0b7e..c906f163 100644 --- a/platforms/fastly.ts +++ b/platforms/fastly.ts @@ -46,6 +46,24 @@ export class Redis extends core.Redis { * ``` */ constructor(config: RedisConfigFastly) { + if ( + config.url.startsWith(" ") || + config.url.endsWith(" ") || + /\r|\n/.test(config.url) + ) { + console.warn( + "The redis url contains whitespace or newline, which can cause errors!", + ); + } + if ( + config.token.startsWith(" ") || + config.token.endsWith(" ") || + /\r|\n/.test(config.token) + ) { + console.warn( + "The redis token contains whitespace or newline, which can cause errors!", + ); + } const client = defaultRequester({ baseUrl: config.url, headers: { authorization: `Bearer ${config.token}` }, diff --git a/platforms/nodejs.ts b/platforms/nodejs.ts index adbf15d7..fcb0c9fc 100644 --- a/platforms/nodejs.ts +++ b/platforms/nodejs.ts @@ -82,6 +82,24 @@ export class Redis extends core.Redis { super(configOrRequester); return; } + if ( + configOrRequester.url.startsWith(" ") || + configOrRequester.url.endsWith(" ") || + /\r|\n/.test(configOrRequester.url) + ) { + console.warn( + "The redis url contains whitespace or newline, which can cause errors!", + ); + } + if ( + configOrRequester.token.startsWith(" ") || + configOrRequester.token.endsWith(" ") || + /\r|\n/.test(configOrRequester.token) + ) { + console.warn( + "The redis token contains whitespace or newline, which can cause errors!", + ); + } const client = defaultRequester({ baseUrl: configOrRequester.url,