import { HttpInterceptorFn } from '@angular/common/http';
import { inject } from '@angular/core';
import { TwitchAuthService } from '../twitch/twitch-auth.service';

export const authInterceptor: HttpInterceptorFn = (req, next) => {
  const token = inject(TwitchAuthService).auth()?.token;
  if (!token) return next(req);
  return next(req.clone({ setHeaders: { Authorization: `Bearer ${token}` } }));
};
