Choose existing utilities, simpler patterns, and cleaner implementations over manual or complex approaches. This improves code maintainability and reduces potential bugs.
Key practices:
ctx.getCookie()
instead of manually parsing cookie strings)console.log()
from production codeelse if
chains when independent conditions can be usedExample of preferred approach:
// Instead of manual parsing:
const cookies = cookieString.split(";").map(cookie => cookie.trim());
// Use existing utility:
const cookieValue = ctx.getCookie(cookieName);
// Instead of else-if chains:
if (authentication === "basic") {
requestHeaders["authorization"] = `Basic ${encodedCredentials}`;
}
if (authentication !== "basic" && options.clientSecret) {
body.set("client_secret", options.clientSecret);
}
This approach reduces complexity, leverages tested utilities, and makes code more readable and maintainable.
Enter the URL of a public GitHub repository