mirror of
https://gitlab.com/mobicoop/v3/service/ad.git
synced 2026-03-15 17:45:50 +00:00
move libs to dedicated package
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Mapper } from '@libs/ddd';
|
||||
import { Mapper } from '@mobicoop/ddd-library';
|
||||
import { AdResponseDto } from './interface/dtos/ad.response.dto';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { AdEntity } from './core/domain/ad.entity';
|
||||
|
||||
@@ -18,12 +18,12 @@ import { MessagePublisher } from './infrastructure/message-publisher';
|
||||
import { AdMapper } from './ad.mapper';
|
||||
import { CreateAdService } from './core/application/commands/create-ad/create-ad.service';
|
||||
import { TimezoneFinder } from './infrastructure/timezone-finder';
|
||||
import { PrismaService } from '@libs/db/prisma.service';
|
||||
import { TimeConverter } from './infrastructure/time-converter';
|
||||
import { FindAdByIdGrpcController } from './interface/grpc-controllers/find-ad-by-id.grpc.controller';
|
||||
import { FindAdByIdQueryHandler } from './core/application/queries/find-ad-by-id/find-ad-by-id.query-handler';
|
||||
import { PublishMessageWhenAdIsCreatedDomainEventHandler } from './core/application/event-handlers/publish-message-when-ad-is-created.domain-event-handler';
|
||||
import { PublishLogMessageWhenAdIsCreatedDomainEventHandler } from './core/application/event-handlers/publish-log-message-when-ad-is-created.domain-event-handler';
|
||||
import { PrismaService } from './infrastructure/prisma.service';
|
||||
|
||||
const grpcControllers = [CreateAdGrpcController, FindAdByIdGrpcController];
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Command, CommandProps } from '@libs/ddd';
|
||||
import { Schedule } from '../../types/schedule';
|
||||
import { MarginDurations } from '../../types/margin-durations';
|
||||
import { Waypoint } from '../../types/waypoint';
|
||||
import { Frequency } from '@modules/ad/core/domain/ad.types';
|
||||
import { Command, CommandProps } from '@mobicoop/ddd-library';
|
||||
|
||||
export class CreateAdCommand extends Command {
|
||||
readonly userId: string;
|
||||
|
||||
@@ -2,14 +2,13 @@ import { CommandHandler, ICommandHandler } from '@nestjs/cqrs';
|
||||
import { CreateAdCommand } from './create-ad.command';
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { AD_REPOSITORY, PARAMS_PROVIDER } from '@modules/ad/ad.di-tokens';
|
||||
import { AggregateID } from '@libs/ddd';
|
||||
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
||||
import { ConflictException } from '@libs/exceptions';
|
||||
import { Waypoint } from '../../types/waypoint';
|
||||
import { DefaultParams } from '../../ports/default-params.type';
|
||||
import { AdRepositoryPort } from '../../ports/ad.repository.port';
|
||||
import { DefaultParamsProviderPort } from '../../ports/default-params-provider.port';
|
||||
import { AdAlreadyExistsException } from '@modules/ad/core/domain/ad.errors';
|
||||
import { AggregateID, ConflictException } from '@mobicoop/ddd-library';
|
||||
|
||||
@CommandHandler(CreateAdCommand)
|
||||
export class CreateAdService implements ICommandHandler {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { MessagePublisherPort } from '@libs/ports/message-publisher.port';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { MESSAGE_PUBLISHER } from '@src/app.constants';
|
||||
import { AdCreatedDomainEvent } from '../../domain/events/ad-created.domain-events';
|
||||
import { MessagePublisherPort } from '@mobicoop/ddd-library';
|
||||
|
||||
@Injectable()
|
||||
export class PublishLogMessageWhenAdIsCreatedDomainEventHandler {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { MessagePublisherPort } from '@libs/ports/message-publisher.port';
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { OnEvent } from '@nestjs/event-emitter';
|
||||
import { MESSAGE_PUBLISHER } from '@src/app.constants';
|
||||
import { AdCreatedDomainEvent } from '../../domain/events/ad-created.domain-events';
|
||||
import { MessagePublisherPort } from '@mobicoop/ddd-library';
|
||||
|
||||
@Injectable()
|
||||
export class PublishMessageWhenAdIsCreatedDomainEventHandler {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RepositoryPort } from '@libs/ddd';
|
||||
import { RepositoryPort } from '@mobicoop/ddd-library';
|
||||
import { AdEntity } from '../../domain/ad.entity';
|
||||
|
||||
export type AdRepositoryPort = RepositoryPort<AdEntity>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { QueryBase } from '@libs/ddd/query.base';
|
||||
import { QueryBase } from '@mobicoop/ddd-library';
|
||||
|
||||
export class FindAdByIdQuery extends QueryBase {
|
||||
readonly id: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AggregateRoot, AggregateID } from '@libs/ddd';
|
||||
import { AggregateRoot, AggregateID } from '@mobicoop/ddd-library';
|
||||
import { v4 } from 'uuid';
|
||||
import { AdCreatedDomainEvent } from './events/ad-created.domain-events';
|
||||
import { AdProps, CreateAdProps, DefaultAdProps } from './ad.types';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ExceptionBase } from '@libs/exceptions';
|
||||
import { ExceptionBase } from '@mobicoop/ddd-library';
|
||||
|
||||
export class AdAlreadyExistsException extends ExceptionBase {
|
||||
static readonly message = 'Ad already exists';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DomainEvent, DomainEventProps } from '@libs/ddd';
|
||||
import { DomainEvent, DomainEventProps } from '@mobicoop/ddd-library';
|
||||
|
||||
export class AdCreatedDomainEvent extends DomainEvent {
|
||||
readonly userId: string;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ValueObject } from '@libs/ddd';
|
||||
import { ValueObject } from '@mobicoop/ddd-library';
|
||||
import { CoordinatesProps } from './coordinates.value-object';
|
||||
|
||||
/** Note:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ValueObject } from '@libs/ddd';
|
||||
import { ValueObject } from '@mobicoop/ddd-library';
|
||||
|
||||
/** Note:
|
||||
* Value Objects with multiple properties can contain
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ValueObject } from '@libs/ddd';
|
||||
import { ValueObject } from '@mobicoop/ddd-library';
|
||||
|
||||
/** Note:
|
||||
* Value Objects with multiple properties can contain
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ValueObject } from '@libs/ddd';
|
||||
import { ValueObject } from '@mobicoop/ddd-library';
|
||||
|
||||
/** Note:
|
||||
* Value Objects with multiple properties can contain
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ValueObject } from '@libs/ddd';
|
||||
import { ValueObject } from '@mobicoop/ddd-library';
|
||||
import { AddressProps } from './address.value-object';
|
||||
|
||||
/** Note:
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { AdEntity } from '../core/domain/ad.entity';
|
||||
import { PrismaService } from '@libs/db/prisma.service';
|
||||
import { AdMapper } from '../ad.mapper';
|
||||
import { PrismaRepositoryBase } from '@libs/db/prisma-repository.base';
|
||||
import { AdRepositoryPort } from '../core/application/ports/ad.repository.port';
|
||||
import { PrismaRepositoryBase } from '@mobicoop/ddd-library';
|
||||
import { PrismaService } from './prisma.service';
|
||||
|
||||
export type AdBaseModel = {
|
||||
uuid: string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { MessageBrokerPublisher } from '@mobicoop/message-broker-module';
|
||||
import { MESSAGE_BROKER_PUBLISHER } from '@src/app.constants';
|
||||
import { MessagePublisherPort } from '@libs/ports/message-publisher.port';
|
||||
import { MessagePublisherPort } from '@mobicoop/ddd-library';
|
||||
|
||||
@Injectable()
|
||||
export class MessagePublisher implements MessagePublisherPort {
|
||||
|
||||
15
src/modules/ad/infrastructure/prisma.service.ts
Normal file
15
src/modules/ad/infrastructure/prisma.service.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
@Injectable()
|
||||
export class PrismaService extends PrismaClient implements OnModuleInit {
|
||||
async onModuleInit() {
|
||||
await this.$connect();
|
||||
}
|
||||
|
||||
async enableShutdownHooks(app: INestApplication) {
|
||||
this.$on('beforeExit', async () => {
|
||||
await app.close();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { PaginatedResponseDto } from '@libs/api/paginated.response.base';
|
||||
import { PaginatedResponseDto } from '@mobicoop/ddd-library';
|
||||
import { AdResponseDto } from './ad.response.dto';
|
||||
|
||||
export class AdPaginatedResponseDto extends PaginatedResponseDto<AdResponseDto> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ResponseBase } from '@libs/api/response.base';
|
||||
import { ResponseBase } from '@mobicoop/ddd-library';
|
||||
import { Frequency } from '@modules/ad/core/domain/ad.types';
|
||||
|
||||
export class AdResponseDto extends ResponseBase {
|
||||
|
||||
@@ -2,10 +2,10 @@ import { Controller, UsePipes } from '@nestjs/common';
|
||||
import { CommandBus } from '@nestjs/cqrs';
|
||||
import { GrpcMethod, RpcException } from '@nestjs/microservices';
|
||||
import { CreateAdRequestDto } from './dtos/create-ad.request.dto';
|
||||
import { AggregateID } from '@libs/ddd';
|
||||
import { IdResponse } from '@libs/api/id.response.dto';
|
||||
import { RpcExceptionCode } from '@libs/exceptions/rpc-exception.codes.enum';
|
||||
import { RpcValidationPipe } from '@libs/utils/pipes/rpc.validation-pipe';
|
||||
import { AggregateID } from '@mobicoop/ddd-library';
|
||||
import { IdResponse } from '@mobicoop/ddd-library';
|
||||
import { RpcExceptionCode } from '@mobicoop/ddd-library';
|
||||
import { RpcValidationPipe } from '@mobicoop/ddd-library';
|
||||
import { CreateAdCommand } from '@modules/ad/core/application/commands/create-ad/create-ad.command';
|
||||
import { AdAlreadyExistsException } from '@modules/ad/core/domain/ad.errors';
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ import { FindAdByIdQuery } from '@modules/ad/core/application/queries/find-ad-by
|
||||
import { AdResponseDto } from '../dtos/ad.response.dto';
|
||||
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
||||
import { AdMapper } from '@modules/ad/ad.mapper';
|
||||
import { NotFoundException } from '@libs/exceptions';
|
||||
import { RpcExceptionCode } from '@libs/exceptions/rpc-exception.codes.enum';
|
||||
import { RpcValidationPipe } from '@libs/utils/pipes/rpc.validation-pipe';
|
||||
import { NotFoundException } from '@mobicoop/ddd-library';
|
||||
import { RpcExceptionCode } from '@mobicoop/ddd-library';
|
||||
import { RpcValidationPipe } from '@mobicoop/ddd-library';
|
||||
|
||||
@UsePipes(
|
||||
new RpcValidationPipe({
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { PrismaService } from '@libs/db/prisma.service';
|
||||
import {
|
||||
AD_REPOSITORY,
|
||||
PARAMS_PROVIDER,
|
||||
@@ -8,6 +7,7 @@ import {
|
||||
import { AdMapper } from '@modules/ad/ad.mapper';
|
||||
import { AdRepository } from '@modules/ad/infrastructure/ad.repository';
|
||||
import { DefaultParamsProvider } from '@modules/ad/infrastructure/default-params-provider';
|
||||
import { PrismaService } from '@modules/ad/infrastructure/prisma.service';
|
||||
import { TimeConverter } from '@modules/ad/infrastructure/time-converter';
|
||||
import { TimezoneFinder } from '@modules/ad/infrastructure/timezone-finder';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
|
||||
@@ -2,9 +2,9 @@ import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AD_REPOSITORY, PARAMS_PROVIDER } from '@modules/ad/ad.di-tokens';
|
||||
import { WaypointDto } from '@modules/ad/interface/grpc-controllers/dtos/waypoint.dto';
|
||||
import { CreateAdRequestDto } from '@modules/ad/interface/grpc-controllers/dtos/create-ad.request.dto';
|
||||
import { AggregateID } from '@libs/ddd';
|
||||
import { AggregateID } from '@mobicoop/ddd-library';
|
||||
import { AdEntity } from '@modules/ad/core/domain/ad.entity';
|
||||
import { ConflictException } from '@libs/exceptions';
|
||||
import { ConflictException } from '@mobicoop/ddd-library';
|
||||
import { Frequency } from '@modules/ad/core/domain/ad.types';
|
||||
import { DefaultParamsProviderPort } from '@modules/ad/core/application/ports/default-params-provider.port';
|
||||
import { CreateAdService } from '@modules/ad/core/application/commands/create-ad/create-ad.service';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { PrismaService } from '@libs/db/prisma.service';
|
||||
import {
|
||||
PARAMS_PROVIDER,
|
||||
TIMEZONE_FINDER,
|
||||
@@ -9,6 +8,7 @@ import { DefaultParamsProviderPort } from '@modules/ad/core/application/ports/de
|
||||
import { TimeConverterPort } from '@modules/ad/core/application/ports/time-converter.port';
|
||||
import { TimezoneFinderPort } from '@modules/ad/core/application/ports/timezone-finder.port';
|
||||
import { AdRepository } from '@modules/ad/infrastructure/ad.repository';
|
||||
import { PrismaService } from '@modules/ad/infrastructure/prisma.service';
|
||||
import { EventEmitter2, EventEmitterModule } from '@nestjs/event-emitter';
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { IdResponse } from '@libs/api/id.response.dto';
|
||||
import { RpcExceptionCode } from '@libs/exceptions/rpc-exception.codes.enum';
|
||||
import { IdResponse } from '@mobicoop/ddd-library';
|
||||
import { RpcExceptionCode } from '@mobicoop/ddd-library';
|
||||
import { AdAlreadyExistsException } from '@modules/ad/core/domain/ad.errors';
|
||||
import { Frequency } from '@modules/ad/core/domain/ad.types';
|
||||
import { CreateAdGrpcController } from '@modules/ad/interface/grpc-controllers/create-ad.grpc.controller';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NotFoundException } from '@libs/exceptions';
|
||||
import { RpcExceptionCode } from '@libs/exceptions/rpc-exception.codes.enum';
|
||||
import { NotFoundException } from '@mobicoop/ddd-library';
|
||||
import { RpcExceptionCode } from '@mobicoop/ddd-library';
|
||||
import { AdMapper } from '@modules/ad/ad.mapper';
|
||||
import { Frequency } from '@modules/ad/core/domain/ad.types';
|
||||
import { FindAdByIdGrpcController } from '@modules/ad/interface/grpc-controllers/find-ad-by-id.grpc.controller';
|
||||
|
||||
@@ -10,7 +10,7 @@ import { AD_REPOSITORY } from '@modules/health/health.di-tokens';
|
||||
import { AdRepositoryPort } from '@modules/ad/core/application/ports/ad.repository.port';
|
||||
import { MESSAGE_PUBLISHER } from '@src/app.constants';
|
||||
import { LOGGING_AD_HEALTH_CRIT } from '@modules/health/health.constants';
|
||||
import { MessagePublisherPort } from '@libs/ports/message-publisher.port';
|
||||
import { MessagePublisherPort } from '@mobicoop/ddd-library';
|
||||
|
||||
@Injectable()
|
||||
export class RepositoriesHealthIndicatorUseCase extends HealthIndicator {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { MESSAGE_BROKER_PUBLISHER } from '../../../app.constants';
|
||||
import { MessageBrokerPublisher } from '@mobicoop/message-broker-module';
|
||||
import { MessagePublisherPort } from '@libs/ports/message-publisher.port';
|
||||
import { MessagePublisherPort } from '@mobicoop/ddd-library';
|
||||
|
||||
@Injectable()
|
||||
export class MessagePublisher implements MessagePublisherPort {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { HealthCheckError, HealthIndicatorResult } from '@nestjs/terminus';
|
||||
import { RepositoriesHealthIndicatorUseCase } from '../../core/aplication/usecases/repositories.health-indicator.usecase';
|
||||
import { AD_REPOSITORY } from '@modules/health/health.di-tokens';
|
||||
import { MESSAGE_PUBLISHER } from '@src/app.constants';
|
||||
import { DatabaseErrorException } from '@libs/exceptions';
|
||||
import { DatabaseErrorException } from '@mobicoop/ddd-library';
|
||||
|
||||
const mockAdRepository = {
|
||||
healthCheck: jest
|
||||
|
||||
Reference in New Issue
Block a user