diff --git a/angular.json b/angular.json index 256bb52..1765036 100644 --- a/angular.json +++ b/angular.json @@ -49,7 +49,13 @@ "development": { "optimization": false, "extractLicenses": false, - "sourceMap": true + "sourceMap": true, + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.development.ts" + } + ] } }, "defaultConfiguration": "production" diff --git a/src/app/services/login.service.spec.ts b/src/app/services/login.service.spec.ts new file mode 100644 index 0000000..299b0d5 --- /dev/null +++ b/src/app/services/login.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { LoginService } from './login.service'; + +describe('LoginService', () => { + let service: LoginService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(LoginService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/services/login.service.ts b/src/app/services/login.service.ts new file mode 100644 index 0000000..bc33419 --- /dev/null +++ b/src/app/services/login.service.ts @@ -0,0 +1,22 @@ +import { HttpClient } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs'; +import { environment } from '../../environments/environment'; + +@Injectable({ + providedIn: 'root', +}) +export class LoginService { + private apiUrl = environment.apiURL; + + constructor(private http: HttpClient) {} + + login(username: string, password: string): Observable { + return this.http.get(this.apiUrl + '/login', { + params: { + username: username, + password: password, + }, + }); + } +} diff --git a/src/environments/environment.development.ts b/src/environments/environment.development.ts new file mode 100644 index 0000000..89fad4e --- /dev/null +++ b/src/environments/environment.development.ts @@ -0,0 +1,4 @@ +export const environment = { + production: false, + apiURL: 'https://api.memorymap.fr/api/v1', +}; diff --git a/src/environments/environment.ts b/src/environments/environment.ts new file mode 100644 index 0000000..2c63d3c --- /dev/null +++ b/src/environments/environment.ts @@ -0,0 +1,4 @@ +export const environment = { + production: true, + apiURL: 'https://api.memorymap.fr/api/v1', +};