Refactor tutorial service for public access and enhance authentication handling

This commit is contained in:
liosha84
2025-07-06 19:37:32 +03:00
parent c39571ad70
commit 2ee97f8c86
25 changed files with 217 additions and 325 deletions
@@ -4,7 +4,7 @@ import { Observable } from 'rxjs';
import { Tutorial } from '../models/tutorial.model';
import {text} from 'node:stream/consumers';
const baseUrl = 'http://localhost:8080/api/tutorials';
const baseUrl = 'http://localhost:8080/api/public/tutorials';
@Injectable({
providedIn: 'root'
@@ -13,31 +13,31 @@ export class TutorialService {
constructor(private http: HttpClient) { }
getAll(): Observable<Tutorial[]> {
getAllPublic(): Observable<Tutorial[]> {
return this.http.get<Tutorial[]>(baseUrl);
}
get(id: any): Observable<Tutorial> {
return this.http.get(`${baseUrl}/${id}`);
}
create(data: any): Observable<any> {
return this.http.post(baseUrl, data);
}
update(id: any, data: any): Observable<any> {
return this.http.put(`${baseUrl}/${id}`, data);
}
delete(id: any): Observable<any> {
return this.http.delete(`${baseUrl}/${id}`);
}
deleteAll(): Observable<any> {
return this.http.delete(baseUrl);
}
//
// get(id: any): Observable<Tutorial> {
// return this.http.get(`${baseUrl}/${id}`);
// }
//
// create(data: any): Observable<any> {
// return this.http.post(baseUrl, data);
// }
//
//
// update(id: any, data: any): Observable<any> {
// return this.http.put(`${baseUrl}/${id}`, data);
// }
//
// delete(id: any): Observable<any> {
// return this.http.delete(`${baseUrl}/${id}`);
// }
//
// deleteAll(): Observable<any> {
// return this.http.delete(baseUrl);
// }
findByTitle(title: any): Observable<Tutorial[]> {
return this.http.get<Tutorial[]>(`${baseUrl}?title=${title}`);