Skip to content

Commit

Permalink
refactor: optional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenbkr committed Aug 1, 2024
1 parent 4ecc52a commit bcd5426
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/auth/authHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const tokenHandler = (claim: string) => {
return async (request: FastifyRequest, reply: FastifyReply): Promise<void> => {
const logContext = 'tokenHandler()';
const authHeader = request.headers.authorization;
if (!authHeader || !authHeader.startsWith('Bearer ') || !claim) {
if (!authHeader?.startsWith('Bearer ') || !claim) {
reply.code(401).send({ error: 'Unauthorized' });
return;
}
Expand Down

0 comments on commit bcd5426

Please sign in to comment.