Skip to content

Commit

Permalink
fix: replace repository.add by repository.create method
Browse files Browse the repository at this point in the history
  • Loading branch information
kanelv committed Apr 4, 2024
1 parent ef55d70 commit b2e984f
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/application/use-cases/url/shorten-url.usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class ShortenUrlUseCase {
//if it doesn't exist, shorten it
const urlCode = nanoid(10);

await this.urlRepository.add(createOneUrl);
await this.urlRepository.create(createOneUrl);

// return `${this.configService.get('URL_SHORTENER_DOMAIN')}/url/${urlCode}`;

Expand Down
2 changes: 1 addition & 1 deletion src/application/use-cases/user/sign-up-user.usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class SignUpUserUseCase {
createOneUser.password
);

return await this.userRepository.add({
return await this.userRepository.create({
userName: createOneUser.userName,
password: encryptedPassword
});
Expand Down
2 changes: 1 addition & 1 deletion src/domain/contracts/repositories/repository.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type UrlFindOneBy = {
};

export interface IRepository {
add(object: any): Promise<any>;
create(object: any): Promise<any>;
findAll(): Promise<any[]>;
findOne(object: any): Promise<any>;
isExist(object: any): Promise<any>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type FindOneUrl = {
};

export abstract class AbstractUrlRepository implements IRepository {
abstract add(createOneUrl: CreateOneUrl): Promise<any>;
abstract create(createOneUrl: CreateOneUrl): Promise<any>;
abstract findAll(): Promise<any[]>;
abstract findOne(findOneUrl: FindOneUrl): Promise<any>;
abstract deleteOne(findOneUrl: FindOneUrl): Promise<any>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type FindOneUser = {
};

export abstract class AbstractUserRepository implements IRepository {
abstract add(createOneUser: CreateOneUser): Promise<any>;
abstract create(createOneUser: CreateOneUser): Promise<any>;
abstract findAll(): Promise<any[]>;
abstract findOne(findOneUser: FindOneUser): Promise<any>;
abstract updateOne(updateOneUser: UpdateOneUser): Promise<any>;
Expand Down
2 changes: 1 addition & 1 deletion src/ia/repositories/url.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class UrlRepository implements AbstractUrlRepository {

private readonly logger = new Logger(UrlRepository.name);

async add(createOneUrl: CreateOneUrl): Promise<any> {
async create(createOneUrl: CreateOneUrl): Promise<any> {
const newUrl = this.urlRepository.create(createOneUrl);

const insertResult: InsertResult = await this.urlRepository.insert(newUrl);
Expand Down
2 changes: 1 addition & 1 deletion src/ia/repositories/user.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class UserRepository implements AbstractUserRepository {

private readonly logger = new Logger(UserRepository.name);

async add(createOneUser: CreateOneUser): Promise<any> {
async create(createOneUser: CreateOneUser): Promise<any> {
const newUser = this.userRepository.create(createOneUser);
this.logger.debug(`create::newUser: ${JSON.stringify(newUser, null, 2)}`);

Expand Down
37 changes: 0 additions & 37 deletions test/app.e2e-spec.ts

This file was deleted.

0 comments on commit b2e984f

Please sign in to comment.