Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master-migration #106

Merged
merged 224 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
224 commits
Select commit Hold shift + click to select a range
a7c365e
feat : add post song using AWS
AntonioMrtz Oct 8, 2023
a60c593
feat : add delete song endpoint with aws
AntonioMrtz Oct 8, 2023
7885ed8
chore : delete prints
AntonioMrtz Oct 8, 2023
f9ab0a4
feat : add get cancion con aws
AntonioMrtz Oct 8, 2023
e14672d
chore : update collection to songCollection in DTOSong
AntonioMrtz Oct 8, 2023
bcbb8ed
feat : add streaming support frontend for songs
AntonioMrtz Oct 8, 2023
f955513
test : disable aws song tests
AntonioMrtz Oct 9, 2023
79af899
chore : change token expire time to 7 days
AntonioMrtz Oct 9, 2023
7782b13
fix : gap show all now is 14px
AntonioMrtz Oct 9, 2023
14ddd80
feat : mostrarTodo user playlists
AntonioMrtz Oct 9, 2023
0be4004
feat :add ShowAllSongsFromArtist fix ShowAllPlaylist
AntonioMrtz Oct 9, 2023
8e52e43
feat : add mostrarTodo button UserProfile
AntonioMrtz Oct 9, 2023
261b734
chore : update requirements python
AntonioMrtz Oct 9, 2023
d4de6db
Merge pull request #82 from AntonioMrtz/feat/MostrarTodoUserArtistPro…
AntonioMrtz Oct 9, 2023
350fd93
chore : add distribution_id of cloudfront as env variable
AntonioMrtz Oct 9, 2023
411d04e
test : use song database service on tests
AntonioMrtz Oct 9, 2023
e78b3a2
chore : add github actions env variable for DISTRIBUTION_ID
AntonioMrtz Oct 9, 2023
3c47892
Merge pull request #83 from AntonioMrtz/test/DatabaseSongsForTesting
AntonioMrtz Oct 9, 2023
d82d9c8
fix : userprofile for artist fix canciones del artista header
AntonioMrtz Oct 9, 2023
2c38ee2
fix : reduce Playlist>Song artist hitbox
AntonioMrtz Oct 9, 2023
f918362
fix : reduce cards artist hitbox
AntonioMrtz Oct 9, 2023
1ca3198
feat : make SongCard use cards style and add clickable artist
AntonioMrtz Oct 9, 2023
80ac8de
fix : delete empty onContextMenu SongCard
AntonioMrtz Oct 10, 2023
268ef40
fix : add repeat song increases play count by 1
AntonioMrtz Oct 10, 2023
ba04c55
fix : disable song still playing while logout and play 2 songs at sam…
AntonioMrtz Oct 10, 2023
66266c0
fix : alt text of image cards
AntonioMrtz Oct 10, 2023
8135367
fix : no anidated button inside SongCard
AntonioMrtz Oct 10, 2023
3fd125e
fix : modified path of mui imports
AntonioMrtz Oct 10, 2023
f6fd1a6
test : add test StartMenu
AntonioMrtz Oct 11, 2023
6d95d46
chore : add github actions frontend tests
AntonioMrtz Oct 11, 2023
7b9bf73
test : add RegisterMenu tests
AntonioMrtz Oct 12, 2023
98a5221
test : add UserProfile tests
AntonioMrtz Oct 12, 2023
d8c754a
test : add Home tests
AntonioMrtz Oct 12, 2023
59f6aee
test : increase coverage Home test with mock fetchs
AntonioMrtz Oct 12, 2023
306f391
test : increase coverage UserProfile tests
AntonioMrtz Oct 12, 2023
f6e0590
test : add App tests
AntonioMrtz Oct 13, 2023
cc50471
test : add Genre tests
AntonioMrtz Oct 13, 2023
ddcf4af
test : add Explorar tests
AntonioMrtz Oct 13, 2023
b768346
file : move pages tests to their own folder
AntonioMrtz Oct 13, 2023
606ffe9
file : move componentes/ to components/
AntonioMrtz Oct 13, 2023
77bf20e
file : move componentes/ to components/
AntonioMrtz Oct 13, 2023
f6237a7
file : delete tech docs
AntonioMrtz Oct 13, 2023
defe9f1
file : delete tech docs
AntonioMrtz Oct 13, 2023
ac43de7
fix : add mock scrollto in App tests
AntonioMrtz Oct 13, 2023
db47ce5
test : add Playlist tests
AntonioMrtz Oct 13, 2023
feae107
file : move apptest to __tests__/renderer/
AntonioMrtz Oct 13, 2023
664badd
test : add Sticky Header tests
AntonioMrtz Oct 14, 2023
d826c03
chore : fix typo
AntonioMrtz Oct 14, 2023
28ced1d
test : add ItemsAllArtist tests
AntonioMrtz Oct 14, 2023
ed47537
test : add ItemsAllPlaylist test
AntonioMrtz Oct 14, 2023
9e07bcb
fix : typo error add .test to test files
AntonioMrtz Oct 14, 2023
db7e915
test : add ItemsAllSong tests
AntonioMrtz Oct 14, 2023
b23efdb
fix : add expect statement according to Cards content in Items
AntonioMrtz Oct 14, 2023
3066907
fix : test name error
AntonioMrtz Oct 14, 2023
05e94e2
test : add ItemsAllPlaylistFromUser tests
AntonioMrtz Oct 14, 2023
6b689d7
test : add Sidebar tests
AntonioMrtz Oct 16, 2023
14b0809
test : add Sidebaer>Playlist tests
AntonioMrtz Oct 16, 2023
b382cb1
test : add AddSongPlaylistAccordion tests
AntonioMrtz Oct 16, 2023
5752387
test : add Token tests
AntonioMrtz Oct 16, 2023
13d9724
test : add Footer tests
AntonioMrtz Oct 16, 2023
b6bc38a
test : add SongInfo tests
AntonioMrtz Oct 16, 2023
31b48ab
test : add SongConfig & VolumeSlider tests
AntonioMrtz Oct 16, 2023
d71975b
test : add ContextMenuSong
AntonioMrtz Oct 16, 2023
c7cc6e9
test : draft player test
AntonioMrtz Oct 17, 2023
04c8339
Create Procfile
AntonioMrtz Oct 17, 2023
014d46a
Update Procfile
AntonioMrtz Oct 17, 2023
0bd4e48
Delete Backend API/Procfile
AntonioMrtz Oct 17, 2023
308c0c2
file : Update Procfile
AntonioMrtz Oct 17, 2023
fe38253
feat : add Dockerfile deploy Backend
AntonioMrtz Oct 17, 2023
c6f42f7
fix : add SECRET_KEY_SIGN env variable to example Dockerfile run
AntonioMrtz Oct 17, 2023
278be0a
fix : fix typo
AntonioMrtz Oct 17, 2023
72f2865
test : add Player tests
AntonioMrtz Oct 18, 2023
eb49685
test : add ContextMenuPlaylist tests
AntonioMrtz Oct 18, 2023
c0081f7
Merge branch 'master-streaming' of https://github.com/AntonioMrtz/Spo…
AntonioMrtz Oct 18, 2023
253cdc7
Merge pull request #86 from AntonioMrtz/test/ReactTesting
AntonioMrtz Oct 18, 2023
cc6b155
chore : delete prints on ContextMenuPlaylist tests
AntonioMrtz Oct 18, 2023
6577e41
chore : add type input cloudfront input
AntonioMrtz Oct 18, 2023
0ac88d3
feat : add Lambda AWS API
AntonioMrtz Oct 18, 2023
59215ef
fix : interceptor react gets latest cookie on fetch
AntonioMrtz Oct 18, 2023
8633f3e
fix : remove artist field fetch create song
AntonioMrtz Oct 18, 2023
6435e36
docs : update env.example with lambda_backend
AntonioMrtz Oct 18, 2023
1153caa
fix : lambda function stores and deletes correctly
AntonioMrtz Oct 19, 2023
31daf9a
fix : adapt to backend Python and clean comments
AntonioMrtz Oct 19, 2023
4a83751
feat : song service now uses AWSLambda correctly
AntonioMrtz Oct 19, 2023
2abe140
chore : add request module to requirements
AntonioMrtz Oct 19, 2023
9037a55
fix : interceptor react gets latest cookie on fetch
AntonioMrtz Oct 18, 2023
67322f0
fix : remove artist field fetch create song
AntonioMrtz Oct 18, 2023
929e7f6
Merge pull request #87 from AntonioMrtz/feat/SongStreamingUsingLambdaAWS
AntonioMrtz Oct 19, 2023
7746d73
docs : add tests to contributing
AntonioMrtz Oct 19, 2023
72cffe0
docs : update readme with frontend tests and how to docker
AntonioMrtz Oct 19, 2023
c35c11d
chore : update docker comments
AntonioMrtz Oct 19, 2023
b479962
style : format lamda_function style
AntonioMrtz Oct 19, 2023
234e46e
file : delete songservice and api_test_song with database storage
AntonioMrtz Oct 20, 2023
96af545
file : deleted unsued streaming methods
AntonioMrtz Oct 20, 2023
a285346
feat : add api test song
AntonioMrtz Oct 20, 2023
de8870b
feat : adapt mdoules to use streaming lambda song service
AntonioMrtz Oct 20, 2023
8e23831
fix : indentation error solved
AntonioMrtz Oct 20, 2023
4636b57
chore : add CI LAMBDA_URL env variable
AntonioMrtz Oct 20, 2023
8e26976
Merge pull request #88 from AntonioMrtz/test/CancionesEndpointTesting…
AntonioMrtz Oct 20, 2023
aec15a9
feat : add script generate docs
AntonioMrtz Oct 20, 2023
3da5825
feat : add workflow file generate docs
AntonioMrtz Oct 20, 2023
5f2abf1
fix : push to base branch of pull request
AntonioMrtz Oct 20, 2023
b86257c
feat : trigger add documentation on branch merge
AntonioMrtz Oct 20, 2023
5e42e30
Merge pull request #89 from AntonioMrtz/feat/GenerateDocsGithubActions
AntonioMrtz Oct 20, 2023
ce88d2c
fix : generate docs
AntonioMrtz Oct 20, 2023
75110d1
test
AntonioMrtz Oct 20, 2023
c428eb7
Merge pull request #90 from AntonioMrtz/chore/CheckGenerateDocsIsWorking
AntonioMrtz Oct 20, 2023
6472583
feat : use pat
AntonioMrtz Oct 20, 2023
abcd4b9
Merge pull request #91 from AntonioMrtz/fix/PushWithCredentialsOnGene…
AntonioMrtz Oct 20, 2023
5a174f9
fix : credentials
AntonioMrtz Oct 20, 2023
e421d2c
Merge pull request #92 from AntonioMrtz/chore/UseCredentials
AntonioMrtz Oct 20, 2023
ae62855
fix : github actions update docs on merge working
AntonioMrtz Oct 20, 2023
70596a4
feat : add backend methods for search by name
AntonioMrtz Oct 21, 2023
48c7f63
chore : delete unused imports from tests
AntonioMrtz Oct 21, 2023
7157749
feat : change search_by_name output to arrays of jsons
AntonioMrtz Oct 21, 2023
5bc5001
docs : update docs search_by_name
AntonioMrtz Oct 21, 2023
3afc976
style : format search service
AntonioMrtz Oct 21, 2023
951cd5d
test : add search endpoint tests
AntonioMrtz Oct 21, 2023
b1c554b
feat : add UserCard
AntonioMrtz Oct 21, 2023
6fb9ded
feat : add search bar
AntonioMrtz Oct 21, 2023
950929e
feat : add filtered items
AntonioMrtz Oct 22, 2023
55fde9d
test : add Explorar searchbar tests
AntonioMrtz Oct 22, 2023
4f9f9a3
Merge pull request #96 from AntonioMrtz/feat/ExplorarSearchBar
AntonioMrtz Oct 22, 2023
45db45f
fix : change branch to update docs github actions
AntonioMrtz Oct 23, 2023
0ba05f7
feat : update readme
AntonioMrtz Oct 23, 2023
0a58ea7
file : delete unused frontend component diagram
AntonioMrtz Oct 23, 2023
8b23f3b
docs : add api docs
AntonioMrtz Oct 25, 2023
1502ff3
docs : update readme goals
AntonioMrtz Oct 25, 2023
fad6e59
chore : gitignore dont ignore .vscode
AntonioMrtz Oct 29, 2023
58651e8
chore : add recomended extensions
AntonioMrtz Oct 29, 2023
8c28013
chore : add issue template
AntonioMrtz Nov 1, 2023
cc59056
fix : move issue template under ISSUE_TEMPLATE folder
AntonioMrtz Nov 1, 2023
8e0c5e0
Update issue templates
AntonioMrtz Nov 1, 2023
337eac1
fix : rename issue template
AntonioMrtz Nov 1, 2023
0c2c7d7
fix : add onerror image to cards and profiles
AntonioMrtz Nov 2, 2023
1b5af68
fix : artists not showing explorar
AntonioMrtz Nov 2, 2023
52d5fd7
docs : add song architecture
AntonioMrtz Nov 3, 2023
b88dc63
docs : add frontend architecture
AntonioMrtz Nov 4, 2023
fa1f4ce
chore : modify build icons
AntonioMrtz Nov 25, 2023
ae16997
chore : add spotify icon to build
AntonioMrtz Nov 25, 2023
1a3e51e
fix : replace browser router with hashrouter for build
AntonioMrtz Nov 25, 2023
a8b8534
chore : add installer
AntonioMrtz Nov 25, 2023
ef2be38
Update README.md
AntonioMrtz Nov 25, 2023
edba469
chore : add vercel deployment file
AntonioMrtz Nov 25, 2023
7c37515
Merge branch 'master-streaming-lambda' of https://github.com/AntonioM…
AntonioMrtz Nov 25, 2023
d9f7080
Revert "chore : add vercel deployment file"
AntonioMrtz Nov 25, 2023
4ae50e0
feat : add backend using render
AntonioMrtz Nov 25, 2023
4344475
Add files via upload
AntonioMrtz Jan 21, 2024
a513e75
Add files via upload
AntonioMrtz Jan 21, 2024
4976e9a
Add files via upload
AntonioMrtz Jan 21, 2024
e46f256
Delete assets/images/song_architecture_aws.png
AntonioMrtz Jan 21, 2024
7546d23
Add files via upload
AntonioMrtz Jan 21, 2024
590e6cb
docs : update song arch on Readme
AntonioMrtz Jan 27, 2024
891b8ca
docs : fix song arch readme
AntonioMrtz Jan 27, 2024
f0d5ce9
docs : add funding kofi
AntonioMrtz Feb 17, 2024
2bb6023
ci : change example lambda url
AntonioMrtz Feb 17, 2024
d7ef23e
build : protect backend path into env
AntonioMrtz Feb 17, 2024
38ab423
ci : establish v12 backend python version pipeline
AntonioMrtz Feb 17, 2024
0106687
ci : update python backend actions for more recent ones
AntonioMrtz Feb 17, 2024
2c80c05
ci : reduce setup python to v4
AntonioMrtz Feb 17, 2024
9b2c7f1
ci : reduce python setup to v3
AntonioMrtz Feb 17, 2024
ac067fb
ci : python setup solving problems with ubuntu version
AntonioMrtz Feb 17, 2024
f7ccc56
ci : update actions version frontend
AntonioMrtz Feb 17, 2024
83d7e6f
ci : node update v18
AntonioMrtz Feb 17, 2024
d09483d
ci : use ubuntu 22.04 on frontend tests
AntonioMrtz Feb 17, 2024
b44c141
ci : add mongo uri env logic instead of mongo pass
AntonioMrtz Feb 17, 2024
192aec7
docs: add frontend example env
AntonioMrtz Feb 17, 2024
ac37459
ci : add peerDependencies meta failing packages pipeline
AntonioMrtz Feb 18, 2024
ec3a460
ci : add skiplibcheck true tsconfig
AntonioMrtz Feb 18, 2024
7b303c9
Revert "ci : add skiplibcheck true tsconfig"
AntonioMrtz Feb 18, 2024
2327499
Revert "ci : add peerDependencies meta failing packages pipeline"
AntonioMrtz Feb 18, 2024
6b9b344
chore : audit fix
AntonioMrtz Feb 18, 2024
d8287a0
chore : use local backend in frontend requests
AntonioMrtz Feb 18, 2024
a1a3f3d
chore : remove dotenv
AntonioMrtz Feb 18, 2024
57c8e06
chore : npm run lint fixed
AntonioMrtz Feb 18, 2024
fdc73df
chore : eslint label with button disable
AntonioMrtz Feb 18, 2024
bc9ab6e
refactor : change const noSong for noSongPlaying
AntonioMrtz Feb 24, 2024
6b3cea2
chore : update gitignore with python coverage and env files
AntonioMrtz Feb 24, 2024
70eb92b
docs : add frontend docs
AntonioMrtz Feb 24, 2024
8df5052
chore : add separated reduced requirements backend
AntonioMrtz Feb 24, 2024
1f7ca8b
refactor : rename __tests__ folder into tests
AntonioMrtz Feb 24, 2024
6379c88
chore : vscode adjusts for new test path
AntonioMrtz Feb 24, 2024
a9396c1
docs : update docs with new separated requirements
AntonioMrtz Feb 24, 2024
6afa74d
chore : add comments new backend env on Dockerfile
AntonioMrtz Feb 24, 2024
65b145b
fix : pipeline backend test unify run
AntonioMrtz Feb 24, 2024
f416bfe
docs : update PR template with new types of commit/branches
AntonioMrtz Feb 24, 2024
04df1c2
Merge pull request #99 from AntonioMrtz/build/AddEnviromentsSensibleInfo
AntonioMrtz Feb 24, 2024
dcec46f
docs : Update API documentation
actions-user Feb 24, 2024
0fd6957
chore : remove boto dependency
AntonioMrtz Feb 24, 2024
b730b0d
fix : add correct link readme frontend
AntonioMrtz Feb 24, 2024
9e05894
chore : add recommended extensions
AntonioMrtz Feb 24, 2024
85ba7f6
Merge pull request #100 from AntonioMrtz/chore/AddRecommendedExtensions
AntonioMrtz Feb 24, 2024
a39ea16
style : run linter black and isort on codebase
AntonioMrtz Feb 24, 2024
af8a8e9
fix : remove boto import
AntonioMrtz Feb 24, 2024
b280069
style : format black
AntonioMrtz Feb 24, 2024
9d7221c
ci : add backend format black pipeline
AntonioMrtz Feb 24, 2024
8d53753
docs : add style linting command to backend docs
AntonioMrtz Feb 24, 2024
b5306aa
fix : add boto to requirements and delete unused boto code
AntonioMrtz Mar 10, 2024
c1cb21f
build : add Docker Compose and modify dockerfile
AntonioMrtz Mar 10, 2024
67df8a1
build : add script for building and deploying docker compose
AntonioMrtz Mar 10, 2024
c1e5689
docs : update docs with docker compose info
AntonioMrtz Mar 10, 2024
04c2691
fix : rename Debug Main to Debug Backend
AntonioMrtz Mar 10, 2024
91c6041
Merge pull request #102 from AntonioMrtz/build/ContainerizeMongoForDev
AntonioMrtz Mar 10, 2024
2bbfba7
Merge branch 'master-streaming-lambda' into style/Style&LintingBackend
AntonioMrtz Mar 10, 2024
b3e56f3
Update backend-black.yml
AntonioMrtz Mar 10, 2024
f4d4519
fix : add docker compose build and up script
AntonioMrtz Mar 12, 2024
1aa8fa5
refactor : rename Backend API folder to Backend
AntonioMrtz Mar 17, 2024
b51d5b1
Merge pull request #103 from AntonioMrtz/refactor/Rename-BackendAPI-f…
AntonioMrtz Mar 17, 2024
7281b54
chore : rename requirements_* to requirements-*
AntonioMrtz Mar 17, 2024
008d972
build : add .dockerignore
AntonioMrtz Mar 17, 2024
b84820a
build : add separate dev and prod composes
AntonioMrtz Mar 17, 2024
f3f47a9
fix : typo on build and up scripts
AntonioMrtz Mar 17, 2024
b48c189
Merge pull request #104 from AntonioMrtz/build/Improve-Docker-&-Add-D…
AntonioMrtz Mar 17, 2024
a9e17a3
Merge branch 'master-streaming-lambda' of https://github.com/AntonioM…
AntonioMrtz Mar 17, 2024
5f201d2
chore : lint with flake8 and remove unused imports
AntonioMrtz Mar 17, 2024
eaa6dda
docs : fix max line length on style check backend
AntonioMrtz Mar 17, 2024
4a68a7d
chore : remove unused flake8 config file
AntonioMrtz Mar 17, 2024
761c8cd
fix : rename Backend API to Backend on style pipeline action
AntonioMrtz Mar 17, 2024
1322b7f
Merge pull request #101 from AntonioMrtz/style/Style&LintingBackend
AntonioMrtz Mar 17, 2024
5c9c76f
docs : Update API documentation
actions-user Mar 17, 2024
686a016
Merge branch 'master-streaming-lambda' of https://github.com/AntonioM…
AntonioMrtz Mar 17, 2024
bab283b
chore : delete merge files
AntonioMrtz Mar 17, 2024
ffa5294
fix : solve migration problems son song service
AntonioMrtz Mar 17, 2024
795fdbf
Merge branch 'master-streaming-lambda' of https://github.com/AntonioM…
AntonioMrtz Mar 17, 2024
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
35 changes: 35 additions & 0 deletions .github/workflows/backend-black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Backend Run Black style

on:
pull_request:
branches:
- 'master'
- 'master-*'
jobs:

run_tests:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
architecture: "x64"
env:
AGENT_TOOLSDIRECTORY: /opt/hostedtoolcache

- name: Install dependencies
working-directory: Backend/
run: pip install -r requirements.txt && pip install -r requirements-test.txt && pip install -r requirements-dev.txt

- name: Run style check
working-directory: Backend/src
run: python -m black . --check

- name: Fail workflow on style check failure
if: ${{ failure() }}
run: exit 1

10 changes: 6 additions & 4 deletions .github/workflows/backend-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Backend API Tests
name: Backend Tests

on:
pull_request:
Expand All @@ -22,15 +22,17 @@ jobs:
AGENT_TOOLSDIRECTORY: /opt/hostedtoolcache

- name: Install dependencies
working-directory: Backend API # Change to your backend API directory path
run: pip install -r requirements.txt && pip install -r requirements_test.txt
working-directory: Backend
run: pip install -r requirements.txt && pip install -r requirements-test.txt

- name: Run tests
working-directory: Backend API/src # Change to your backend API src directory path
working-directory: Backend/src
run: python -m pytest -s
env:
MONGO_URI : ${{ secrets.MONGO_URI }}
SECRET_KEY_SIGN : ${{ secrets.SECRET_KEY_SIGN }}
DISTRIBUTION_ID : ${{ secrets.DISTRIBUTION_ID }}
LAMBDA_URL : ${{ secrets.LAMBDA_URL }}


- name: Fail workflow on test failure
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ jobs:
python-version: 3.9

- name: Install dependencies
working-directory: Backend API
working-directory: Backend
run: pip install -r requirements.txt

- name: Run generate docs
working-directory: Backend API/src
working-directory: Backend/src
run: |
python generate-docs.py
mv -f api-docs-spotify-electron.html ../api-docs-spotify-electron.html

- name: Add and commit changes
working-directory: Backend API/
working-directory: Backend/
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
Expand Down
82 changes: 82 additions & 0 deletions AWS-Lambda-API/lambda_function.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import json
import boto3
import os
import io
import base64

s3 = boto3.resource('s3')
s3_client = boto3.client('s3')
song_bucket = s3.Bucket('canciones-spotify-electron')
bucket_base_path = "canciones/"
distribution_id = os.getenv("DISTRIBUTION_ID")


def get_cloudfront_url(resource_path: str):

cloudfront_client = boto3.client('cloudfront')
response = cloudfront_client.get_distribution(Id=distribution_id)
domain_name = response['Distribution']['DomainName']

# Construct the CloudFront URL
cloudfront_url = f"https://{domain_name}/{bucket_base_path}{resource_path}.mp3"

return cloudfront_url


def lambda_handler(event, context):

try:

method = event["httpMethod"]
song_name = event["queryStringParameters"]["nombre"]

if (method == 'GET'):
return {
"statusCode": 200,
"body": json.dumps({"url": str(get_cloudfront_url(song_name))})
}

elif (method == 'DELETE'):
s3_client.delete_object(
Bucket=song_bucket.name, Key=f"{bucket_base_path}{song_name}.mp3")
return {
"statusCode": 202,
"body": json.dumps({"details": "Canción borrada correctamente"})
}

elif (method == 'POST'):

song_key = f"{bucket_base_path}{song_name}.mp3"

try:

body_str = event["body"]
body_dict = json.loads(body_str)
song_data = body_dict.get("file")
encoded_data = song_data.split("'")[1]

decoded_bytes = base64.b64decode(encoded_data)

s3_client.put_object(Body=decoded_bytes,
Bucket=song_bucket.name, Key=song_key)
return {
"statusCode": 201,
"body": json.dumps({"details": "Canción borrada correctamente"})
}

except Exception as e:
return {
"statusCode": 500,
"body": json.dumps({"details": str(e)})
}

return {
"statusCode": 201,
"body": json.dumps({"details": "Canción creada correctamente"})
}

except Exception as e:
return {
"statusCode": 500,
"body": json.dumps({"error": str(e)})
}
2 changes: 0 additions & 2 deletions Backend API/.env.example

This file was deleted.

3 changes: 0 additions & 3 deletions Backend API/.vscode/settings.json

This file was deleted.

7 changes: 0 additions & 7 deletions Backend API/docker/build_and_up.sh

This file was deleted.

36 changes: 0 additions & 36 deletions Backend API/src/main.py

This file was deleted.

6 changes: 0 additions & 6 deletions Backend API/src/services/utils.py

This file was deleted.

14 changes: 0 additions & 14 deletions Backend API/src/tests/test_API/api_token.py

This file was deleted.

Loading