From 9aa79cb6d83c05997136966e0412d66bf79533c5 Mon Sep 17 00:00:00 2001 From: geraldovictor Date: Mon, 13 Nov 2023 23:06:04 -0300 Subject: [PATCH] =?UTF-8?q?Corrige=20url=20e=20nome=20de=20vari=C3=A1vel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/environment/environment.ts | 3 ++- src/app/services/auth.service.spec.ts | 14 +++++++------- src/app/services/auth.service.ts | 16 ++++++++-------- src/app/services/email.service.ts | 7 ++++--- .../user-token-interceptor.service.spec.ts | 2 +- src/app/services/user.service.spec.ts | 8 ++++---- src/app/services/user.service.ts | 10 +++++----- 7 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/app/environment/environment.ts b/src/app/environment/environment.ts index e21e43da..6ed41a3c 100644 --- a/src/app/environment/environment.ts +++ b/src/app/environment/environment.ts @@ -1,4 +1,5 @@ export const EDUPLAY_CLIENT_KEY = "a1cdba06226408fcda63b49c50223c68d56005d234cc98bcdc1ae787d2b4de1d"; export const environment = { - apiURL: 'https://unb-tv-backend-2be1ed3a0485.herokuapp.com/api', + usersAPIURL: 'https://unb-tv-backend-2be1ed3a0485.herokuapp.com/api', + adminAPIURL: 'https://admin-unb-tv-2023-2-dc0dd53d3aca.herokuapp.com/api' }; diff --git a/src/app/services/auth.service.spec.ts b/src/app/services/auth.service.spec.ts index d4bec24a..cd99307a 100644 --- a/src/app/services/auth.service.spec.ts +++ b/src/app/services/auth.service.spec.ts @@ -30,7 +30,7 @@ describe('AuthService', () => { service.registerUser(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/register`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/register`); expect(req.request.method).toBe('POST'); req.flush(userResponse); }); @@ -44,7 +44,7 @@ describe('AuthService', () => { service.loginUser(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/login`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/login`); expect(req.request.method).toBe('POST'); req.flush(userResponse); }); @@ -57,7 +57,7 @@ describe('AuthService', () => { service.activeAccount(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/activate-account`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/activate-account`); expect(req.request.method).toBe('PATCH'); req.flush(userResponse); }); @@ -69,7 +69,7 @@ describe('AuthService', () => { service.resendCode(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/resend-code`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/resend-code`); expect(req.request.method).toBe('POST'); req.flush(userResponse); }); @@ -81,7 +81,7 @@ describe('AuthService', () => { service.sendEmailPassword(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/reset-password/request`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/reset-password/request`); expect(req.request.method).toBe('POST'); req.flush(userResponse); }); @@ -94,7 +94,7 @@ describe('AuthService', () => { service.verifyCodePassword(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/reset-password/verify`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/reset-password/verify`); expect(req.request.method).toBe('POST'); req.flush(userResponse); }); @@ -108,7 +108,7 @@ describe('AuthService', () => { service.updatePassword(userResponse).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/auth/reset-password/change`); + const req = httpMock.expectOne(`${service.usersAPIURL}/auth/reset-password/change`); expect(req.request.method).toBe('PATCH'); req.flush(userResponse); }); diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index b94bb0cc..7f4a6a3a 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -8,36 +8,36 @@ import { Observable } from 'rxjs'; providedIn: 'root' }) export class AuthService { - public apiURL = environment.apiURL; + public usersAPIURL = environment.usersAPIURL; constructor(private http: HttpClient) { } registerUser(user: any): Observable { - return this.http.post(`${this.apiURL}/auth/register`, user); + return this.http.post(`${this.usersAPIURL}/auth/register`, user); } loginUser(user: any): Observable { - return this.http.post(`${this.apiURL}/auth/login`, user); + return this.http.post(`${this.usersAPIURL}/auth/login`, user); } activeAccount(emailCode: any): Observable { - return this.http.patch(`${this.apiURL}/auth/activate-account`, emailCode); + return this.http.patch(`${this.usersAPIURL}/auth/activate-account`, emailCode); } resendCode(email: any): Observable { - return this.http.post(`${this.apiURL}/auth/resend-code`, email); + return this.http.post(`${this.usersAPIURL}/auth/resend-code`, email); } sendEmailPassword(email: any): Observable { - return this.http.post(`${this.apiURL}/auth/reset-password/request`, email); + return this.http.post(`${this.usersAPIURL}/auth/reset-password/request`, email); } verifyCodePassword(info: any): Observable { - return this.http.post(`${this.apiURL}/auth/reset-password/verify`, info); + return this.http.post(`${this.usersAPIURL}/auth/reset-password/verify`, info); } updatePassword(user: any): Observable { - return this.http.patch(`${this.apiURL}/auth/reset-password/change`, user); + return this.http.patch(`${this.usersAPIURL}/auth/reset-password/change`, user); } isAuthenticated(): boolean { diff --git a/src/app/services/email.service.ts b/src/app/services/email.service.ts index cbe6b773..fa91d33b 100644 --- a/src/app/services/email.service.ts +++ b/src/app/services/email.service.ts @@ -2,16 +2,17 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs'; import { IEmailData } from 'src/shared/model/email.model'; +import { environment } from '../environment/environment'; @Injectable({ providedIn: 'root' }) export class EmailService { - private apiUrl = 'http://localhost:8080/api/pauta/email'; // Ajuste conforme necessário + private adminAPIUrl = environment.adminAPIURL + '/pauta/email'; // Ajuste conforme necessário - constructor(private http: HttpClient) {} + constructor(private http: HttpClient) { } sendEmail(email: IEmailData): Observable { - return this.http.post(this.apiUrl, email); + return this.http.post(this.adminAPIUrl, email); } } \ No newline at end of file diff --git a/src/app/services/user-token-interceptor.service.spec.ts b/src/app/services/user-token-interceptor.service.spec.ts index 085d5581..3f520648 100644 --- a/src/app/services/user-token-interceptor.service.spec.ts +++ b/src/app/services/user-token-interceptor.service.spec.ts @@ -33,7 +33,7 @@ describe('TokenInterceptorService', () => { userService.getAllUsers().subscribe((res) => { expect(res).toBeTruthy(); }); - const req = httpMock.expectOne(`${userService.apiURL}/users`); + const req = httpMock.expectOne(`${userService.usersAPIURL}/users`); expect(req.request.headers.has('Authorization')).toEqual(true); }); }); diff --git a/src/app/services/user.service.spec.ts b/src/app/services/user.service.spec.ts index cc2d4167..9950ac52 100644 --- a/src/app/services/user.service.spec.ts +++ b/src/app/services/user.service.spec.ts @@ -30,7 +30,7 @@ describe('UserService', () => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/users/1`); + const req = httpMock.expectOne(`${service.usersAPIURL}/users/1`); expect(req.request.method).toBe('GET'); req.flush(userResponse); }); @@ -56,7 +56,7 @@ describe('UserService', () => { service.getAllUsers().subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/users`); + const req = httpMock.expectOne(`${service.usersAPIURL}/users`); expect(req.request.method).toBe('GET'); req.flush(userResponse); } @@ -74,7 +74,7 @@ describe('UserService', () => { service.updateUser(1, { "name": "Mario", "connection": "PROFESSOR", "email": "mario@gmail.com" }).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/users/1`); + const req = httpMock.expectOne(`${service.usersAPIURL}/users/1`); expect(req.request.method).toBe('PATCH'); req.flush(userResponse); } @@ -92,7 +92,7 @@ describe('UserService', () => { service.deleteUser(1).subscribe(res => { expect(res).toEqual(userResponse); }); - const req = httpMock.expectOne(`${service.apiURL}/users/1`); + const req = httpMock.expectOne(`${service.usersAPIURL}/users/1`); expect(req.request.method).toBe('DELETE'); req.flush(userResponse); } diff --git a/src/app/services/user.service.ts b/src/app/services/user.service.ts index bb9279f9..4677ad41 100644 --- a/src/app/services/user.service.ts +++ b/src/app/services/user.service.ts @@ -7,23 +7,23 @@ import { Observable } from 'rxjs'; providedIn: 'root' }) export class UserService { - public apiURL = environment.apiURL; + public usersAPIURL = environment.usersAPIURL; constructor(private http: HttpClient) { } getUser(id: any): Observable { - return this.http.get(`${this.apiURL}/users/${id}`); + return this.http.get(`${this.usersAPIURL}/users/${id}`); } getAllUsers(): Observable { - return this.http.get(`${this.apiURL}/users`); + return this.http.get(`${this.usersAPIURL}/users`); } updateUser(id: any, body: any): Observable { - return this.http.patch(`${this.apiURL}/users/${id}`, body); + return this.http.patch(`${this.usersAPIURL}/users/${id}`, body); } deleteUser(id: any): Observable { - return this.http.delete(`${this.apiURL}/users/${id}`); + return this.http.delete(`${this.usersAPIURL}/users/${id}`); } }