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

Develop #47

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
80e55d5
add yamusic integration
dergunovd Aug 30, 2022
d160897
load playlist
dergunovd Sep 1, 2022
812861e
temporary remove deploy deps on test
dergunovd Sep 1, 2022
d6eb197
Merge pull request #39 from music10/yamusic
dergunovd Sep 1, 2022
a22be60
fix docker
dergunovd Sep 1, 2022
2a4f98f
Merge pull request #40 from music10/yamusic
dergunovd Sep 1, 2022
66dbce1
change api for playlists
dergunovd Sep 1, 2022
a760ad3
Merge pull request #41 from music10/yamusic
dergunovd Sep 1, 2022
293baed
fix cors
dergunovd Sep 1, 2022
6273f82
fix cors
dergunovd Sep 1, 2022
d039cb5
Merge pull request #42 from music10/yamusic
dergunovd Sep 1, 2022
56ff322
fix cors
dergunovd Sep 1, 2022
2a81b18
fix search
dergunovd Sep 1, 2022
4dbd6eb
fix tests
dergunovd Sep 1, 2022
d3abe0e
get mp3
dergunovd Sep 2, 2022
99ab003
fix game
dergunovd Sep 2, 2022
2a1f47f
test sockets
dergunovd Sep 2, 2022
94ba556
test sockets
dergunovd Sep 2, 2022
58f7440
test sockets
dergunovd Sep 2, 2022
c232af2
test sockets
dergunovd Sep 2, 2022
9b36183
Merge pull request #43 from music10/socket
dergunovd Sep 2, 2022
3a62ad9
fix game artist
dergunovd Sep 2, 2022
9f476f5
fix game artist
dergunovd Sep 2, 2022
7d21c5e
fix game artist
dergunovd Sep 2, 2022
1fb397a
fix game artist
dergunovd Sep 2, 2022
13fc0c9
Merge pull request #44 from music10/socket
dergunovd Sep 2, 2022
824dfb6
implement cherry-pick
dergunovd Sep 3, 2022
190b6f5
Merge pull request #45 from music10/socket
dergunovd Sep 3, 2022
a400b8c
fix non-playable playlists && game class && tests
dergunovd Sep 3, 2022
5d68953
Merge pull request #46 from music10/socket
dergunovd Sep 3, 2022
65f6dc9
fix lock file
dergunovd Sep 3, 2022
9587120
sharing
dergunovd Sep 3, 2022
1801c30
implement random playlist
dergunovd Sep 3, 2022
379f194
implement random playlist
dergunovd Sep 3, 2022
2c26eee
fix random playlist
dergunovd Sep 3, 2022
59c89cf
fix share
dergunovd Sep 10, 2022
05ffeb0
implement hints
dergunovd Oct 8, 2022
e89950d
fix get tracks
dergunovd Oct 8, 2022
788abed
fix get mp3
dergunovd Oct 8, 2022
9f30753
fix eslint
dergunovd Oct 8, 2022
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
13 changes: 5 additions & 8 deletions .github/workflows/server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
# Publish `master` as Docker `latest` image.
branches:
- master
- develop

# Publish `v1.2.3` tags as releases.
tags:
Expand All @@ -24,10 +25,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: 14.x
node-version: 18.x

- name: Install dependencies
run: npm ci
Expand All @@ -37,21 +38,17 @@ jobs:

- name: Unit Test
run: npm run test
env:
SPOTIFY_AUTH_TOKEN: ${{ secrets.SPOTIFY_AUTH_TOKEN }}

- name: e2e Test
run: npm run test:e2e
env:
SPOTIFY_AUTH_TOKEN: ${{ secrets.SPOTIFY_AUTH_TOKEN }}

- name: Build Test
run: docker build . --file Dockerfile
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:
# Ensure test job passes before pushing image.
needs: test
# needs: test

runs-on: ubuntu-latest
if: github.event_name == 'push'
Expand All @@ -60,7 +57,7 @@ jobs:
- uses: actions/checkout@v2

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --build-arg SPOTIFY_AUTH_TOKEN=${{ secrets.SPOTIFY_AUTH_TOKEN }}
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ lerna-debug.log*

# Tests
/coverage
/src/coverage
/.nyc_output

# IDEs and editors
Expand All @@ -32,4 +33,4 @@ lerna-debug.log*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/extensions.json
11 changes: 11 additions & 0 deletions .run/All Tests.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="All Tests" type="JavaScriptTestRunnerJest" nameIsGenerated="true">
<node-interpreter value="project" />
<node-options value="" />
<jest-package value="$PROJECT_DIR$/node_modules/jest" />
<working-dir value="$PROJECT_DIR$" />
<envs />
<scope-kind value="ALL" />
<method v="2" />
</configuration>
</component>
15 changes: 15 additions & 0 deletions .run/build.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="build" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/../musiq/package.json" />
<command value="run" />
<scripts>
<script value="build" />
</scripts>
<node-interpreter value="project" />
<envs>
<env name="REACT_APP_BUGSNAG_KEY" value="e9be1e87d7c7da624188f5f407300e3b" />
<env name="REACT_APP_AMPLITUDE_API_KEY" value="e9b6ebbee137e8acbb95a381e4748a11" />
</envs>
<method v="2" />
</configuration>
</component>
19 changes: 19 additions & 0 deletions .run/test.Dockerfile.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="test.Dockerfile" type="docker-deploy" factoryName="dockerfile" server-name="Docker">
<deployment type="dockerfile">
<settings>
<option name="containerName" value="" />
<option name="sourceFilePath" value="test.Dockerfile" />
<option name="volumeBindings">
<list>
<DockerVolumeBindingImpl>
<option name="containerPath" value="/server" />
<option name="hostPath" value="C:\Users\DDergnuov\Projects\musiq\musiq" />
</DockerVolumeBindingImpl>
</list>
</option>
</settings>
</deployment>
<method v="2" />
</configuration>
</component>
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:15.5.1-buster
FROM node:18-buster

WORKDIR /server

Expand All @@ -7,9 +7,6 @@ COPY . .

RUN yarn

ARG SPOTIFY_AUTH_TOKEN
ENV SPOTIFY_AUTH_TOKEN=${SPOTIFY_AUTH_TOKEN}

RUN yarn build
CMD ["yarn", "start:prod"]

Expand Down
58 changes: 56 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,61 @@ npm start
### Deploy

```bash
docker pull docker.pkg.github.com/music10/server/server:latest
docker pull docker.pkg.github.com/music10/server/server:develop
docker rm --force musiq
docker run -p 5001:3001 -p 5000:3000 -d --name musiq --restart always docker.pkg.github.com/music10/server/server:latest
docker run -p 3000:3000 -p 3001:3001 -d --name musiq --restart always docker.pkg.github.com/music10/server/server:develop
```

### Example nginx config

```nginx
server {
server_name musiq.dergunov.net;
root /home/musiq/web;

index index.html index.htm;

location / {
try_files $uri $uri/ /index.html;
}
listen [::]:80;
listen 80;
}
server {
server_name api.musiq.dergunov.net;

location / {
try_files @server;
}

location @server {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_request_buffering off;
proxy_buffering off;
}

listen [::]:80;
listen 80;
}
server {
server_name ws.musiq.dergunov.net;

location / {
try_files @server;
}

location @server {
proxy_pass http://127.0.0.1:3001;
proxy_http_verion 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}

listen [::]:80;
listen 80;
}
```
3 changes: 3 additions & 0 deletions __tests__/mocks/playlist.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { PlaylistDto } from '../../src/dtos';
import { Type } from '../../src/modules/yandex/yandex.types';

/**
* Example of PlaylistDto
*/
export const PLAYLIST_MOCK: PlaylistDto = {
id: '6536346784',
name: 'Русский рэп',
tracks: [],
type: Type.playlist,
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
};
39 changes: 38 additions & 1 deletion __tests__/mocks/playlists.ts
Original file line number Diff line number Diff line change
@@ -1,90 +1,127 @@
/**
* Example of playlists array
*/
export const PLAYLISTS_MOCK = [
import { PlaylistDto } from '../../src/dtos';
import { Type } from '../../src/modules/yandex/yandex.types';

export const PLAYLISTS_MOCK: PlaylistDto[] = [
{
id: '6536346784',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Русский рэп',
},
{
id: '6536456504',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Русское',
},
{
id: '6538130744',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Рок Легенды',
},
{
id: '6538212324',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Party 2000 (Eng)',
},
{
id: '6538286664',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Электронная музыка',
},
{
id: '6538301104',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Хиты 2019',
},
{
id: '6538306484',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'top100',
},
{
id: '6538316964',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Тем кому за 20',
},
{
id: '7143520404',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Егор Крид',
},
{
id: '7143574264',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Моргенштерн',
},
{
id: '7143612724',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Макс Корж',
},
{
id: '7145047804',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Billie Eilish',
},
{
id: '7196330084',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Скриптонит',
},
{
id: '7196352584',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Imagine Dragons',
},
{
id: '7196355904',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Linkin Park',
},
{
id: '7196528424',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'GONE.Fludd',
},
{
id: '7223020864',
cover: 'https://i.scdn.co/image/ab67706c0000bebb9fe89caef5c9f3d66b0d988d',
type: Type.playlist,
tracks: [],
name: 'Oxxxymiron',
},
];
16 changes: 2 additions & 14 deletions __tests__/playlists.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ describe('PlaylistsController (e2e)', () => {
await app.init();
});

it('/playlists (GET)', async () => {
return request(app.getHttpServer())
.get('/playlists')
.expect(200, PLAYLISTS_MOCK);
});

it('/playlists?query=Eminem (GET)', async () => {
return request(app.getHttpServer())
.get('/playlists?query=Rap')
.expect(200, PLAYLISTS_MOCK);
});

it('/playlists/artist?query=Eminem (GET)', async () => {
return request(app.getHttpServer())
.get('/playlists/artist?query=Eminem')
Expand All @@ -52,9 +40,9 @@ describe('PlaylistsController (e2e)', () => {
.expect(200, PLAYLISTS_MOCK);
});

it('/playlists/{id} (GET)', async () => {
it('/playlists/playlist/{id} (GET)', async () => {
return request(app.getHttpServer())
.get('/playlists/123')
.get('/playlists/playlist/123')
.expect(200, PLAYLIST_MOCK);
});

Expand Down
Loading