feat: free tier region limits
This commit is contained in:
@@ -42,11 +42,16 @@ export const monitors = new Elysia({ prefix: "/monitors" })
|
||||
return { error: `Minimum interval for ${plan} plan is ${limits.minIntervalS}s` };
|
||||
}
|
||||
|
||||
// Enforce region limit for plan
|
||||
const regions = body.regions ?? [];
|
||||
if (regions.length > limits.maxRegions) {
|
||||
set.status = 400;
|
||||
return { error: `Free plan allows ${limits.maxRegions} region per monitor. Upgrade to use multi-region.` };
|
||||
}
|
||||
|
||||
// SSRF protection
|
||||
const ssrfError = await validateMonitorUrl(body.url);
|
||||
if (ssrfError) { set.status = 400; return { error: ssrfError }; }
|
||||
|
||||
const regions = body.regions ?? [];
|
||||
const [monitor] = await sql`
|
||||
INSERT INTO monitors (account_id, name, url, method, request_headers, request_body, timeout_ms, interval_s, query, regions)
|
||||
VALUES (
|
||||
@@ -89,6 +94,12 @@ export const monitors = new Elysia({ prefix: "/monitors" })
|
||||
}
|
||||
}
|
||||
|
||||
// Enforce region limit for plan
|
||||
if (body.regions && body.regions.length > limits.maxRegions) {
|
||||
set.status = 400;
|
||||
return { error: `Free plan allows ${limits.maxRegions} region per monitor. Upgrade to use multi-region.` };
|
||||
}
|
||||
|
||||
// SSRF protection on URL change
|
||||
if (body.url) {
|
||||
const ssrfError = await validateMonitorUrl(body.url);
|
||||
|
||||
Reference in New Issue
Block a user