Browse Source
Merge pull request #2809 from Budibase/fix/prevent-limits-for-tenants
remove cloud limits for certain tenants
gh-pages
Martin McKeaveney
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
10 additions and
1 deletions
-
packages/server/src/middleware/tests/usageQuota.spec.js
-
packages/server/src/middleware/usageQuota.js
|
|
|
@ -6,6 +6,9 @@ jest.mock("../../environment", () => ({ |
|
|
|
isDev: () => true, |
|
|
|
_set: () => {}, |
|
|
|
})) |
|
|
|
jest.mock("@budibase/auth/tenancy", () => ({ |
|
|
|
getTenantId: () => "testing123" |
|
|
|
})) |
|
|
|
|
|
|
|
const usageQuotaMiddleware = require("../usageQuota") |
|
|
|
const usageQuota = require("../../utilities/usageQuota") |
|
|
|
|
|
|
|
@ -1,6 +1,10 @@ |
|
|
|
const CouchDB = require("../db") |
|
|
|
const usageQuota = require("../utilities/usageQuota") |
|
|
|
const env = require("../environment") |
|
|
|
const { getTenantId } = require("@budibase/auth/tenancy") |
|
|
|
|
|
|
|
// tenants without limits
|
|
|
|
const EXCLUDED_TENANTS = ["bb", "default", "bbtest", "bbstaging"] |
|
|
|
|
|
|
|
// currently only counting new writes and deletes
|
|
|
|
const METHOD_MAP = { |
|
|
|
@ -28,8 +32,10 @@ function getProperty(url) { |
|
|
|
} |
|
|
|
|
|
|
|
module.exports = async (ctx, next) => { |
|
|
|
const tenantId = getTenantId() |
|
|
|
|
|
|
|
// if in development or a self hosted cloud usage quotas should not be executed
|
|
|
|
if (env.isDev() || env.SELF_HOSTED) { |
|
|
|
if (env.isDev() || env.SELF_HOSTED || EXCLUDED_TENANTS.includes(tenantId)) { |
|
|
|
return next() |
|
|
|
} |
|
|
|
|
|
|
|
|