generated from nhcarrigan/template
feat: initial prototype works
I can log in and create a book! Woo!
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @copyright 2026 NHCarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { ApiService } from './api.service';
|
||||
import { Game, CreateGameDto, UpdateGameDto } from '@library/shared-types';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class GamesService {
|
||||
constructor(private api: ApiService) {}
|
||||
|
||||
getAllGames(): Observable<Game[]> {
|
||||
return this.api.get<Game[]>('/games');
|
||||
}
|
||||
|
||||
getGameById(id: string): Observable<Game | null> {
|
||||
return this.api.get<Game | null>(`/games/${id}`);
|
||||
}
|
||||
|
||||
createGame(game: CreateGameDto): Observable<Game> {
|
||||
return this.api.post<Game>('/games', game);
|
||||
}
|
||||
|
||||
updateGame(id: string, game: UpdateGameDto): Observable<Game> {
|
||||
return this.api.put<Game>(`/games/${id}`, game);
|
||||
}
|
||||
|
||||
deleteGame(id: string): Observable<{ success: boolean }> {
|
||||
return this.api.delete<{ success: boolean }>(`/games/${id}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user