Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { APP_FILTER, APP_PIPE } from '@nestjs/core';
import { ZodValidationPipe } from 'nestjs-zod';
import { PrometheusModule } from '@willsoto/nestjs-prometheus';
import { HealthModule } from '@libs/health';
import { UserModule } from './modules/user';
import { UserModule } from './user';
import { GlobalExceptionFilter } from '@shared/error';
import { AuthModule } from './auth/auth.module';
import { BullBoardModule } from '@bull-board/nestjs';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { InjectRedis } from '@nestjs-modules/ioredis';
import { HttpStatus, Injectable } from '@nestjs/common';
import * as argon from 'argon2';
import Redis from 'ioredis';
import { UpdatePassUserCommand } from '@core/modules/user';
import { BaseException } from '@shared/error';
import { PasswordResetConfirmDto } from '../dtos';
import { UpdatePasswordUseCase } from '@core/user';

@Injectable()
export class ConfirmResetPasswordUseCase {
constructor(
@InjectRedis()
private readonly redis: Redis,
private readonly updateUserPass: UpdatePassUserCommand,
private readonly updatePasswordUserUseCase: UpdatePasswordUseCase,
) {}

async execute(dto: PasswordResetConfirmDto) {
Expand Down Expand Up @@ -43,7 +43,7 @@ export class ConfirmResetPasswordUseCase {
}

const hashed = await argon.hash(dto.password);
const isUpdated = await this.updateUserPass.execute(dto.email, hashed);
const isUpdated = await this.updatePasswordUserUseCase.execute(dto.email, hashed);

if (!isUpdated) {
throw new BaseException(
Expand Down
6 changes: 3 additions & 3 deletions src/auth/application/use-cases/refresh-tokens.use-case.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { HttpStatus, Inject, Injectable } from '@nestjs/common';
import { FindOneUserCommand } from '@core/modules/user';
import { BaseException } from '@shared/error';
import { ISessionRepository } from '../../domain/repository';
import { TokenService } from '../../infrastructure/security';
import { DeviceMetadata } from '../../infrastructure/utils/get-device-meta';
import { FindUserQuery } from '@core/user';

@Injectable()
export class RefreshTokensUseCase {
constructor(
@Inject('ISessionRepository')
private readonly sessionRepo: ISessionRepository,
private readonly tokenService: TokenService,
private readonly findUserCommand: FindOneUserCommand,
private readonly findUserQuery: FindUserQuery,
) {}

async execute(token: string, metadata: DeviceMetadata) {
Expand Down Expand Up @@ -39,7 +39,7 @@ export class RefreshTokensUseCase {
);
}

const { user } = await this.findUserCommand.execute({ id: session.userId });
const { user } = await this.findUserQuery.execute({ id: session.userId });

if (!user) {
await this.sessionRepo.revoke(session.id);
Expand Down
6 changes: 3 additions & 3 deletions src/auth/application/use-cases/reset-password.use-case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { HttpStatus, Injectable } from '@nestjs/common';
import { Queue } from 'bullmq';
import Redis from 'ioredis';
import { generate, generateSecret } from 'otplib';
import { FindOneUserCommand } from '@core/modules/user';
import { BaseException } from '@shared/error';
import { AuthMailJobs, AuthQueues } from '../../domain/enums';
import { ResetPasswordEvent } from '../../domain/events';
import { ResetPasswordDto } from '../dtos';
import { FindUserQuery } from '@core/user';

@Injectable()
export class ResetPasswordUseCase {
Expand All @@ -17,11 +17,11 @@ export class ResetPasswordUseCase {
private readonly redis: Redis,
@InjectQueue(AuthQueues.AUTH_MAIL)
private readonly mailQueue: Queue,
private readonly findUserCommand: FindOneUserCommand,
private readonly findUserQuery: FindUserQuery,
) {}

async execute(dto: ResetPasswordDto) {
const entity = await this.findUserCommand.execute({ email: dto.email });
const entity = await this.findUserQuery.execute({ email: dto.email });

if (!entity.user) {
throw new BaseException(
Expand Down
6 changes: 3 additions & 3 deletions src/auth/application/use-cases/sign-in.use-case.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { HttpStatus, Inject, Injectable } from '@nestjs/common';
import * as argon from 'argon2';
import { FindOneUserCommand } from '@core/modules/user';
import { BaseException } from '@shared/error';
import { ISessionRepository } from '../../domain/repository';
import { TokenService } from '../../infrastructure/security';
import { DeviceMetadata } from '../../infrastructure/utils/get-device-meta';
import { SignInDto } from '../dtos';
import { FindUserQuery } from '@core/user';

@Injectable()
export class SignInUseCase {
constructor(
@Inject('ISessionRepository')
private readonly sessionRepo: ISessionRepository,
private readonly tokenService: TokenService,
private readonly findUserCommand: FindOneUserCommand,
private readonly findUserQuery: FindUserQuery,
) {}

async execute(dto: SignInDto, meta: DeviceMetadata) {
const entities = await this.findUserCommand.execute({ email: dto.email });
const entities = await this.findUserQuery.execute({ email: dto.email });

if (!entities?.user || !entities?.security) {
throw new BaseException(
Expand Down
6 changes: 3 additions & 3 deletions src/auth/application/use-cases/sign-up-verify.use-case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { InjectRedis } from '@nestjs-modules/ioredis';
import { HttpStatus, Inject, Injectable } from '@nestjs/common';
import Redis from 'ioredis';
import { verify as verifyOTP } from 'otplib';
import { CreateUserCommand } from '@core/modules/user';
import { RegisterUserUseCase } from '@core/user';
import { BaseException } from '@shared/error';
import { ISessionRepository } from '../../domain/repository';
import { TokenService } from '../../infrastructure/security';
Expand All @@ -17,7 +17,7 @@ export class SignUpVerifyUseCase {
@Inject('ISessionRepository')
private readonly sessionRepo: ISessionRepository,
private readonly tokenService: TokenService,
private readonly createUserCommand: CreateUserCommand,
private readonly registerUserUseCase: RegisterUserUseCase,
) {}

async execute(dto: VerifyDto, meta: DeviceMetadata) {
Expand Down Expand Up @@ -58,7 +58,7 @@ export class SignUpVerifyUseCase {
);
}

const user = await this.createUserCommand.execute({
const user = await this.registerUserUseCase.execute({
...userData.user,
password: userData.password,
});
Expand Down
6 changes: 3 additions & 3 deletions src/auth/application/use-cases/sign-up.use-case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as argon from 'argon2';
import { Queue } from 'bullmq';
import Redis from 'ioredis';
import { generate, generateSecret } from 'otplib';
import { FindOneUserCommand } from '@core/modules/user';
import { FindUserQuery } from '@core/user';
import { BaseException } from '@shared/error';
import { AuthQueues, AuthMailJobs } from '../../domain/enums';
import { RegisterCodeEvent } from '../../domain/events';
Expand All @@ -18,7 +18,7 @@ export class SignUpUseCase {
private readonly redis: Redis,
@InjectQueue(AuthQueues.AUTH_MAIL)
private readonly mailQueue: Queue,
private readonly findUserCommand: FindOneUserCommand,
private readonly findUserQuery: FindUserQuery,
) {}

async execute(dto: SignUpDto) {
Expand All @@ -37,7 +37,7 @@ export class SignUpUseCase {
);
}

const isExists = await this.findUserCommand.execute({ email: dto.email });
const isExists = await this.findUserQuery.execute({ email: dto.email });

if (isExists) {
throw new BaseException(
Expand Down
2 changes: 1 addition & 1 deletion src/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BullModule } from '@nestjs/bullmq';
import { Module, forwardRef } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { JwtModule } from '@nestjs/jwt';
import { UserModule } from '@core/modules/user';
import { UserModule } from '@core/user';
import { AuthController, AuthRecoveryController } from './application/controller';
import { AuthFacade } from './application/auth.facade';
import {
Expand Down
2 changes: 1 addition & 1 deletion src/auth/infrastructure/security/token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
import { JwtService } from '@nestjs/jwt';
import { ConfigService } from '@nestjs/config';
import type { JwtPayload } from '@shared/types';
import type { User } from '@core/modules/user';
import type { User } from '@core/user';

@Injectable()
export class TokenService {
Expand Down
2 changes: 1 addition & 1 deletion src/modules/teams/repository/teams.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Inject, Logger } from '@nestjs/common';
import { ITeamsRepository } from './teams.repository.interface';
import { DATABASE_SERVICE, DatabaseService } from '@libs/database';
import * as schema from '../entities';
import * as scUsers from '@core/modules/user/entities';
import * as scUsers from '@core/user/infrastructure/persistence/models';
import { and, asc, count, desc, eq, ilike, inArray, isNull, sql } from 'drizzle-orm';

export class TeamsRepository implements ITeamsRepository {
Expand Down
34 changes: 0 additions & 34 deletions src/modules/user/commands/find-one.command.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/modules/user/commands/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/modules/user/controller/index.ts

This file was deleted.

18 changes: 0 additions & 18 deletions src/modules/user/controller/settings.controller.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/modules/user/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/modules/user/repository/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/modules/user/services/index.ts

This file was deleted.

123 changes: 0 additions & 123 deletions src/modules/user/services/user.service.ts

This file was deleted.

Loading
Loading