Skip to content

Commit

Permalink
placing dtos in each module
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisGil11 committed Jan 18, 2024
1 parent b387796 commit e516b9c
Show file tree
Hide file tree
Showing 15 changed files with 271 additions and 285 deletions.
4 changes: 3 additions & 1 deletion src/artists/infrastructure/controllers/artist.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { DataSourceSingleton } from 'src/common/infrastructure/dataSourceSinglet
import { GetAllArtistsApplicationService } from 'src/artists/application/services/get-all-artists.application.service';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { GetTrendingArtistsService } from 'src/artists/application/services/FindTrendingArtists.service';
import { AllArtistInfoDto, TrendingArtistsDto } from 'src/dtos';

import { OrmSongRepository } from 'src/songs/infrastructure/repositories/song.repository.impl';
import { Song } from 'src/songs/domain/song';
import {
Expand All @@ -40,6 +40,8 @@ import { AudithApplicationServiceDecorator } from 'src/common/Application/applic
import { AudithRepositoryImpl } from 'src/common/infrastructure/repositories/audithRepository.impl';
import { JwtService } from '@nestjs/jwt';
import { JwtAuthGuard } from 'src/users/application/jwtoken/jwt-auth.guard';
import { TrendingArtistsDto } from '../dtos/trendingArtist.dto';
import { AllArtistInfoDto } from '../dtos/allArtistInfo.dto';
@ApiBearerAuth()
@Controller('api/artist')
export class ArtistController {
Expand Down
13 changes: 13 additions & 0 deletions src/artists/infrastructure/dtos/allArtistInfo.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { SongDto } from 'src/songs/infrastructure/dtos/Song.dto';

export class AllArtistInfoDto {
id: string;
name: string;
image: Buffer;
genre: string;
albums: {
id: string;
image: Buffer;
}[];
songs: SongDto[];
}
7 changes: 7 additions & 0 deletions src/artists/infrastructure/dtos/trendingArtist.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export class TrendingArtistsDto {
artists: {
id: string;
name: string;
image: Buffer;
}[];
}
2 changes: 1 addition & 1 deletion src/common/infrastructure/Common.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { PlaylistRepository } from 'src/playlist/infrastructure/PlaylistReposito
import { Controller, Get, Param } from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { Result } from '../domain/logic/Result';
import { PlaylistDto, SongDto } from 'src/dtos';
import { LoggingApplicationServiceDecorator } from '../Application/application-service/decorators/error-decorator/loggin-application.service.decorator';
import { NestLogger } from './logger/nest-logger';
import { BrowseSongsService } from 'src/songs/application/services/browseSongs.service';
Expand All @@ -21,6 +20,7 @@ import { Playlist } from 'src/playlist/domain/playlist';
import { MyResponse } from './Response';
import { PaginationDto } from './Dtos/pagination.dto';
import { ArtistID } from 'src/artists/domain/value-objects/artistID-valueobject';
import { SongDto } from 'src/songs/infrastructure/dtos/Song.dto';

export class QueryDto {
artists?: { id: string; name: string; image: Buffer }[];
Expand Down
92 changes: 0 additions & 92 deletions src/dtos.ts

This file was deleted.

27 changes: 17 additions & 10 deletions src/playlist/infrastructure/controllers/album.controller.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { Controller, Get, Param, ParseUUIDPipe, Req, UseGuards } from '@nestjs/common';
import {
Controller,
Get,
Param,
ParseUUIDPipe,
Req,
UseGuards,
} from '@nestjs/common';
import { Playlist } from 'src/playlist/domain/playlist';
import { PlaylistRepository } from '../PlaylistRepository.impl';
import { DataSourceSingleton } from 'src/common/infrastructure/dataSourceSingleton';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { OrmSongRepository } from 'src/songs/infrastructure/repositories/song.repository.impl';
import { PlaylistDto, SongDto, TopAlbumsDto, TopPlaylistDto } from 'src/dtos';
import { FindTopAlbumsService } from 'src/playlist/application/services/FindTopAlbums.service';
import { Result } from 'src/common/domain/logic/Result';
import { MyResponse } from 'src/common/infrastructure/Response';
Expand All @@ -17,7 +23,10 @@ import { FindArtistsInCollectionService } from 'src/artists/application/services
import { OrmArtistRepository } from 'src/artists/infrastructure/repositories/artist.repository.impl';
import { Artist } from 'src/artists/domain/artist';
import { Song } from 'src/songs/domain/song';
import { FindAlbumByIDService, FindAlbumByIDServiceDto } from 'src/playlist/application/services/FindAlbumByID.service';
import {
FindAlbumByIDService,
FindAlbumByIDServiceDto,
} from 'src/playlist/application/services/FindAlbumByID.service';
import { SongID } from 'src/songs/domain/value-objects/SongID-valueobject';
import { PlaylistID } from 'src/playlist/domain/value-objects/PlaylistID-valueobject';
import { AudithApplicationServiceDecorator } from 'src/common/Application/application-service/decorators/error-decorator/audith.service.decorator';
Expand All @@ -26,15 +35,16 @@ import { JwtAuthGuard } from 'src/users/application/jwtoken/jwt-auth.guard';
import { JwtService } from '@nestjs/jwt';
import { LoggingApplicationServiceDecorator } from 'src/common/Application/application-service/decorators/error-decorator/loggin-application.service.decorator';
import { NestLogger } from 'src/common/infrastructure/logger/nest-logger';
import { TopPlaylistDto } from '../dtos/topPlaylistDto';
import { PlaylistDto } from '../dtos/playlistDto';
import { TopAlbumsDto } from '../dtos/topAlbumsDto';
import { SongDto } from 'src/songs/infrastructure/dtos/Song.dto';
@ApiBearerAuth()
@Controller('api/album')
export class AlbumController {
private repository: PlaylistRepository;
private songRepository: OrmSongRepository;
private artistsRepository: OrmArtistRepository;
private findTopAlbumsService: FindTopAlbumsService;
private findAlbumByIDService: FindAlbumByIDService;
private findPlaylistByIdService: FindAlbumByPlaylistIDService;
private findSongsInCollectionService: GetSongsInCollectionService;
private findArtistsInCollectionService: FindArtistsInCollectionService;
private audithRepo: AudithRepositoryImpl;
Expand Down Expand Up @@ -102,10 +112,7 @@ export class AlbumController {
const userid = await this.jwtService.decode(token).id;
const service = new AudithApplicationServiceDecorator(
new LoggingApplicationServiceDecorator(
new FindAlbumByIDService(
this.repository,
this.songRepository,
),
new FindAlbumByIDService(this.repository, this.songRepository),
new NestLogger(),
),
this.audithRepo,
Expand Down
19 changes: 13 additions & 6 deletions src/playlist/infrastructure/controllers/playlist.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { Controller, Get, Inject, Param, ParseUUIDPipe, Req, UseGuards } from '@nestjs/common';
import {
Controller,
Get,
Inject,
Param,
ParseUUIDPipe,
Req,
UseGuards,
} from '@nestjs/common';
import {
FindAlbumByArtistIDService,
FindAlbumByArtistIDServiceDto,
Expand All @@ -13,7 +21,6 @@ import { DataSourceSingleton } from 'src/common/infrastructure/dataSourceSinglet
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { OrmSongRepository } from 'src/songs/infrastructure/repositories/song.repository.impl';
import { FindTopPlaylistsService } from 'src/playlist/application/services/FindTopPlaylists.service';
import { PlaylistDto, SongDto, TopPlaylistDto } from 'src/dtos';
import { Artist } from 'src/artists/domain/artist';
import {
GetSongsInCollectionService,
Expand All @@ -33,15 +40,15 @@ import { JwtService } from '@nestjs/jwt';
import { JwtAuthGuard } from 'src/users/application/jwtoken/jwt-auth.guard';
import { LoggingApplicationServiceDecorator } from 'src/common/Application/application-service/decorators/error-decorator/loggin-application.service.decorator';
import { NestLogger } from 'src/common/infrastructure/logger/nest-logger';
import { TopPlaylistDto } from '../dtos/topPlaylistDto';
import { PlaylistDto } from '../dtos/playlistDto';
import { SongDto } from 'src/songs/infrastructure/dtos/Song.dto';
@ApiBearerAuth()
@Controller('api/playlist')
export class PlaylistController {
private repository: PlaylistRepository;
private songRepository: OrmSongRepository;
private artistsRepository: OrmArtistRepository;
private findPlaylistByIdService: FindAlbumByPlaylistIDService;
private findPlaylistByArtistIdService: FindAlbumByArtistIDService;
private findTopPlaylistsService: FindTopPlaylistsService;
private findSongsInCollectionService: GetSongsInCollectionService;
private findArtistsInCollectionService: FindArtistsInCollectionService;
private audithRepo: AudithRepositoryImpl;
Expand Down Expand Up @@ -136,7 +143,7 @@ export class PlaylistController {
const service = new AudithApplicationServiceDecorator(
new LoggingApplicationServiceDecorator(
new FindAlbumByPlaylistIDService(this.repository, this.songRepository),
new NestLogger()
new NestLogger(),
),
this.audithRepo,
userid,
Expand Down
14 changes: 14 additions & 0 deletions src/playlist/infrastructure/dtos/playlistDto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { SongDto } from 'src/songs/infrastructure/dtos/Song.dto';

export class PlaylistDto {
id: string;
name: string;
duration: string;
image: Buffer;
streams: number;
creators?: {
creatorId: string;
creatorName: string;
}[];
songs: SongDto[];
}
6 changes: 6 additions & 0 deletions src/playlist/infrastructure/dtos/topAlbumsDto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class TopAlbumsDto {
playlists: {
id: string;
image: Buffer;
}[];
}
6 changes: 6 additions & 0 deletions src/playlist/infrastructure/dtos/topPlaylistDto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export class TopPlaylistDto {
playlists: {
id: string;
image: Buffer;
}[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { OrmPromotionRepository } from '../Repositories/promotion.repository.imp
import { GetFileService } from 'src/common/infrastructure/services/getFile.service';
import { DataSourceSingleton } from 'src/common/infrastructure/dataSourceSingleton';
import { ApiTags } from '@nestjs/swagger';
import { PromotionDto } from 'src/dtos';
import { FindRandomPromotionsService } from 'src/promotions/application/services/FindRandomPromotion.service';
import { Result } from 'src/common/domain/logic/Result';
import { MyResponse } from 'src/common/infrastructure/Response';
import { PromoID } from 'src/promotions/domain/value-objects/PromoID-valueobject';
import { PromotionDto } from '../dtos/PromotionDto';

@Controller('api/promotion')
export class PromotionsController {
Expand Down
4 changes: 4 additions & 0 deletions src/promotions/infrastructure/dtos/PromotionDto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export class PromotionDto {
id: string;
image: Buffer;
}
Loading

0 comments on commit e516b9c

Please sign in to comment.