MCPcopy Create free account
hub / github.com/avoidwork/tenso / benchmarkRouteProtection

Function benchmarkRouteProtection

benchmarks/auth.js:256–323  ·  view source on GitHub ↗

* Benchmarks route protection pattern matching

()

Source from the content-addressed store, hash-verified

254 * Benchmarks route protection pattern matching
255 */
256function benchmarkRouteProtection () {
257 console.log("\n📊 Route Protection Pattern Matching");
258 console.log("-".repeat(40));
259
260 const suite = new Benchmark.Suite();
261
262 // Create protection patterns
263 const protectPatterns = [
264 /^\/admin/,
265 /^\/api\/private/,
266 /^\/user\/profile/,
267 /^\/secure/,
268 /^\/protected/
269 ];
270
271 const unprotectPatterns = [
272 /^\/public/,
273 /^\/assets/,
274 /^\/login/,
275 /^\/health/
276 ];
277
278 // Test URLs
279 const testUrls = [
280 "/admin/dashboard",
281 "/api/private/data",
282 "/user/profile/123",
283 "/public/assets/style.css",
284 "/login",
285 "/secure/vault",
286 "/health/check",
287 "/unmatched/route"
288 ];
289
290 // Mock protection check function
291 const checkRouteProtection = url => {
292 // Check unprotect patterns first
293 for (const pattern of unprotectPatterns) {
294 if (pattern.test(url)) return { protected: false, reason: "unprotected" };
295 }
296
297 // Check protect patterns
298 for (const pattern of protectPatterns) {
299 if (pattern.test(url)) return { protected: true, reason: "protected" };
300 }
301
302 return { protected: false, reason: "default" };
303 };
304
305 suite
306 .add("Route protection - Single URL check", () => {
307 checkRouteProtection("/admin/dashboard");
308 })
309 .add("Route protection - Multiple URL checks", () => {
310 testUrls.forEach(url => checkRouteProtection(url));
311 })
312 .add("Route protection - Pattern compilation", () => {
313 const patterns = ["^/admin", "^/api/private", "^/secure"];

Callers 1

mainFunction · 0.85

Calls 2

checkRouteProtectionFunction · 0.85
logMethod · 0.80

Tested by

no test coverage detected