Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
gamboaalejandro committed Jan 18, 2024
2 parents e1dcb95 + 5acfd91 commit 2e93b53
Show file tree
Hide file tree
Showing 17 changed files with 293 additions and 317 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
# Sound-Space API
Proyecto hecho en TypeScript que sirve como API para una aplicación de streaming de música.

Está realizado con una arquitectura hexagonal, siguiendo los principios de Domain Driven Design.
Está realizado con arquitectura hexagonal, siguiendo los principios de Domain Driven Design.

Modelo de dominio y Arquitectura hexagonal del proyecto en el siguiente link de lucidchart:
https://lucid.app/lucidchart/f9202a4f-fac1-49ae-b385-e59cd17f2d64/edit?viewport_loc=3673%2C-1262%2C4063%2C1857%2CcDu60uZC6Uby&invitationId=inv_7e2b3c3e-ee33-47a9-a8d6-193279445e03

## ¿Cómo funciona el proyecto?

El proyecto consiste en una API que expone varios endpoints para acceder a los servicios de streaming de música. Esta se comunica con una base de datos en la nube (Azure) que almacena la información de las canciones, los artistas, los álbumes, las listas de reproducción, álbumes y los usuarios.
El proyecto consiste en una API que expone varios endpoints para acceder a los servicios de streaming de música. Esta se comunica con una base de datos en la nube (Azure) que almacena la información de las canciones, los artistas, los álbumes, las listas de reproducción y los usuarios.


La estructura de este proyecto sigue una arquitectura hexagonal, donde el núcleo del sistema es el modelo de dominio, que contiene las clases y las interfaces que representan los conceptos del dominio de la música. El modelo de dominio se comunica con el exterior a través de puertos y adaptadores.
Expand Down
17 changes: 6 additions & 11 deletions src/artists/infrastructure/controllers/artist.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ import {
} from 'src/artists/application/services/get-artist-profile.application.service';
import { Artist } from 'src/artists/domain/artist';


import { NestLogger } from 'src/common/infrastructure/logger/nest-logger';
import { DataSourceSingleton } from 'src/common/infrastructure/dataSourceSingleton';
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 @@ -39,15 +38,11 @@ import { ArtistID } from 'src/artists/domain/value-objects/artistID-valueobject'
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 {
AudithApplicationServiceDecorator
} from '../../../common/Application/application-service/decorators/audith.service.decorator';
import {
LoggingApplicationServiceDecorator
} from '../../../common/Application/application-service/decorators/loggin-application.service.decorator';
import {
ErrorApplicationServiceDecorator
} from '../../../common/Application/application-service/decorators/error-application.service.decorator';
import { TrendingArtistsDto } from '../dtos/trendingArtist.dto';
import { AllArtistInfoDto } from '../dtos/allArtistInfo.dto';
import { AudithApplicationServiceDecorator } from '../../../common/Application/application-service/decorators/audith.service.decorator';
import { LoggingApplicationServiceDecorator } from '../../../common/Application/application-service/decorators/loggin-application.service.decorator';
import { ErrorApplicationServiceDecorator } from '../../../common/Application/application-service/decorators/error-application.service.decorator';
@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;
}[];
}
4 changes: 2 additions & 2 deletions src/common/infrastructure/Common.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +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/loggin-application.service.decorator';
import { NestLogger } from './logger/nest-logger';
import { BrowseSongsService } from 'src/songs/application/services/browseSongs.service';
import { Song } from 'src/songs/domain/song';
Expand All @@ -21,6 +19,8 @@ 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';
import { LoggingApplicationServiceDecorator } from '../Application/application-service/decorators/loggin-application.service.decorator';

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.

35 changes: 19 additions & 16 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,28 +23,28 @@ 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 { AudithRepositoryImpl } from 'src/common/infrastructure/repositories/audithRepository.impl';
import { JwtAuthGuard } from 'src/users/application/jwtoken/jwt-auth.guard';
import { JwtService } from '@nestjs/jwt';
import { NestLogger } from 'src/common/infrastructure/logger/nest-logger';
import {
AudithApplicationServiceDecorator
} from '../../../common/Application/application-service/decorators/audith.service.decorator';
import {
LoggingApplicationServiceDecorator
} from '../../../common/Application/application-service/decorators/loggin-application.service.decorator';
import { TopPlaylistDto } from '../dtos/topPlaylistDto';
import { PlaylistDto } from '../dtos/playlistDto';
import { TopAlbumsDto } from '../dtos/topAlbumsDto';
import { SongDto } from 'src/songs/infrastructure/dtos/Song.dto';
import { AudithApplicationServiceDecorator } from 'src/common/Application/application-service/decorators/audith.service.decorator';
import { LoggingApplicationServiceDecorator } from 'src/common/Application/application-service/decorators/loggin-application.service.decorator';
@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 @@ -106,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
27 changes: 15 additions & 12 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 @@ -31,21 +38,17 @@ import { AudithRepositoryImpl } from 'src/common/infrastructure/repositories/aud
import { JwtService } from '@nestjs/jwt';
import { JwtAuthGuard } from 'src/users/application/jwtoken/jwt-auth.guard';
import { NestLogger } from 'src/common/infrastructure/logger/nest-logger';
import {
AudithApplicationServiceDecorator
} from '../../../common/Application/application-service/decorators/audith.service.decorator';
import {
LoggingApplicationServiceDecorator
} from '../../../common/Application/application-service/decorators/loggin-application.service.decorator';
import { TopPlaylistDto } from '../dtos/topPlaylistDto';
import { PlaylistDto } from '../dtos/playlistDto';
import { SongDto } from 'src/songs/infrastructure/dtos/Song.dto';
import { AudithApplicationServiceDecorator } from 'src/common/Application/application-service/decorators/audith.service.decorator';
import { LoggingApplicationServiceDecorator } from 'src/common/Application/application-service/decorators/loggin-application.service.decorator';
@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 @@ -140,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 2e93b53

Please sign in to comment.