test: disable rate limiting in testing
This commit is contained in:
parent
7473c29948
commit
b298524663
3 changed files with 17 additions and 13 deletions
|
|
@ -52,18 +52,16 @@ export const createApp = () => {
|
|||
app.use(honoLogger());
|
||||
}
|
||||
|
||||
if (!config.disableRateLimiting) {
|
||||
app.use(
|
||||
rateLimiter({
|
||||
windowMs: 60 * 5 * 1000,
|
||||
limit: 1000,
|
||||
keyGenerator: (c) => c.req.header("x-forwarded-for") ?? "",
|
||||
skip: () => {
|
||||
return config.__prod__ === false;
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
app.use(
|
||||
rateLimiter({
|
||||
windowMs: 60 * 5 * 1000,
|
||||
limit: 1000,
|
||||
keyGenerator: (c) => c.req.header("x-forwarded-for") ?? "",
|
||||
skip: () => {
|
||||
return config.disableRateLimiting;
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
app.use(
|
||||
bodyLimit({
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ const envSchema = z
|
|||
.filter(Boolean)
|
||||
.concat(s.BASE_URL) ?? [s.BASE_URL],
|
||||
trustProxy: s.TRUST_PROXY === "true",
|
||||
disableRateLimiting: s.DISABLE_RATE_LIMITING === "true",
|
||||
disableRateLimiting: s.DISABLE_RATE_LIMITING === "true" || s.NODE_ENV === "test",
|
||||
appSecret: s.APP_SECRET,
|
||||
baseUrl: s.BASE_URL,
|
||||
isSecure: s.BASE_URL?.startsWith("https://") ?? false,
|
||||
|
|
|
|||
|
|
@ -38,9 +38,15 @@ export const auth = betterAuth({
|
|||
protocol: "auto",
|
||||
},
|
||||
trustedOrigins: config.trustedOrigins,
|
||||
rateLimit: {
|
||||
enabled: !config.disableRateLimiting,
|
||||
},
|
||||
advanced: {
|
||||
cookiePrefix: "zerobyte",
|
||||
useSecureCookies: config.isSecure,
|
||||
ipAddress: {
|
||||
disableIpTracking: config.disableRateLimiting,
|
||||
},
|
||||
},
|
||||
onAPIError: {
|
||||
throw: true,
|
||||
|
|
|
|||
Loading…
Reference in a new issue