mirror of
https://github.com/mauricioabh/arbpulse.git
synced 2026-08-05 11:37:44 +00:00
test(m3): add Upstash read-tier rate limit HTTP test
Node test asserts 429 with Retry-After after 60 GET requests per IP. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
|
||||
/** Loads `.env.local` without overriding variables already set in the shell. */
|
||||
export function loadEnvLocal(): void {
|
||||
const file = join(process.cwd(), ".env.local");
|
||||
if (!existsSync(file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const line of readFileSync(file, "utf8").split(/\r?\n/)) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed || trimmed.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const eq = trimmed.indexOf("=");
|
||||
if (eq <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const key = trimmed.slice(0, eq).trim();
|
||||
let value = trimmed.slice(eq + 1).trim();
|
||||
if (
|
||||
(value.startsWith('"') && value.endsWith('"')) ||
|
||||
(value.startsWith("'") && value.endsWith("'"))
|
||||
) {
|
||||
value = value.slice(1, -1);
|
||||
}
|
||||
|
||||
if (process.env[key] === undefined) {
|
||||
process.env[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user