Import des sources angular à partir de 'headup_app'

This commit is contained in:
Rampeur
2025-08-11 23:26:29 +02:00
parent 7dcb426ef5
commit 0a6cbc0c00
335 changed files with 64362 additions and 0 deletions
@@ -0,0 +1,13 @@
import { HttpInterceptorFn } from "@angular/common/http";
import { environment } from 'src/environments/environment';
export const apiInterceptor: HttpInterceptorFn = (req, next) => {
const apiReq = req.clone({
setHeaders: {
...({ 'Content-Type': 'application/json', 'Accept': 'application/json' }),
},
url: `${environment.api_url}${req.url}`
});
return next(apiReq);
};
@@ -0,0 +1,10 @@
import { HttpInterceptorFn } from "@angular/common/http";
import { throwError } from "rxjs";
import { catchError } from "rxjs/operators";
export const errorInterceptor: HttpInterceptorFn = (req, next) => {
return next(req).pipe(catchError((err) => throwError(() => {
console.log(err.error);
return err.error;
})));
};
+4
View File
@@ -0,0 +1,4 @@
export * from './api.interceptor';
export * from './error.interceptor';
//export * from './http.token.interceptor';
export * from './token.interceptor';
@@ -0,0 +1,13 @@
import { inject } from "@angular/core";
import { HttpInterceptorFn } from "@angular/common/http";
import { JwtService } from "src/app/core/services/jwt.service";
export const tokenInterceptor: HttpInterceptorFn = (req, next) => {
const token = inject(JwtService).getToken();
const request = req.clone({
setHeaders: {
...(token ? { Authorization: `Token ${token}` } : {}),
},
});
return next(request);
};