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());
|
app.use(honoLogger());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.disableRateLimiting) {
|
app.use(
|
||||||
app.use(
|
rateLimiter({
|
||||||
rateLimiter({
|
windowMs: 60 * 5 * 1000,
|
||||||
windowMs: 60 * 5 * 1000,
|
limit: 1000,
|
||||||
limit: 1000,
|
keyGenerator: (c) => c.req.header("x-forwarded-for") ?? "",
|
||||||
keyGenerator: (c) => c.req.header("x-forwarded-for") ?? "",
|
skip: () => {
|
||||||
skip: () => {
|
return config.disableRateLimiting;
|
||||||
return config.__prod__ === false;
|
},
|
||||||
},
|
}),
|
||||||
}),
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
app.use(
|
app.use(
|
||||||
bodyLimit({
|
bodyLimit({
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ const envSchema = z
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.concat(s.BASE_URL) ?? [s.BASE_URL],
|
.concat(s.BASE_URL) ?? [s.BASE_URL],
|
||||||
trustProxy: s.TRUST_PROXY === "true",
|
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,
|
appSecret: s.APP_SECRET,
|
||||||
baseUrl: s.BASE_URL,
|
baseUrl: s.BASE_URL,
|
||||||
isSecure: s.BASE_URL?.startsWith("https://") ?? false,
|
isSecure: s.BASE_URL?.startsWith("https://") ?? false,
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,15 @@ export const auth = betterAuth({
|
||||||
protocol: "auto",
|
protocol: "auto",
|
||||||
},
|
},
|
||||||
trustedOrigins: config.trustedOrigins,
|
trustedOrigins: config.trustedOrigins,
|
||||||
|
rateLimit: {
|
||||||
|
enabled: !config.disableRateLimiting,
|
||||||
|
},
|
||||||
advanced: {
|
advanced: {
|
||||||
cookiePrefix: "zerobyte",
|
cookiePrefix: "zerobyte",
|
||||||
useSecureCookies: config.isSecure,
|
useSecureCookies: config.isSecure,
|
||||||
|
ipAddress: {
|
||||||
|
disableIpTracking: config.disableRateLimiting,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
onAPIError: {
|
onAPIError: {
|
||||||
throw: true,
|
throw: true,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue