bro-framework 3.0.4 → 3.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/edge.js +2 -2
- package/src/engine.js +1 -1
- package/src/next.js +1 -1
package/package.json
CHANGED
package/src/edge.js
CHANGED
|
@@ -8,8 +8,8 @@ export async function hashIdentity(identity) {
|
|
|
8
8
|
const hash = await crypto.subtle.digest('SHA-256', data);
|
|
9
9
|
return Array.from(new Uint8Array(hash)).map(b => b.toString(16).padStart(2, '0')).join('');
|
|
10
10
|
}
|
|
11
|
-
export function generateRateLimitKey(req, config, prefix = 'route') { const identity = resolveIdentity(req, config); return `bro:rate_limit:${prefix}:${req.originalUrl || req.url}:${
|
|
12
|
-
export function generateCacheKey(req, config, locale) { const identity = resolveIdentity(req, config); return `bro:cache:${req.method}:${req.originalUrl || req.url}:${locale}:${
|
|
11
|
+
export async function generateRateLimitKey(req, config, prefix = 'route') { const identity = resolveIdentity(req, config); const hash = await hashIdentity(identity); return `bro:rate_limit:${prefix}:${req.originalUrl || req.url}:${hash}`; }
|
|
12
|
+
export async function generateCacheKey(req, config, locale) { const identity = resolveIdentity(req, config); const hash = await hashIdentity(identity); return `bro:cache:${req.method}:${req.originalUrl || req.url}:${locale}:${hash}`; }
|
|
13
13
|
|
|
14
14
|
export { z };
|
|
15
15
|
|
package/src/engine.js
CHANGED
|
@@ -118,7 +118,7 @@ export async function executeRequest(routeConfig, requestData, globalConfig, ctx
|
|
|
118
118
|
const redisClient = ctxExtras.redis;
|
|
119
119
|
|
|
120
120
|
if (activeRateLimit && redisClient) {
|
|
121
|
-
const rlKey = generateRateLimitKey ? await generateRateLimitKey(requestData, globalConfig) : `bro:rl:${requestData.originalUrl}:${requestData.ip}`;
|
|
121
|
+
const rlKey = ctxExtras.generateRateLimitKey ? await ctxExtras.generateRateLimitKey(requestData, globalConfig) : `bro:rl:${requestData.originalUrl}:${requestData.ip}`;
|
|
122
122
|
try {
|
|
123
123
|
const current = await redisClient.incr(rlKey);
|
|
124
124
|
const windowSeconds = Math.floor(activeRateLimit.windowMs / 1000);
|
package/src/next.js
CHANGED
|
@@ -236,7 +236,7 @@ export function createBro(globalConfig = {}) {
|
|
|
236
236
|
console.error('[bro.js/next] Unhandled Error:', error);
|
|
237
237
|
return NextResponse.json(
|
|
238
238
|
{
|
|
239
|
-
type: '
|
|
239
|
+
type: 'errors/internal_server_error',
|
|
240
240
|
title: 'Internal Server Error',
|
|
241
241
|
status: 500,
|
|
242
242
|
instance: req.url,
|