Skip to content

Commit

Permalink
refactor: update request handling in api.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
jqshuv committed Oct 19, 2024
1 parent d5c9415 commit f80e4bb
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/routes/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,19 @@ function hasValidHeader(request: Request, env: Env): boolean {
const authHeader = request.headers.get('Authorization');

// Check if the Authorization header is valid.
if (authHeader === env.AUTH_SECRET) {
return true;
} else {
return false;
}
if (authHeader === env.AUTH_SECRET) return true;

// Return false if the Authorization header is invalid.
return false;
} else if (searchParams.has('auth')) {
// Get the auth query parameter from the request.
const authParam = searchParams.get('auth');

// Check if the auth query parameter is valid.
if (authParam === env.AUTH_SECRET) {
return true;
} else {
return false;
}
if (authParam === env.AUTH_SECRET) return true;

// Return false if the auth query parameter is invalid.
return false;
} else {
return false;
}
Expand Down

0 comments on commit f80e4bb

Please sign in to comment.