https://github.com/humanscape/human-love-music-server
๐งโ๐คโ๐งโค๏ธ๐ถ
https://github.com/humanscape/human-love-music-server
Last synced: 3 months ago
JSON representation
๐งโ๐คโ๐งโค๏ธ๐ถ
- Host: GitHub
- URL: https://github.com/humanscape/human-love-music-server
- Owner: humanscape
- Created: 2021-12-20T08:57:25.000Z (over 3 years ago)
- Default Branch: develop
- Last Pushed: 2022-12-07T02:25:17.000Z (over 2 years ago)
- Last Synced: 2025-01-19T09:43:03.371Z (4 months ago)
- Language: TypeScript
- Size: 293 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# human-love-music-server
ํด๋จผ๋ค์ ์ํ ์์ ๊ณต์ ์ดํ๋ฆฌ์ผ์ด์ . ํด๋ฎค ๐งโ๐คโ๐งโค๏ธ๐ถ
- [ํด๋ผ์ด์ธํธ](https://github.com/humanscape/human-love-music-client)
- [์๋ฒ](https://github.com/humanscape/human-love-music-server)## ๊ฐ๋ฐํ๊ฒฝ ๊ตฌ์ฑ
### 1. node 14 ๋ฒ์ ์ ์ค์นํด์ฃผ์ธ์.
> 14.17.6 ๋ฒ์ ์์ ๋์์ด ํ์ธ๋์์ต๋๋ค
### 2. ์์กด์ฑ์ ์ค์นํฉ๋๋ค.
```
yarn install
```### 3. ํ๊ฒฝ ๋ณ์๋ฅผ ์ค์ ํฉ๋๋ค.
`.env.sample` ํ์ผ์ ๋ณด๊ณ ์๋ก์ด ํ์ผ์ ์์ฑํฉ๋๋ค.
- `.env`: ๋ก์ปฌ ํ๊ฒฝ
- `.env.production`: ์ด์ ํ๊ฒฝ```
PORT= # ์ฑ์ด ์คํ๋ ํฌํธ
AUTH_JWT_SECRET= # (ํ์ฌ ์ฌ์ฉ๋์ง ์์ต๋๋ค)# DB ์ฐ๊ฒฐ ์ ๋ณด
DB_HOST=
DB_PORT=
DB_NAME=
DB_USERNAME=
DB_PASSWORD=# ์ฌ๋ ๋ด ์ค์ ํ์ด์ง์์ ์ฐพ์ ์ ์์ต๋๋ค
SLACK_SIGNING_SECRET= # Basic Information - App Credentials - Signing Secret
SLACK_BOT_TOKEN= # OAuth & Permissions - Bot User OAuth Token# ์ฌ๋ ๋ด์ด ์ฒ๋ฆฌํ ๋์ ์ฑ๋ ID. ์ฑ๋ ์ฐํด๋ฆญ - Open channel details - ํ๋จ์์ ํ์ธ ๊ฐ๋ฅํฉ๋๋ค.
SLACK_DIGEST_TARGET_CHANNEL= # digest๋ฅผ ์์ฑํ ๋ ๋ฉ์์ง๋ฅผ ์์งํ ๋์ ์ฑ๋
SLACK_QUEUE_ALLOW_CHANNEL= # ๋ผ๋์ค ๊ณก ์ถ๊ฐ ๋ฉ์์ง๋ฅผ ์์ ํ ์ฑ๋YOUTUBE_API_KEY= # Google API ์ฝ์์ ํตํด ๋ฐ๊ธ
SOUNDCLOUD_API_KEY= # SoundCloud ์น์์ ์๋ฌด ๋ฆฌํ์คํธ ํ url์ query params๋ก ์ง์ ๋ `client_id`๋ฅผ ์ง์ ํฉ๋๋ค
```### 4. ์ด๊ธฐ DB์ ๋ฐ์ดํฐ๋ฅผ ์ค๋นํฉ๋๋ค.
DB ์ปค๋ฅ์ ์ ๋ณด๊ฐ ์ฌ๋ฐ๋ฅธ์ง ํ์ธํ ํ ์๋ ์ปค๋งจ๋๋ฅผ ์คํํ์ฌ ํ ์ด๋ธ์ ์์ฑํฉ๋๋ค.
```
npx mikro-orm schema:update --run
```๋ผ๋์ค ๊ธฐ๋ฅ ์๋์ ํ์ํ ์ด๊ธฐ ๋ฐ์ดํฐ๋ฅผ ์ง์ ์์ฑํฉ๋๋ค. (์์ง ์๋ฉ ๋ฉ์๋๋ฅผ ์ ๊ณตํ๊ณ ์์ง ์์ต๋๋ค.)
```
> insert into playlistid, created_at, updated_at, playlist_type, title, description
PJTHllahrNXiNQF, <ํ์ฌ์๊ฐ>, <ํ์ฌ์๊ฐ>, RADIO, Radio,> insert into radio
id, room_name, playlist_id, current_track_id, current_track_started_at, current_track_duration
ToOE5kKoO3XC8m0, main, PJTHllahrNXiNQF, , ,
```### 5. ์ฑ์ ์คํ์ํต๋๋ค.
```
yarn start# ํน์ watch mode
yarn start:dev
```## ๋น๋์ ๋ฐฐํฌ
`yarn build`๋ก ์คํํ๊ณ `yarn start:prod`๋ก ๋น๋๋ ํ์ผ์ ์คํํฉ๋๋ค.
> ์ ์ปค๋งจ๋๋ก ์ฑ ์คํ์ .env.production ํ์ผ์ ํ๊ฒฝ๋ณ์๋ก ์ฌ์ฉํฉ๋๋ค.
Node ๋ฐํ์์ ์ ๊ณตํ๋ ํ๊ฒฝ์ ์๋ฒ๋ฅผ ๋ฐฐํฌ & ์คํ์ํต๋๋ค.
๊ฐ๊ธ์ ๋จ์ผ ์ธ์คํด์ค ํ๊ฒฝ์์ ์ฑ์ ์ด์ฉํ๋ ํด์ผ ์์ฝ ์์ ๊ด๋ จ ์ด์๋ฅผ ์ต์ํ์ํฌ ์ ์์ต๋๋ค. (ec2 ๋ฑ)## ํธ๋ฌ๋ธ ์ํ & ๊ด๋ฆฌ
### ๋ผ๋์ค ํ๊ฐ ๊ผฌ์ธ ๊ฒฝ์ฐ(์ฌ์์ด ๋ฉ์ถ๊ฑฐ๋ ๋ค์ ๊ณก์ผ๋ก ๋์ด๊ฐ์ง ์์)
- ์์ฝ ์์ ์ด setTimeout(์ธ๋ฉ๋ชจ๋ฆฌ)๋ก ๊ด๋ฆฌ๋๊ธฐ ๋๋ฌธ์ ์ผ๋ถ ๊ด๋ฆฌํ ์๋น์ค์ ๋ฐฐํฌ ๋ฐ ์ด์ฉ์, ํน์ ๋ค์ค ์ธ์คํด์ค ํ๊ฒฝ์์ ํ ๊ด๋ฆฌ์ ์คํจํ ์ ์์ต๋๋ค.
- ๊ถ๊ทน์ ์ผ๋ก๋ ๋ฉ์์งํ ๋์ ์ ํด์ผ ์์ ํ๋ฉ๋๋ค.
- ์์ฝ ์์ ์ ์ง์ํ๊ณ , ๋๋ ์ด๊ฐ ์ ์ ๊ฒ
- https://github.com/rabbitmq/rabbitmq-delayed-message-exchange ๋ฅผ ๊ด์ฐฎ์ ํ๋ณด๋ก ๋ณด๊ณ ์์ต๋๋ค.
- ํ์ฌ ์ํ์์๋ ๋ค์๊ณผ ๊ฐ์ ์ ์ฐจ๋ก ์ผ์์ ํด์ ๊ฐ๋ฅํฉ๋๋ค.
1. DB์์ radio ํ ์ด๋ธ์ ์กด์ฌํ๋ ๋จ์ผ ๋ก์ฐ์ `current_track_id`, `current_track_started_at`, `current_track_duration`์ ๊ฐ์ ๋ชจ๋ `null`๋ก ์ค์ ํฉ๋๋ค.
1. ํด๋น `radio.playlist..tracks`๋ฅผ ๋ชจ๋ ์ ๊ฑฐํฉ๋๋ค.
1. ์ฑ์ ์ฌ๋ถํ ํฉ๋๋ค.### ํ์ฌ ๋ฉค๋ฒ ๋ณ๋์ด ์๋ ๊ฒฝ์ฐ
`PUT /slack/members`๋ฅผ ์คํํ์ฌ `slack_member` ํ ์ด๋ธ์ ์ ๋ฐ์ดํธ ํฉ๋๋ค.