You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
50 lines
1.4 KiB
|
|
import { Injectable } from '@angular/core';
|
|
import { HttpClient } from '@angular/common/http';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
|
|
export class ApiService
|
|
{
|
|
server_route = 'http://localhost:3000'
|
|
|
|
constructor(private http: HttpClient) { }
|
|
|
|
getMessage()
|
|
{
|
|
return this.http.get(
|
|
'http://localhost:3000/api/message');
|
|
}
|
|
|
|
postReplayUpload(file: any)
|
|
{
|
|
return this.http.post(
|
|
this.server_route+'/api/upload-replay', file);
|
|
}
|
|
|
|
getSeasons()
|
|
{
|
|
return this.http.get(
|
|
this.server_route+'/api/seasons');
|
|
}
|
|
|
|
getSeasonDetails(id: string)
|
|
{
|
|
return this.http.get(
|
|
this.server_route+'/api/seasons/'+id);
|
|
}
|
|
|
|
addSeason(title: string, subtitle: string, startDate: Date)
|
|
{
|
|
return this.http.post<{title: string, subtitle: string, startDate: Date}>(this.server_route+'/api/seasons/add', { title, subtitle, startDate },
|
|
{headers: { authorization: `Bearer ${localStorage.getItem('token')}` },});
|
|
}
|
|
|
|
addRace(seasonId: string, startDate: Date, endDate: Date, mapName: string, mapLink: string, weekNumber: Number)
|
|
{
|
|
return this.http.post<{title: string, subtitle: string, startDate: Date}>(this.server_route+'/api/race/add', { seasonId, startDate, endDate, mapName, mapLink, weekNumber },
|
|
{headers: { authorization: `Bearer ${localStorage.getItem('token')}` },});
|
|
}
|
|
}
|