import { HttpClient } from "@angular/common/http";
import { Injectable } from '@angular/core';
import { Observable } from "rxjs";

export interface accessToken {
  name: string,
  timestamp: Date
}

@Injectable({
  providedIn: 'root'
})
export class HttpServiceTest {

  constructor(private http: HttpClient) {
    console.log('creating instance of http service')
  }

  getToken(name: string) {
    return this.http.get(`http://localhost:5000/session/${name}`);
  }

  setToken(loginToken: accessToken) {
    return this.http.post('http://localhost:5000/session',loginToken);
  }

  destroyToken(name: string) {
    return this.http.delete(`http://localhost:5000/session/${name}`);
  }

}
