Skip to content

Commit

Permalink
Merge pull request #8 from isdi-coders-2023/feature/environ
Browse files Browse the repository at this point in the history
change environment to production
  • Loading branch information
marcosparajua authored May 19, 2024
2 parents 864d46d + ba23345 commit 88dacb7
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
40 changes: 20 additions & 20 deletions src/services/articles.repo.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import { HttpClient } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';
import { Article } from '../entities/article.js';
import { environment } from '../environments/environment.dev';
import { environment } from '../environments/environment.js';
import { Observable } from 'rxjs';

@Injectable({
providedIn: 'root',
providedIn: 'root',
})
export class RepoArticlesService {
httpClient = inject(HttpClient);
url = environment.apiUrl + '/articles';
httpClient = inject(HttpClient);
url = environment.apiUrl + '/articles';

getById(id: string): Observable<Article> {
return this.httpClient.get<Article>(`${this.url}/${id}`);
}
getById(id: string): Observable<Article> {
return this.httpClient.get<Article>(`${this.url}/${id}`);
}

create(data: FormData) {
const url = this.url;
return this.httpClient.post(url, data);
}
create(data: FormData) {
const url = this.url;
return this.httpClient.post(url, data);
}

getArticles() {
return this.httpClient.get<Article[]>(this.url);
}
getArticles() {
return this.httpClient.get<Article[]>(this.url);
}

deleteArticle(id: string) {
return this.httpClient.delete<Article>(this.url + '/' + id);
}
deleteArticle(id: string) {
return this.httpClient.delete<Article>(this.url + '/' + id);
}

update(id: string, article: FormData): Observable<Article> {
return this.httpClient.patch<Article>(`${this.url}/${id}`, article);
}
update(id: string, article: FormData): Observable<Article> {
return this.httpClient.patch<Article>(`${this.url}/${id}`, article);
}
}
40 changes: 20 additions & 20 deletions src/services/users.repo.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { HttpClient } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';
import { User, UserLoginDto } from '../entities/user.js';
import { environment } from '../environments/environment.dev';
import { environment } from '../environments/environment.js';
import { Article } from '../entities/article.js';

@Injectable({
providedIn: 'root',
providedIn: 'root',
})
export class RepoUsersService {
httpClient = inject(HttpClient);
url = environment.apiUrl + '/users';
httpClient = inject(HttpClient);
url = environment.apiUrl + '/users';

login(data: UserLoginDto) {
return this.httpClient.post<{ token: string }>(this.url + '/login', data);
}
login(data: UserLoginDto) {
return this.httpClient.post<{ token: string }>(this.url + '/login', data);
}

getById(id: string) {
return this.httpClient.get(this.url + '/' + id);
}
getById(id: string) {
return this.httpClient.get(this.url + '/' + id);
}

create(data: FormData) {
const url = this.url + '/signup';
return this.httpClient.post(url, data);
}
create(data: FormData) {
const url = this.url + '/signup';
return this.httpClient.post(url, data);
}

getUsers() {
return this.httpClient.get<User[]>(this.url);
}
getUserArticles(userId: string) {
return this.httpClient.get<Article[]>(`${this.url}/${userId}`);
}
getUsers() {
return this.httpClient.get<User[]>(this.url);
}
getUserArticles(userId: string) {
return this.httpClient.get<Article[]>(`${this.url}/${userId}`);
}
}

0 comments on commit 88dacb7

Please sign in to comment.