├── .gitignore
├── .prettierrc
├── README.md
├── backend
├── app.ts
├── bin
│ └── www
├── config
│ └── redis.ts
├── models
│ ├── MUSIC.js
│ ├── USER.js
│ ├── index.js
│ ├── init-models.js
│ └── sessions.js
├── package.json
├── public
│ ├── index.html
│ └── stylesheets
│ │ └── style.css
├── routes
│ ├── api
│ │ ├── index.ts
│ │ ├── music.ts
│ │ ├── room.ts
│ │ └── userList.ts
│ ├── audio.ts
│ ├── download.ts
│ ├── loginRouter.ts
│ ├── room.ts
│ └── uploadRouter.ts
├── services
│ ├── loginService.ts
│ ├── music.ts
│ └── uploadService.ts
├── socket
│ ├── SocketHandler.ts
│ ├── index.ts
│ ├── music.ts
│ └── userData.ts
├── tsconfig.json
├── types
│ └── index.ts
├── utils
│ ├── cloudConfig.ts
│ └── util.ts
├── yarn-error.log
└── yarn.lock
└── frontend
├── .gitignore
├── README.md
├── package-lock.json
├── package.json
├── public
├── favicon.ico
├── icons
│ ├── chevron-left.svg
│ ├── chevron-right.svg
│ ├── close.svg
│ ├── create-room.svg
│ ├── file-upload.svg
│ ├── leave-room.svg
│ ├── music-note.svg
│ ├── no-room.svg
│ ├── pause.svg
│ ├── play-circle.svg
│ ├── play.svg
│ ├── playlist-add.svg
│ ├── search.svg
│ ├── thumbs-up.svg
│ ├── user.svg
│ ├── volume-off.svg
│ └── volume-up.svg
├── images
│ ├── GitHub-Mark-120px-plus.png
│ ├── GitHub-Mark-32px.png
│ ├── btn_google_signin_light_normal_web.png
│ ├── kakao.png
│ └── logo.png
├── index.html
├── manifest.json
└── robots.txt
├── src
├── components
│ ├── App.tsx
│ ├── Header
│ │ ├── CreateRoomButton.tsx
│ │ ├── Header.tsx
│ │ ├── UploadModal.tsx
│ │ └── UserButton.tsx
│ ├── Main
│ │ └── RoomItem.tsx
│ ├── Room
│ │ ├── Chat
│ │ │ └── ChatComponent.tsx
│ │ ├── MusicPlayer
│ │ │ ├── MusicPlayer.tsx
│ │ │ ├── ThumbnailPlayer.tsx
│ │ │ └── Title.tsx
│ │ ├── PlayList
│ │ │ ├── MusicSearch
│ │ │ │ ├── MusicSearch.tsx
│ │ │ │ ├── MusicSearchItem.tsx
│ │ │ │ └── reducer
│ │ │ │ │ ├── addMusicState.tsx
│ │ │ │ │ └── searchResult.tsx
│ │ │ ├── PlayList.tsx
│ │ │ └── PlayListItem.tsx
│ │ └── UserList
│ │ │ ├── UserItem.tsx
│ │ │ └── UserList.tsx
│ └── Util
│ │ ├── CircleButton.tsx
│ │ ├── Loading.tsx
│ │ ├── Modal.tsx
│ │ ├── PopUp.tsx
│ │ ├── Progress.tsx
│ │ ├── SearchBar.tsx
│ │ ├── scrollbar.tsx
│ │ └── uploadController.ts
├── config.host.json
├── context
│ └── MyContext.tsx
├── hooks
│ ├── useAsync.tsx
│ ├── useinfiniteScroll.tsx
│ └── utils.tsx
├── images
│ └── search.png
├── index.css
├── index.tsx
├── pages
│ ├── Login.tsx
│ ├── Main.tsx
│ ├── Result.tsx
│ └── Room.tsx
├── react-app-env.d.ts
├── stylesheets
│ ├── MusicPlayer.scss
│ ├── Progress.scss
│ ├── global.scss
│ ├── header.scss
│ ├── login.scss
│ ├── main.scss
│ ├── palette.scss
│ ├── reset.css
│ ├── style.module.scss
│ └── userList.scss
└── types
│ └── index.ts
├── tsconfig.json
└── yarn.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .env
3 | *.mp3
4 | *.wav
5 | config.json
6 | config.local.json
7 | dump.rdb
8 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "arrowParens": "avoid",
3 | "printWidth": 120,
4 | "singleQuote": true,
5 | "tabWidth": 2,
6 | "trailingComma": "all",
7 | "useTabs": false
8 | }
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Shall We Sound?
2 |
3 | [ShallWeSound 바로가기]('https://shallwesound.p-e.kr/')
4 |
5 | ## 👨👨👦 참여자
6 |
7 | |
|
|
|
|
8 | | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------: |
9 | | J006 곽성준 | J084 박기범 | J163 이진선 | J171 이홍덕 |
10 | | [@seongjunme](https://github.com/seongjunme) | [@kbpark9898](https://github.com/kbpark9898) | [@jsl0149](https://github.com/jsl0149) | [@doggydeok2](https://github.com/doggydeok2) |
11 |
12 | ## 개요
13 |
14 | **_'같이 음악 듣지 않으실래요?'_**
15 |
16 | 내가 지금 듣고 있는 🎧이 노래🎧 너무 좋은데! 다른 사람도 다 알았으면 좋겠는데!
17 |
18 | 이런 경험 모두 한번씩은 있지 않나요??
19 |
20 | 이제 더 이상 고민하지 마세요. Shall We Sound와 함께라면 같이 듣고, 같이 즐길 수 있습니다. 😆
21 |
22 | 모두가 동시에 같은 노래를 듣고, 그 노래에 대해 이야기할 수 있어요. 🎶🎶
23 |
24 | 내가 직접 만든 노래라구요? 걱정하지 마세요! Shall We Sound는 이용자들에게 열려있는 음악 플랫폼입니다.
25 |
26 | 내 노래를 자랑하고 싶다면, 서슴없이 업로드하세요. 그리고 재생하세요! 이제 당신은 프로 뮤지션입니다.
27 |
28 | 그럼 이제 옆에있는 내 사람에게 말해보세요.
29 |
30 | **'shall we sound?'**
31 |
32 | ## 기술스택
33 |
34 | ---
35 |
36 | | division | stack |
37 | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
38 | | Web |    |
39 | | Front-end |    |
40 | | Back-end |    |
41 | | Production |   |
42 | | Code Management |   |
43 | | Formatting |   |
44 |
45 | ## 주요기능
46 |
47 | 👨💻 **로그인**
48 |
49 | 🎧 **공유 스트리밍**
50 |
51 | 🎼 **음악 업로드**
52 |
53 | 🏠 **방만들기**
54 |
55 | 💬 **유저** **채팅**
56 |
57 | ♻️ **방장 권한 위임**
58 |
59 | 🔎 **음악 검색**
60 |
61 | ## 상세소개
62 |
63 | [프로젝트 노션 링크](https://www.notion.so/boostcamp-wm/15-10-Web21-e15fcfdb965b4aa08bf9c8c5cf795796)
64 |
--------------------------------------------------------------------------------
/backend/app.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import cors from 'cors';
3 | import path from 'path';
4 | import http from 'http';
5 | import dotenv from 'dotenv';
6 | dotenv.config({ path: __dirname + '/config/.env' });
7 | import socket from './socket';
8 | import roomRouter from './routes/room';
9 | import audioRouter from './routes/audio';
10 | import apiRouter from './routes/api/';
11 | import uploadRouter from './routes/uploadRouter';
12 | import downloadRouter from './routes/download';
13 | import loginRouter from './routes/loginRouter';
14 |
15 | const models = require('./models/index.js');
16 | const app: express.Application = express();
17 | const server: http.Server = http.createServer(app);
18 |
19 | const sequelize = require('sequelize');
20 | const SequelizeAuto = require('sequelize-auto');
21 |
22 | app.use(
23 | cors({
24 | origin: true,
25 | credentials: true,
26 | }),
27 | );
28 |
29 | app.use('/api', apiRouter);
30 |
31 | app.get('/', (req, res) => {
32 | res.send('hello');
33 | });
34 |
35 | app.use('/room', roomRouter);
36 | app.use('/audio', audioRouter);
37 | app.use('/upload', uploadRouter);
38 | app.use('/download', downloadRouter);
39 | app.use('/oauth', loginRouter);
40 |
41 | app.use(express.static(path.join(__dirname, 'videos')));
42 |
43 | app.set('port', 3000);
44 |
45 | server.listen(3000);
46 |
47 | socket(server);
48 |
--------------------------------------------------------------------------------
/backend/bin/www:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | /**
4 | * Module dependencies.
5 | */
6 |
7 | var app = require('../app');
8 | var debug = require('debug')('backend:server');
9 | var http = require('http');
10 |
11 | /**
12 | * Get port from environment and store in Express.
13 | */
14 |
15 | var port = normalizePort(process.env.PORT || '3000');
16 | app.set('port', port);
17 |
18 | /**
19 | * Create HTTP server.
20 | */
21 |
22 | var server = http.createServer(app);
23 |
24 | /**
25 | * Listen on provided port, on all network interfaces.
26 | */
27 |
28 | server.listen(port);
29 | server.on('error', onError);
30 | server.on('listening', onListening);
31 |
32 | /**
33 | * Normalize a port into a number, string, or false.
34 | */
35 |
36 | function normalizePort(val) {
37 | var port = parseInt(val, 10);
38 |
39 | if (isNaN(port)) {
40 | // named pipe
41 | return val;
42 | }
43 |
44 | if (port >= 0) {
45 | // port number
46 | return port;
47 | }
48 |
49 | return false;
50 | }
51 |
52 | /**
53 | * Event listener for HTTP server "error" event.
54 | */
55 |
56 | function onError(error) {
57 | if (error.syscall !== 'listen') {
58 | throw error;
59 | }
60 |
61 | var bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port;
62 |
63 | // handle specific listen errors with friendly messages
64 | switch (error.code) {
65 | case 'EACCES':
66 | console.error(bind + ' requires elevated privileges');
67 | process.exit(1);
68 | break;
69 | case 'EADDRINUSE':
70 | console.error(bind + ' is already in use');
71 | process.exit(1);
72 | break;
73 | default:
74 | throw error;
75 | }
76 | }
77 |
78 | /**
79 | * Event listener for HTTP server "listening" event.
80 | */
81 |
82 | function onListening() {
83 | var addr = server.address();
84 | var bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
85 | debug('Listening on ' + bind);
86 | }
87 |
--------------------------------------------------------------------------------
/backend/config/redis.ts:
--------------------------------------------------------------------------------
1 | import redis from 'redis'
2 | export const client = redis.createClient();
3 | client.on("error", function(error) {
4 | console.error(error);
5 | });
6 | export const resultPrint = redis.print;
7 |
8 | export const updateOrDeleteToken = (token:string, updateToken:string|null, option:number)=>{
9 | if(option === 1){
10 | client.get(token, (err, data)=>{
11 | client.set(updateToken!, data!);
12 | })
13 | client.del(token);
14 | }else{
15 | client.del(token);
16 | }
17 | }
--------------------------------------------------------------------------------
/backend/models/MUSIC.js:
--------------------------------------------------------------------------------
1 | const Sequelize = require('sequelize');
2 | module.exports = function(sequelize, DataTypes) {
3 | return sequelize.define('MUSIC', {
4 | MID: {
5 | autoIncrement: true,
6 | type: DataTypes.INTEGER,
7 | allowNull: false,
8 | primaryKey: true
9 | },
10 | name: {
11 | type: DataTypes.STRING(500),
12 | allowNull: true
13 | },
14 | singer: {
15 | type: DataTypes.STRING(500),
16 | allowNull: true
17 | },
18 | description: {
19 | type: DataTypes.STRING(200),
20 | allowNull: true
21 | },
22 | thumbnail: {
23 | type: DataTypes.STRING(500),
24 | allowNull: true
25 | },
26 | path: {
27 | type: DataTypes.STRING(500),
28 | allowNull: true
29 | },
30 | content_hash: {
31 | type: DataTypes.STRING(200),
32 | allowNull: true,
33 | unique: "content_hash_UNIQUE"
34 | }
35 | }, {
36 | sequelize,
37 | tableName: 'MUSIC',
38 | timestamps: false,
39 | indexes: [
40 | {
41 | name: "PRIMARY",
42 | unique: true,
43 | using: "BTREE",
44 | fields: [
45 | { name: "MID" },
46 | ]
47 | },
48 | {
49 | name: "content_hash_UNIQUE",
50 | unique: true,
51 | using: "BTREE",
52 | fields: [
53 | { name: "content_hash" },
54 | ]
55 | },
56 | {
57 | name: "m_u_s_i_c_name_singer",
58 | type: "FULLTEXT",
59 | fields: [
60 | { name: "name" },
61 | { name: "singer" },
62 | ]
63 | },
64 | ]
65 | });
66 | };
67 |
--------------------------------------------------------------------------------
/backend/models/USER.js:
--------------------------------------------------------------------------------
1 | const Sequelize = require('sequelize');
2 | module.exports = function(sequelize, DataTypes) {
3 | return sequelize.define('USER', {
4 | U_ID: {
5 | autoIncrement: true,
6 | type: DataTypes.INTEGER,
7 | allowNull: false,
8 | primaryKey: true
9 | },
10 | user_email: {
11 | type: DataTypes.STRING(100),
12 | allowNull: true
13 | },
14 | ID: {
15 | type: DataTypes.STRING(400),
16 | allowNull: false
17 | },
18 | platform: {
19 | type: DataTypes.STRING(45),
20 | allowNull: false
21 | }
22 | }, {
23 | sequelize,
24 | tableName: 'USER',
25 | timestamps: false,
26 | indexes: [
27 | {
28 | name: "PRIMARY",
29 | unique: true,
30 | using: "BTREE",
31 | fields: [
32 | { name: "U_ID" },
33 | ]
34 | },
35 | ]
36 | });
37 | };
38 |
--------------------------------------------------------------------------------
/backend/models/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const fs = require('fs');
4 | const path = require('path');
5 | const Sequelize = require('sequelize');
6 | const basename = path.basename(__filename);
7 | const env = process.env.NODE_ENV || 'development';
8 | const config = require(__dirname + '/../config/config.json')[env];
9 | const db = {};
10 |
11 | let sequelize;
12 | if (config.use_env_variable) {
13 | sequelize = new Sequelize(process.env[config.use_env_variable], config);
14 | } else {
15 | sequelize = new Sequelize(config.database, config.username, config.password, config);
16 | }
17 |
18 | fs.readdirSync(__dirname)
19 | .filter(file => {
20 | return file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js';
21 | })
22 | .forEach(file => {
23 | const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);
24 | db[model.name] = model;
25 | });
26 |
27 | Object.keys(db).forEach(modelName => {
28 | if (db[modelName].associate) {
29 | db[modelName].associate(db);
30 | }
31 | });
32 |
33 | db.sequelize = sequelize;
34 | db.Sequelize = Sequelize;
35 |
36 | module.exports = db;
37 |
--------------------------------------------------------------------------------
/backend/models/init-models.js:
--------------------------------------------------------------------------------
1 | var DataTypes = require("sequelize").DataTypes;
2 | var _MUSIC = require("./MUSIC");
3 | var _USER = require("./USER");
4 | var _sessions = require("./sessions");
5 |
6 | function initModels(sequelize) {
7 | var MUSIC = _MUSIC(sequelize, DataTypes);
8 | var USER = _USER(sequelize, DataTypes);
9 | var sessions = _sessions(sequelize, DataTypes);
10 |
11 |
12 | return {
13 | MUSIC,
14 | USER,
15 | sessions,
16 | };
17 | }
18 | module.exports = initModels;
19 | module.exports.initModels = initModels;
20 | module.exports.default = initModels;
21 |
--------------------------------------------------------------------------------
/backend/models/sessions.js:
--------------------------------------------------------------------------------
1 | const Sequelize = require('sequelize');
2 | module.exports = function(sequelize, DataTypes) {
3 | return sequelize.define('sessions', {
4 | session_id: {
5 | type: DataTypes.STRING(128),
6 | allowNull: false,
7 | primaryKey: true
8 | },
9 | expires: {
10 | type: DataTypes.INTEGER.UNSIGNED,
11 | allowNull: false
12 | },
13 | data: {
14 | type: DataTypes.TEXT,
15 | allowNull: true
16 | }
17 | }, {
18 | sequelize,
19 | tableName: 'sessions',
20 | timestamps: false,
21 | indexes: [
22 | {
23 | name: "PRIMARY",
24 | unique: true,
25 | using: "BTREE",
26 | fields: [
27 | { name: "session_id" },
28 | ]
29 | },
30 | ]
31 | });
32 | };
33 |
--------------------------------------------------------------------------------
/backend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "backend",
3 | "version": "0.0.0",
4 | "private": true,
5 | "scripts": {
6 | "start": "nodemon --exec ts-node app.ts"
7 | },
8 | "dependencies": {
9 | "@ffmpeg-installer/ffmpeg": "^1.1.0",
10 | "@types/axios": "^0.14.0",
11 | "@types/body-parser": "^1.19.2",
12 | "@types/express": "^4.17.13",
13 | "@types/jsonwebtoken": "^8.5.6",
14 | "@types/multer": "^1.4.7",
15 | "@types/mysql": "^2.15.19",
16 | "@types/qs": "^6.9.7",
17 | "@types/redis": "^2.8.32",
18 | "aws-sdk": "2.348.0",
19 | "axios": "^0.24.0",
20 | "body-parser": "^1.19.0",
21 | "cookie-parser": "~1.4.4",
22 | "cors": "^2.8.5",
23 | "debug": "~2.6.9",
24 | "dotenv": "^10.0.0",
25 | "express": "~4.16.1",
26 | "express-mysql-session": "^2.1.7",
27 | "express-session": "^1.17.2",
28 | "fluent-ffmpeg": "^2.1.2",
29 | "global": "^4.4.0",
30 | "hls-server": "^1.5.0",
31 | "http": "^0.0.1-security",
32 | "jsonwebtoken": "^8.5.1",
33 | "morgan": "~1.9.1",
34 | "multer": "^1.4.3",
35 | "mysql": "^2.18.1",
36 | "mysql2": "^2.3.3-rc.0",
37 | "qs": "^6.10.1",
38 | "redis": "^3.1.2",
39 | "sequelize": "^6.9.0",
40 | "sequelize-auto": "^0.8.5",
41 | "sequelize-cli": "^6.3.0",
42 | "session-file-store": "^1.5.0",
43 | "socket.io": "^4.3.1",
44 | "typescript": "^4.4.4"
45 | },
46 | "devDependencies": {
47 | "nodemon": "^2.0.15",
48 | "ts-node": "^10.4.0"
49 | },
50 | "nodemonConfig": {
51 | "ignore": [
52 | "sessions"
53 | ]
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/backend/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Express
6 |
7 |
8 |
9 |
10 | Express
11 | Welcome to Express
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/backend/public/stylesheets/style.css:
--------------------------------------------------------------------------------
1 | body {
2 | padding: 50px;
3 | font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
4 | }
5 |
6 | a {
7 | color: #00B7FF;
8 | }
9 |
--------------------------------------------------------------------------------
/backend/routes/api/index.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import musicRouter from './music';
3 | import roomRouter from './room';
4 | import userListRouter from './userList';
5 | const router = express.Router();
6 |
7 | router.use('/music', musicRouter);
8 | router.use('/room', roomRouter);
9 | router.use('/userList', userListRouter);
10 | export default router;
11 |
--------------------------------------------------------------------------------
/backend/routes/api/music.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import MusicService from '../../services/music';
3 |
4 | const router = express.Router();
5 |
6 | router.get('/', async (req: express.Request, res: express.Response) => {
7 | const keyword = (req.query.keyword as string) ?? '';
8 | const page = parseInt(req.query.page as string);
9 |
10 | if (keyword === '') {
11 | res.send([]);
12 | } else {
13 | const result = await MusicService.searchByPage(keyword, page);
14 | res.send(result);
15 | }
16 | });
17 |
18 | export default router;
19 |
--------------------------------------------------------------------------------
/backend/routes/api/room.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import { socketData } from '../../socket/SocketHandler';
3 |
4 | const router = express.Router();
5 |
6 | router.use(express.json());
7 |
8 | router.get('/', (req: express.Request, res: express.Response) => {
9 | const data = socketData.map(val => {
10 | return { id: val.id, name: val.name, description: val.description, totalUser: val.socketId.length };
11 | });
12 | res.json({ list: data });
13 | });
14 |
15 | export default router;
16 |
--------------------------------------------------------------------------------
/backend/routes/api/userList.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import { socketData } from '../../socket/userData';
3 | import { utils } from '../../utils/util';
4 |
5 | const router = express.Router();
6 |
7 | router.get('/', (req, res, next) => {
8 | const roomTitle = `${req.query.roomTitle}`;
9 | const targetRoom = utils.findRoomOnTitle(socketData, roomTitle);
10 | const userList = targetRoom?.userId.filter((val, idx, arr) => arr.indexOf(val) === idx);
11 | if (!targetRoom) res.json({ list: ['bad'] });
12 |
13 | res.json({ list: userList });
14 | });
15 |
16 | export default router;
17 |
--------------------------------------------------------------------------------
/backend/routes/audio.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import fs from 'fs';
3 | import path from 'path';
4 | const router = express.Router();
5 |
6 | router.get('/:name', (req: express.Request, res: express.Response) => {
7 | const music = req.params.name;
8 |
9 | const data = fs.readFileSync(path.resolve(__dirname, `../audio/${music}`));
10 | res.writeHead(200, {
11 | 'Content-Type': 'audio/mpeg',
12 | 'Accept-Ranges': 'none',
13 | });
14 | res.write(data);
15 | res.end();
16 | });
17 |
18 | export default router;
19 |
--------------------------------------------------------------------------------
/backend/routes/download.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import {myS3, makeSignedURL} from '../utils/cloudConfig'
3 | const router = express.Router();
4 | router.use(express.json());
5 |
6 | router.get('/' ,(req, res)=>{
7 | const contentHash = req.body.contentHash;
8 | const musicName = req.body.musicName;
9 | res.send(makeSignedURL(myS3, contentHash, musicName));
10 | })
11 |
12 |
13 | export default router;
--------------------------------------------------------------------------------
/backend/routes/loginRouter.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import { loginServie } from '../services/loginService';
3 | import * as jwt from 'jsonwebtoken';
4 |
5 | const router = express.Router();
6 | router.use(express.json());
7 |
8 | router.get('/', (req, res) => {
9 | res.send('test complete');
10 | });
11 |
12 | router.get('/test', (req, res) => {
13 | res.send('test test complete');
14 | });
15 |
16 | router.get('/kakao', (req, res) => {
17 | res.redirect(
18 | `https://kauth.kakao.com/oauth/authorize?client_id=${process.env.KAKAO_CLIENT_KEY}&redirect_uri=${process.env.KAKAO_CALLBACK_URL}&response_type=code`,
19 | );
20 | });
21 | router.get('/github', (req, res) => {
22 | res.redirect(
23 | `https://github.com/login/oauth/authorize?client_id=${process.env.GITHUB_CLIENT_ID}&redirect_uri=${process.env.GITHUB_CALLBACK_URL}`,
24 | );
25 | });
26 |
27 | router.get('/github/callback', async (req, res) => {
28 | const { code } = req.query;
29 | const token = await loginServie.githubLogin(code);
30 | res.cookie('userID', loginServie.getUserId(jwt.verify(token, `${process.env.SALT}`)));
31 | res.cookie('userEmail', loginServie.getUserEmail(jwt.verify(token, `${process.env.SALT}`)));
32 | res.cookie('jwt', token).redirect(`${process.env.LOCALHOST_URL}`);
33 | });
34 |
35 | router.get('/kakao/callback', async (req, res) => {
36 | const token = await loginServie.kakaoLogin(req.query.code);
37 | res.cookie('userID', loginServie.getUserId(jwt.verify(token, `${process.env.SALT}`)));
38 | res.cookie('userEmail', loginServie.getUserEmail(jwt.verify(token, `${process.env.SALT}`)));
39 | res.cookie('jwt', token).redirect(`${process.env.LOCALHOST_URL}`);
40 | });
41 |
42 | router.post('/authenticate', async (req, res) => {
43 | const curToken = req.body.jwt;
44 | const authenticateResult = await loginServie.verifyToken(curToken);
45 | if (authenticateResult.result === true) {
46 | if (authenticateResult.newToken === null) {
47 | res.json({ isOK: true });
48 | } else {
49 | loginServie.updateOrDelete(curToken, authenticateResult.newToken, 1);
50 | res.cookie('jwt', authenticateResult.newToken);
51 | res.cookie('userID', authenticateResult.userID);
52 | res.cookie('userEmail', authenticateResult.userEmail);
53 | res.json({ isOK: true });
54 | }
55 | } else {
56 | loginServie.updateOrDelete(curToken, null, 2);
57 | res.cookie('jwt', null);
58 | res.cookie('userID', null);
59 | res.cookie('userEmail', null);
60 | res.json({ isOK: false });
61 | }
62 | });
63 |
64 | export default router;
65 |
--------------------------------------------------------------------------------
/backend/routes/room.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | const router = express.Router();
3 |
4 | router.get('/', (req: express.Request, res: express.Response) => {
5 | res.send('room page');
6 | });
7 |
8 | export default router;
9 |
--------------------------------------------------------------------------------
/backend/routes/uploadRouter.ts:
--------------------------------------------------------------------------------
1 | import express from 'express';
2 | import multer from 'multer';
3 | import {makeHash} from '../utils/util'
4 | import {uploadLogic} from'../services/uploadService'
5 | const upload = multer({
6 | storage: multer.memoryStorage(),
7 | limits:{
8 | fileSize: 15 * 1024 * 1024
9 | }
10 | });
11 | const router = express.Router();
12 | const cpUpload = upload.fields([{name:'userFile1'}, {name:'userFile2'}])
13 |
14 |
15 | router.post('/', cpUpload, async (req, res, next)=>{
16 | const bucket_name = 'sws';
17 | const files = req.files as { [fieldname: string]: Express.Multer.File[] };
18 | const object_name = `${files.userFile1[0].originalname}`;
19 | const contentHash = makeHash(files.userFile1[0].buffer.toString());
20 | const thumbnailName = object_name.split('.')[0]+'.'+files.userFile2[0].originalname.split('.')[1];
21 | const singer = req.body.singer;
22 | const description = req.body.description
23 | uploadLogic(bucket_name, files, object_name, contentHash, thumbnailName, singer, description);
24 | res.send(200);
25 | })
26 | export default router;
--------------------------------------------------------------------------------
/backend/services/loginService.ts:
--------------------------------------------------------------------------------
1 | import axios from 'axios';
2 | import * as jwt from 'jsonwebtoken'
3 | import {authCode, userProfileRequestHeader} from '../types/index'
4 | import {client, resultPrint, updateOrDeleteToken} from '../config/redis'
5 | import {promisify} from 'util'
6 | const models = require('../models/index.js');
7 |
8 | const makeOauthAccessToken = async (platform:string, cururl:string, curheaders:string)=>{
9 | if(platform === 'github'){
10 | return axios({
11 | method: `POST`,
12 | withCredentials: true,
13 | url: cururl,
14 | headers: {
15 | 'content-type': curheaders,
16 | },
17 | })
18 | }else{
19 | return axios({
20 | method: `POST`,
21 | url: cururl,
22 | headers: {
23 | 'content-type': curheaders,
24 | },
25 | })
26 | }
27 | }
28 |
29 |
30 | const getUserProfileFromOauth = async (platform:string, url:string, headers:userProfileRequestHeader) =>{
31 | if(platform === 'github'){
32 | return axios({
33 | method:'GET',
34 | withCredentials:true,
35 | url: url,
36 | headers:{
37 | Authorization: headers.Authorization
38 | }
39 | })
40 | }else{
41 | return axios({
42 | method:'POST',
43 | withCredentials:true,
44 | url: url,
45 | data:{
46 | property_keys: ["kakao_account.email"]
47 | },
48 | headers: {
49 | 'Authorization': headers.Authorization,
50 | 'content-type': headers.contentType!,
51 | },
52 | })
53 | }
54 |
55 | }
56 | const githubLoginService = async(code:authCode)=>{
57 | const tokenURL = `https://github.com/login/oauth/access_token?client_id=${process.env.GITHUB_CLIENT_ID}&client_secret=${process.env.GITHUB_CLIENT_SECRET}&code=${code}`;
58 | const access_token = await makeOauthAccessToken('github', tokenURL, 'application/json');
59 | let access_token_split = access_token.data.split('&')[0].split('=')[1];
60 | const requestHeader:userProfileRequestHeader={
61 | Authorization:`token ${access_token_split}`,
62 | contentType:null
63 | }
64 | const userResponse = await getUserProfileFromOauth('github','https://api.github.com/user', requestHeader )
65 | const userID = userResponse.data.login;
66 | const userEmail = userResponse.data.email === null || userResponse.data.email === undefined ? '':userResponse.data.email;
67 | const aToken = jwt.sign({userID:userID, userEmail:userEmail}, `${process.env.SALT}`, {
68 | expiresIn: '30m'
69 | });
70 | const rToken = jwt.sign({}, `${process.env.SALT}`, {expiresIn:'2h'})
71 | searchOrCreate(userID, userEmail, 'github');
72 | client.set(aToken, rToken, resultPrint);
73 | return aToken;
74 |
75 | }
76 | const kakaoLoginService = async(code:authCode)=>{
77 | const tokenURL=`https://kauth.kakao.com/oauth/token?client_id=${process.env.KAKAO_CLIENT_KEY}&grant_type=authorization_code&redirect_uri=${process.env.KAKAO_CALLBACK_URL}&code=${code}`;
78 | const tokenObj = await makeOauthAccessToken('kakao', tokenURL, 'application/x-www-form-urlencoded');
79 | const accessToken = tokenObj.data.access_token;
80 | const requestHeader:userProfileRequestHeader={
81 | Authorization:`Bearer ${accessToken}`,
82 | contentType:'application/x-www-form-urlencoded'
83 | }
84 | const userResponse = await getUserProfileFromOauth('kakao','https://kapi.kakao.com/v2/user/me', requestHeader);
85 | const userID = userResponse.data.id;
86 | const curEmail = userResponse.data.kakao_account.email;
87 | const userEmail = curEmail === null || curEmail == undefined ? '' : curEmail;
88 | searchOrCreate(userID, userEmail, 'kakao');
89 | const aToken = jwt.sign({userID:userID, userEmail:userEmail}, `${process.env.SALT}`, {
90 | expiresIn: '30m'
91 | });
92 | const rToken = jwt.sign({}, `${process.env.SALT}`, {expiresIn:'2h'})
93 | client.set(aToken, rToken, resultPrint);
94 |
95 | return aToken;
96 | }
97 |
98 | const getUserId = (obj:string|jwt.JwtPayload):string =>{
99 | if(typeof obj === 'string'){
100 | return obj;
101 | }else{
102 | return obj.userID;
103 | }
104 | }
105 | const getUserEmail = (obj:string|jwt.JwtPayload):string =>{
106 | if(typeof obj === 'string'){
107 | return obj;
108 | }else{
109 | return obj.userEmail;
110 | }
111 | }
112 |
113 |
114 | const IDsearchInDB = async(verifyResult:string|jwt.JwtPayload)=>{
115 | try{
116 | await models.USER.findAll({ID:getUserId(verifyResult)})
117 | }catch(DBerr){
118 | return false;
119 | }
120 | return true;
121 | }
122 |
123 | const makeReturnResultOfVerifyToken = (result:boolean, userID:string|null, userEmail:string|null, newToken:string|null) =>{
124 | return {
125 | result:result,
126 | userID:userID,
127 | userEmail:userEmail,
128 | newToken:newToken
129 | }
130 | }
131 | const verifyToken = async (accessToken:string) =>{
132 | try{
133 | const verifyResult = jwt.verify(accessToken, `${process.env.SALT}`);
134 | const DBsearchResult = await IDsearchInDB(verifyResult);
135 | if(DBsearchResult === false){
136 | return makeReturnResultOfVerifyToken(false, null, null, null);
137 | }
138 | return makeReturnResultOfVerifyToken(true, getUserId(verifyResult), getUserEmail(verifyResult), null);
139 | }catch(err){
140 | const refreshRes = await refreshToken(accessToken);
141 | if (refreshRes !== null){
142 | const DBsearchResult = await IDsearchInDB(`${refreshRes}`);
143 | if(DBsearchResult === true){
144 | return makeReturnResultOfVerifyToken(true,
145 | getUserId(jwt.verify(`${refreshRes}`, `${process.env.SALT}`)),
146 | getUserEmail(jwt.verify(`${refreshRes}`, `${process.env.SALT}`)) ,
147 | refreshRes);
148 | }else{
149 | return makeReturnResultOfVerifyToken(false, null, null, null);
150 | }
151 | }else{
152 | return makeReturnResultOfVerifyToken(false, null, null, null);
153 | }
154 | }
155 |
156 | }
157 |
158 | const redisGET = promisify(client.get).bind(client);
159 | const refreshToken = async (accessToken:string)=>{
160 | const rToken = await redisGET(accessToken);
161 | try{
162 | jwt.verify(rToken!, `${process.env.SALT}`);
163 | return jwt.sign({userID:getUserId(jwt.decode(accessToken)!), userEmail:getUserEmail(jwt.decode(accessToken)!)},
164 | `${process.env.SALT}`, {expiresIn:'30m'});
165 | }catch(err){
166 | return null
167 | }
168 |
169 | }
170 |
171 | const updateOrDelete = (token:string, updateToken:string|null, option:number) =>{
172 | updateOrDeleteToken(token, updateToken, option);
173 | }
174 |
175 | const searchOrCreate = (id:string, email:string, platform:string)=>{
176 | models.USER.findOrCreate({
177 | where: { ID:id, platform:platform },
178 | defaults: {
179 | ID:id,
180 | user_email:email,
181 | platform:platform
182 | }
183 | });
184 | }
185 | export const loginServie={
186 | githubLogin:githubLoginService,
187 | kakaoLogin:kakaoLoginService,
188 | verifyToken:verifyToken,
189 | updateOrDelete:updateOrDelete,
190 | getUserId:getUserId,
191 | getUserEmail:getUserEmail,
192 | searchOrCreate:searchOrCreate
193 | }
194 |
195 |
196 |
--------------------------------------------------------------------------------
/backend/services/music.ts:
--------------------------------------------------------------------------------
1 | import { Music } from '../types';
2 |
3 | const MusicModel = require('../models').MUSIC;
4 | const Op = require('sequelize').Op;
5 |
6 | export default {
7 | async searchByPage(keyword: string, page: number) {
8 | try {
9 | const result = await MusicModel.findAll({
10 | where: {
11 | [Op.or]: {
12 | name: { [Op.like]: '%' + keyword + '%' },
13 | singer: { [Op.like]: '%' + keyword + '%' },
14 | },
15 | },
16 | replacements: {
17 | keyword: keyword,
18 | },
19 | limit: 11,
20 | offset: page,
21 | });
22 |
23 | if (result.length >= 11) {
24 | result.pop();
25 | return { result, hasMore: true };
26 | }
27 |
28 | return { result, hasMore: false };
29 | } catch (e) {
30 | return { result: [], hasMore: false };
31 | }
32 | },
33 | async findMusicsBy(MIDS: number[]) {
34 | const result = await MusicModel.findAll({
35 | attribute: ['MID', 'name', 'singer', 'description', 'thumbnail', 'path'],
36 | where: {
37 | MID: {
38 | [Op.or]: MIDS,
39 | },
40 | },
41 | });
42 |
43 | return result.map(
44 | (res: Music): Music => ({
45 | MID: res.MID,
46 | name: res.name,
47 | singer: res.singer,
48 | description: res.description,
49 | thumbnail: res.thumbnail,
50 | path: res.path,
51 | isPlayed: false,
52 | }),
53 | );
54 | },
55 | };
56 |
--------------------------------------------------------------------------------
/backend/services/uploadService.ts:
--------------------------------------------------------------------------------
1 | import {myS3, makeSignedURL} from '../utils/cloudConfig'
2 | import {Readable} from 'stream';
3 | const models = require('../models/index.js');
4 |
5 | const options = {
6 | partSize: 15 * 1024 * 1024
7 | };
8 |
9 | const uploadToStorage = async(
10 | S3:AWS.S3,
11 | objectName:string,
12 | bucketName:string,
13 | files:{[fieldname: string]: Express.Multer.File[];},
14 | contentHash:string,
15 | thumbnailName:string
16 | )=>{
17 | let folder_name = `${contentHash}/`;
18 | // 해쉬값을 이름으로 하는 폴더를 생성하고, 그 안에 파일 업로드
19 | await S3.putObject({
20 | Bucket: bucketName,
21 | Key: folder_name
22 | }).promise();
23 | await Promise.all([
24 | S3.upload({
25 | Bucket: bucketName,
26 | Key: folder_name+objectName,
27 | Body: Readable.from(files.userFile1[0].buffer)
28 | }, options).promise(),
29 | S3.upload({
30 | Bucket: bucketName,
31 | Key: folder_name+thumbnailName,
32 | Body: Readable.from(files.userFile2[0].buffer)
33 | }, options).promise()
34 | ])
35 | }
36 |
37 | export const uploadLogic = async (
38 | bucket_name:string,
39 | files:{[fieldname: string]: Express.Multer.File[];},
40 | object_name:string,
41 | contentHash:string,
42 | thumbnailName:string,
43 | singer:string,
44 | description:string
45 | )=>{
46 | try{
47 | const queryResult = await models.MUSIC.create({
48 | name:object_name,
49 | singer:singer,
50 | description:description,
51 | thumbnail:thumbnailName,
52 | path:'경로경로',
53 | content_hash:contentHash});
54 | await uploadToStorage(myS3, object_name, bucket_name, files, contentHash, thumbnailName);
55 | const path = makeSignedURL(myS3, contentHash, object_name);
56 | const thumbnailPath = makeSignedURL(myS3, contentHash, thumbnailName);
57 | await queryResult.update({path:path, thumbnail:thumbnailPath});
58 |
59 | }catch(e){
60 | console.log(e);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/backend/socket/SocketHandler.ts:
--------------------------------------------------------------------------------
1 | import { Server, Socket } from 'socket.io';
2 | import { socketData, userHash } from './userData';
3 | import musicService from '../services/music';
4 | import { utils } from '../utils/util';
5 | import type { Music, socketInfo } from '../types';
6 |
7 | let userNum: number = 0;
8 | let roomNumber: number = 1;
9 |
10 | const socketHandler = (io: Server) => {
11 | const namespace = io.of('/music');
12 |
13 | namespace.on('connection', (socket: Socket) => {
14 | console.log('접속 중: ', socket.id);
15 | userHash[socket.id] = userNum;
16 | userNum += 1;
17 |
18 | socket.on('disconnect', () => {
19 | const targetRoom: socketInfo = utils.findRoom(socketData, socket.id);
20 | const leaveUser = targetRoom?.socketId[0];
21 | utils.updateDisconnectData(targetRoom, socketData, socket);
22 |
23 | if (targetRoom && targetRoom.socketId.length > 0) {
24 | if (leaveUser === socket.id) {
25 | namespace.to(targetRoom.socketId[0]).emit('delegateHost', true);
26 | }
27 |
28 | namespace.to(targetRoom.id).emit('updateUserList');
29 | const roomList = utils.getRoomListForClient(socketData);
30 | socket.broadcast.emit('updateRoomList', { list: roomList });
31 | }
32 | });
33 |
34 | socket.on('chatMessage', (message: string) => {
35 | const targetRoom: socketInfo = utils.findRoom(socketData, socket.id);
36 | const userID = utils.getUserBySocketID(targetRoom, socket.id);
37 | if (targetRoom !== undefined) socket.to(targetRoom.id).emit('chatMessage', { id: userID, msg: message });
38 | });
39 |
40 | socket.on('responseTime', (currentPlayTime: number) => {
41 | const targetRoom: socketInfo = utils.findRoom(socketData, socket.id);
42 | socket.broadcast.to(targetRoom.id).emit('sync', currentPlayTime);
43 | namespace.to(targetRoom.id).emit('changeMusicInfo', targetRoom.playList.getCurrentMusic());
44 | namespace.to(targetRoom.id).emit('responsePlayList', targetRoom.playList.getPlayList());
45 | });
46 |
47 | socket.on('playControl', playType => {
48 | const targetRoom = utils.findRoomMaster(socketData, socket.id);
49 | if (playType === 'play') {
50 | const targetRoomTemp: socketInfo = utils.findRoom(socketData, socket.id);
51 | utils.joinRoom(socket, namespace, targetRoomTemp);
52 | }
53 | if (targetRoom !== undefined) socket.to(targetRoom.id).emit('playControl', playType);
54 | });
55 |
56 | socket.on('nextMusicReq', () => {
57 | const targetRoom: socketInfo = utils.findRoom(socketData, socket.id);
58 | if (socket.id !== targetRoom?.socketId[0]) return;
59 | namespace.to(targetRoom.id).emit('changeMusicInfo', targetRoom.playList.getNextMusic());
60 | namespace.to(targetRoom.id).emit('responsePlayList', targetRoom.playList.getPlayList());
61 | });
62 |
63 | socket.on('prevMusicReq', () => {
64 | const targetRoom: socketInfo = utils.findRoom(socketData, socket.id);
65 | if (socket.id !== targetRoom?.socketId[0]) return;
66 | namespace.to(targetRoom.id).emit('changeMusicInfo', targetRoom.playList.getPreMusic());
67 | namespace.to(targetRoom.id).emit('responsePlayList', targetRoom.playList.getPlayList());
68 | });
69 |
70 | socket.on('currentMusicReq', () => {
71 | const targetRoom: socketInfo = utils.findRoom(socketData, socket.id);
72 | socket.emit('currentMusicRes', targetRoom?.playList.getCurrentMusic());
73 | });
74 |
75 | socket.on('addMusicInPlayListReq', async (MIDs: number[]) => {
76 | const targetRoom: socketInfo = utils.findRoom(socketData, socket.id);
77 | if (!targetRoom) {
78 | return;
79 | }
80 | if (targetRoom.playList.isExist(MIDs)) {
81 | namespace.to(socket.id).emit('duplicatedMusicInPlayList');
82 | return;
83 | }
84 |
85 | const musics: Music[] = await musicService.findMusicsBy(MIDs);
86 | targetRoom.playList.addMusics(musics);
87 | namespace.to(socket.id).emit('successAddMusic');
88 |
89 | const list = targetRoom?.playList.getPlayList();
90 |
91 | if (list.length === musics.length) {
92 | list[0].isPlayed = true;
93 | namespace.to(targetRoom.id).emit('changeMusicInfo', list[0]);
94 | }
95 |
96 | namespace.to(targetRoom.id).emit('responsePlayList', list);
97 | });
98 |
99 | socket.on('removeMusicInPlayListReq', (MID: number) => {
100 | const targetRoom = socketData.find(val => val.socketId.some(client => client === socket.id) === true);
101 | if (!targetRoom) return;
102 |
103 | targetRoom.playList.removeMusicByMID(MID);
104 |
105 | const res = targetRoom.playList.getPlayList();
106 | namespace.to(targetRoom.id).emit('responsePlayList', res);
107 | });
108 |
109 | socket.on('createRoom', data => {
110 | utils.updateNewRoom(socketData, socket, data, roomNumber.toString());
111 | namespace.to(socket.id).emit('routingAfterCreateRoom', roomNumber.toString());
112 | roomNumber++;
113 | });
114 |
115 | socket.on('joinRoom', roomInfo => {
116 | socket.join(roomInfo.roomID);
117 | if (utils.isRoomExist(socketData, roomInfo.roomID)) {
118 | const target = utils.findRoomOnTitle(socketData, roomInfo.roomID);
119 | target?.socketId.push(socket.id);
120 | target?.userId.push(roomInfo.userID);
121 | if (target?.socketId.length) utils.joinRoom(socket, namespace, target);
122 | namespace.to(target?.id!).emit('updateUserList');
123 | socket.broadcast.emit('updateRoomList');
124 | }
125 | });
126 |
127 | socket.on('leaveRoom', () => {
128 | const targetRoom: socketInfo = utils.findRoom(socketData, socket.id);
129 | const leaveUser = targetRoom?.socketId[0];
130 | utils.updateDisconnectData(targetRoom, socketData, socket);
131 |
132 | if (targetRoom !== undefined) {
133 | if (leaveUser === socket.id) namespace.to(targetRoom.socketId[0]).emit('delegateHost', true);
134 | namespace.to(targetRoom.id).emit('updateUserList');
135 | socket.leave(targetRoom.id);
136 | const roomList = utils.getRoomListForClient(socketData);
137 | socket.broadcast.emit('updateRoomList', { list: roomList });
138 | }
139 | });
140 |
141 | socket.on('clickAndPlayMusic', (clickedMusic: string) => {
142 | const targetRoom = utils.findRoom(socketData, socket.id);
143 | const targetPlayList = targetRoom.playList;
144 | targetPlayList.setIsPlayed(false, targetPlayList.getCurrentMusic().name);
145 | targetPlayList.setIsPlayed(true, clickedMusic);
146 | namespace.to(targetRoom.id).emit('changeMusicInfo', targetPlayList.getMusicByName(clickedMusic));
147 | namespace.to(targetRoom.id).emit('responsePlayList', targetPlayList.getPlayList());
148 | });
149 |
150 | socket.on('redundancyCheck', userInfo => {
151 | const targetRoom: socketInfo = utils.findRoomOnTitle(socketData, userInfo.roomID)!;
152 | const isRedundancy = targetRoom.userId.some(val => val === userInfo.userID);
153 | socket.emit('redundancyCheck', { isRedundancy: isRedundancy, roomID: userInfo.roomID });
154 | });
155 |
156 | socket.on('delegateManual', (userName: string) => {
157 | const targetRoom: socketInfo = utils.findRoom(socketData, socket.id);
158 | utils.delegateHost(targetRoom, userName, socket.id, namespace);
159 | });
160 | });
161 | };
162 |
163 | export { socketHandler, socketData };
164 |
--------------------------------------------------------------------------------
/backend/socket/index.ts:
--------------------------------------------------------------------------------
1 | import { Server } from 'socket.io';
2 | import http from 'http';
3 | import { socketHandler } from './SocketHandler';
4 |
5 | export default (server: http.Server) => {
6 | const io = new Server(server, { cors: { origin: '*' } });
7 |
8 | socketHandler(io);
9 | };
10 |
--------------------------------------------------------------------------------
/backend/socket/music.ts:
--------------------------------------------------------------------------------
1 | import type { Music } from '../types';
2 |
3 | export class PlayList {
4 | playlist: Music[] = [];
5 |
6 | getPlayList(): Music[] {
7 | return this.playlist;
8 | }
9 |
10 | getNextMusic(): Music {
11 | const now = this.playlist.find(music => music.isPlayed);
12 | if (!now) {
13 | this.playlist[0].isPlayed = true;
14 | return this.playlist[0];
15 | }
16 |
17 | const next = this.playlist[(this.playlist.indexOf(now) + 1) % this.playlist.length];
18 | now.isPlayed = false;
19 | next.isPlayed = true;
20 |
21 | return next;
22 | }
23 |
24 | getPreMusic() {
25 | const now = this.playlist.find(music => music.isPlayed);
26 | if (!now) {
27 | this.playlist[0].isPlayed = true;
28 | return this.playlist[0];
29 | }
30 |
31 | let previous: Music;
32 |
33 | if (this.playlist.indexOf(now) === 0) {
34 | previous = this.playlist[this.playlist.length - 1];
35 | } else {
36 | previous = this.playlist[(this.playlist.indexOf(now) - 1) % this.playlist.length];
37 | }
38 |
39 | now.isPlayed = false;
40 | previous.isPlayed = true;
41 |
42 | return previous;
43 | }
44 |
45 | getCurrentMusic(): Music {
46 | return this.playlist.find(music => music.isPlayed)!;
47 | }
48 |
49 | addMusics(musics: Music[]): void {
50 | this.playlist.push(...musics);
51 | }
52 |
53 | getMusicByName(musicName: string) {
54 | return this.playlist.find(val => val.name === musicName);
55 | }
56 |
57 | setIsPlayed(state: boolean, musicName: string) {
58 | const music: Music = this.getMusicByName(musicName)!;
59 | music.isPlayed = state;
60 | }
61 |
62 | removeMusicByMID(MID: number): void {
63 | this.playlist = this.playlist.filter(music => music.MID !== MID);
64 | }
65 |
66 | isExist(MIDs: number[]): boolean {
67 | const temp = new Set(this.playlist.map(music => music.MID));
68 | return MIDs.find(MID => temp.has(MID)) ? true : false;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/backend/socket/userData.ts:
--------------------------------------------------------------------------------
1 | import { socketInfo, userList } from '../types';
2 |
3 | const userHash: userList = {};
4 |
5 | let socketData: socketInfo[] = [];
6 |
7 | export { userHash, socketData, socketInfo };
8 |
--------------------------------------------------------------------------------
/backend/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | /* Visit https://aka.ms/tsconfig.json to read more about this file */
4 |
5 | /* Projects */
6 | // "incremental": true, /* Enable incremental compilation */
7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8 | // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12 |
13 | /* Language and Environment */
14 | "target": "es5" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15 | // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16 | // "jsx": "preserve", /* Specify what JSX code is generated. */
17 | // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
22 | // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25 |
26 | /* Modules */
27 | "module": "commonjs" /* Specify what module code is generated. */,
28 | // "rootDir": "./", /* Specify the root folder within your source files. */
29 | // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
30 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
31 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
32 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
33 | // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
34 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */
35 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
36 | // "resolveJsonModule": true, /* Enable importing .json files */
37 | // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */
38 |
39 | /* JavaScript Support */
40 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
41 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
42 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
43 |
44 | /* Emit */
45 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
46 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */
47 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
48 | // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
49 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
50 | // "outDir": "./", /* Specify an output folder for all emitted files. */
51 | // "removeComments": true, /* Disable emitting comments. */
52 | // "noEmit": true, /* Disable emitting files from a compilation. */
53 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
54 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
55 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
56 | // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
57 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
58 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
59 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
60 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
61 | // "newLine": "crlf", /* Set the newline character for emitting files. */
62 | // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
63 | // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
64 | // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
65 | // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
66 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
67 |
68 | /* Interop Constraints */
69 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
70 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
71 | "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
72 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
73 | "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
74 |
75 | /* Type Checking */
76 | "strict": true /* Enable all strict type-checking options. */,
77 | "noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied `any` type.. */,
78 | // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
79 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
80 | // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
81 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
82 | // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
83 | // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
84 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
85 | // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
86 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
87 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
88 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
89 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
90 | // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
91 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
92 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
93 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
94 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
95 |
96 | /* Completeness */
97 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
98 | "skipLibCheck": true /* Skip type checking all .d.ts files. */
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/backend/types/index.ts:
--------------------------------------------------------------------------------
1 | import { PlayList } from '../socket/music';
2 |
3 | type authCode = string | qs.ParsedQs | string[] | qs.ParsedQs[] | undefined;
4 |
5 | type userProfileRequestHeader={
6 | Authorization:string,
7 | contentType:string|null
8 | }
9 |
10 | type Music = {
11 | MID: number;
12 | name: string;
13 | singer: string;
14 | description: string;
15 | thumbnail: string;
16 | path: string;
17 | isPlayed: boolean;
18 | };
19 |
20 | type socketInfo = {
21 | id: string;
22 | name: string;
23 | socketId: string[];
24 | userId: string[];
25 | description: string;
26 | playList: PlayList;
27 | };
28 |
29 | type userList = {
30 | [socketid: string]: number;
31 | };
32 |
33 | type musicTable = {
34 | MID: number;
35 | name: string;
36 | singer: string;
37 | description: string;
38 | thumbnail: string;
39 | path: string;
40 | content_hash: string;
41 | };
42 |
43 | export type { Music, socketInfo, userList, musicTable, authCode, userProfileRequestHeader};
44 |
--------------------------------------------------------------------------------
/backend/utils/cloudConfig.ts:
--------------------------------------------------------------------------------
1 | import * as AWS from 'aws-sdk';
2 | const region = 'kr-standard';
3 | const access_key = `${process.env.ACCESS_KEY}`;
4 | const secret_key = `${process.env.SECRET_KEY}`;
5 | export const myS3 = new AWS.S3({
6 | endpoint:'https://kr.object.ncloudstorage.com',
7 | region,
8 | credentials: {
9 | accessKeyId : access_key,
10 | secretAccessKey: secret_key
11 | }
12 | });
13 |
14 | export const makeSignedURL = (S3:AWS.S3, contentHash:string, musicName:string):string =>{
15 | const params = {Bucket: 'sws', Key: `${contentHash}/${musicName}`, Expires: 5000000};
16 | return S3.getSignedUrl('getObject', params);
17 | }
--------------------------------------------------------------------------------
/backend/utils/util.ts:
--------------------------------------------------------------------------------
1 | import { Socket } from 'socket.io';
2 | import { socketInfo } from '../types';
3 | import { PlayList } from '../socket/music';
4 | import crypto from 'crypto';
5 |
6 | export function makeHash(fileBuffer: string): string {
7 | return crypto
8 | .createHash('sha512')
9 | .update(fileBuffer + `${process.env.SALT}`)
10 | .digest('hex');
11 | }
12 |
13 | export const utils = {
14 | findRoom: function (socketData: socketInfo[], socketID: string) {
15 | return socketData.find(val => val.socketId.some(client => client === socketID) === true)!;
16 | },
17 |
18 | updateList: function (socketData: socketInfo[], targetRoom: socketInfo) {
19 | socketData.splice(socketData.indexOf(targetRoom), 1);
20 | return socketData.map(val => {
21 | return { id: val.id, name: val.name, description: val.description };
22 | });
23 | },
24 |
25 | updateDisconnectData: function (targetRoom: socketInfo, socketData: socketInfo[], socket: Socket) {
26 | if (targetRoom !== undefined) {
27 | const targetIdx = targetRoom.socketId.indexOf(socket.id);
28 | targetRoom.socketId = targetRoom.socketId.filter(val => val !== socket.id);
29 | targetRoom.userId = targetRoom.userId.filter((val, idx) => idx !== targetIdx);
30 | if (!targetRoom.socketId.length) {
31 | const updatedList = this.updateList(socketData, targetRoom);
32 | socket.broadcast.emit('updateRoomList', { list: updatedList });
33 | }
34 | }
35 | },
36 |
37 | findRoomMaster: function (socketData: socketInfo[], socketID: string) {
38 | return socketData.find(val => val.socketId[0] === socketID);
39 | },
40 |
41 | updateNewRoom: function (socketData: socketInfo[], socket: Socket, roomData: any, roomID: string) {
42 | socketData.push({
43 | id: roomID,
44 | name: roomData.name,
45 | socketId: [],
46 | userId: [],
47 | description: roomData.description,
48 | playList: new PlayList(),
49 | });
50 | },
51 |
52 | getRoomListForClient: function (socketData: socketInfo[]) {
53 | return socketData.map(val => {
54 | return { id: val.id, name: val.name, description: val.description, totalUesr: val.socketId.length };
55 | });
56 | },
57 |
58 | isRoomExist: function (socketData: socketInfo[], roomName: string) {
59 | return socketData.some(val => {
60 | return val.id === roomName;
61 | });
62 | },
63 | findRoomOnTitle: function (socketData: socketInfo[], roomName: string) {
64 | return socketData.find(val => val.id === roomName);
65 | },
66 |
67 | joinRoom: function (socket: Socket, namespace: any, target: socketInfo) {
68 | socket.broadcast.to([target.socketId[0]]).emit('requestTime', 'time');
69 | },
70 |
71 | getUserBySocketID: function (targetRoom: socketInfo, socketID: string) {
72 | const targetIdx = targetRoom.socketId.indexOf(socketID);
73 | return targetRoom.userId[targetIdx];
74 | },
75 |
76 | delegateHost: function (targetRoom: socketInfo, userName: string, socketID: string, namespace: any) {
77 | const targetSocket = this.findSocketIDByUserName(targetRoom, userName);
78 | targetRoom.socketId = [targetSocket, ...targetRoom.socketId.filter(val => val !== targetSocket)];
79 | targetRoom.userId = [userName, ...targetRoom.userId.filter(val => val !== userName)];
80 | namespace.to(targetRoom.id).emit('updateUserList');
81 | namespace.to(socketID).emit('delegateHost', false);
82 | namespace.to(targetSocket).emit('delegateHost', true);
83 | },
84 |
85 | findSocketIDByUserName: function (targetRoom: socketInfo, userName: string) {
86 | const idx = targetRoom.userId.indexOf(userName);
87 | return targetRoom.socketId[idx];
88 | },
89 | };
90 |
--------------------------------------------------------------------------------
/frontend/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 | public/songs
3 |
4 | # dependencies
5 | /node_modules
6 | /.pnp
7 | .pnp.js
8 |
9 | # testing
10 | /coverage
11 |
12 | # production
13 | /build
14 |
15 | # misc
16 | .DS_Store
17 | .env.local
18 | .env.development.local
19 | .env.test.local
20 | .env.production.local
21 | .env
22 |
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 | *.mp3
27 | *.wav
--------------------------------------------------------------------------------
/frontend/README.md:
--------------------------------------------------------------------------------
1 | # Getting Started with Create React App
2 |
3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
4 |
5 | ## Available Scripts
6 |
7 | In the project directory, you can run:
8 |
9 | ### `yarn start`
10 |
11 | Runs the app in the development mode.\
12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13 |
14 | The page will reload if you make edits.\
15 | You will also see any lint errors in the console.
16 |
17 | ### `yarn test`
18 |
19 | Launches the test runner in the interactive watch mode.\
20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 |
22 | ### `yarn build`
23 |
24 | Builds the app for production to the `build` folder.\
25 | It correctly bundles React in production mode and optimizes the build for the best performance.
26 |
27 | The build is minified and the filenames include the hashes.\
28 | Your app is ready to be deployed!
29 |
30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31 |
32 | ### `yarn eject`
33 |
34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35 |
36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37 |
38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39 |
40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41 |
42 | ## Learn More
43 |
44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45 |
46 | To learn React, check out the [React documentation](https://reactjs.org/).
47 |
48 | ### Code Splitting
49 |
50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
51 |
52 | ### Analyzing the Bundle Size
53 |
54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
55 |
56 | ### Making a Progressive Web App
57 |
58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
59 |
60 | ### Advanced Configuration
61 |
62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
63 |
64 | ### Deployment
65 |
66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
67 |
68 | ### `yarn build` fails to minify
69 |
70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
71 |
--------------------------------------------------------------------------------
/frontend/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "frontend",
3 | "version": "0.1.0",
4 | "private": true,
5 | "dependencies": {
6 | "@testing-library/jest-dom": "^5.11.4",
7 | "@testing-library/react": "^11.1.0",
8 | "@testing-library/user-event": "^12.1.10",
9 | "@types/jest": "^27.0.2",
10 | "@types/lodash": "^4.14.176",
11 | "@types/node": "^16.11.6",
12 | "@types/react-dom": "^17.0.10",
13 | "@types/react-router-dom": "^5.3.2",
14 | "@types/socket.io-client": "^3.0.0",
15 | "@types/styled-components": "^5.1.15",
16 | "react": "^17.0.2",
17 | "react-cookie": "^4.1.1",
18 | "react-dom": "^17.0.2",
19 | "react-router-dom": "^5.3.0",
20 | "react-scripts": "4.0.3",
21 | "sass": "^1.43.4",
22 | "socket-client": "^1.0.0",
23 | "socket.io-client": "^4.3.2",
24 | "styled-components": "^5.3.3",
25 | "typescript": "^4.4.4",
26 | "web-vitals": "^1.0.1"
27 | },
28 | "proxy": "http://localhost:3000",
29 | "scripts": {
30 | "start": "react-scripts start",
31 | "build": "react-scripts build",
32 | "test": "react-scripts test",
33 | "eject": "react-scripts eject"
34 | },
35 | "eslintConfig": {
36 | "extends": [
37 | "react-app",
38 | "react-app/jest"
39 | ]
40 | },
41 | "browserslist": {
42 | "production": [
43 | ">0.2%",
44 | "not dead",
45 | "not op_mini all"
46 | ],
47 | "development": [
48 | "last 1 chrome version",
49 | "last 1 firefox version",
50 | "last 1 safari version"
51 | ]
52 | },
53 | "devDependencies": {
54 | "@types/react": "^17.0.33",
55 | "@types/react-responsive": "^8.0.4",
56 | "react-responsive": "^9.0.0-beta.5"
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/frontend/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/boostcampwm-2021/WEB21-ShallWeSound/169272ba5855b5f76b277ff7a9fc94c674705f81/frontend/public/favicon.ico
--------------------------------------------------------------------------------
/frontend/public/icons/chevron-left.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/chevron-right.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/close.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/create-room.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/file-upload.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/leave-room.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/music-note.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/frontend/public/icons/no-room.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/pause.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/play-circle.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/play.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/playlist-add.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/search.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/thumbs-up.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/user.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/volume-off.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/icons/volume-up.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/frontend/public/images/GitHub-Mark-120px-plus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/boostcampwm-2021/WEB21-ShallWeSound/169272ba5855b5f76b277ff7a9fc94c674705f81/frontend/public/images/GitHub-Mark-120px-plus.png
--------------------------------------------------------------------------------
/frontend/public/images/GitHub-Mark-32px.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/boostcampwm-2021/WEB21-ShallWeSound/169272ba5855b5f76b277ff7a9fc94c674705f81/frontend/public/images/GitHub-Mark-32px.png
--------------------------------------------------------------------------------
/frontend/public/images/btn_google_signin_light_normal_web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/boostcampwm-2021/WEB21-ShallWeSound/169272ba5855b5f76b277ff7a9fc94c674705f81/frontend/public/images/btn_google_signin_light_normal_web.png
--------------------------------------------------------------------------------
/frontend/public/images/kakao.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/boostcampwm-2021/WEB21-ShallWeSound/169272ba5855b5f76b277ff7a9fc94c674705f81/frontend/public/images/kakao.png
--------------------------------------------------------------------------------
/frontend/public/images/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/boostcampwm-2021/WEB21-ShallWeSound/169272ba5855b5f76b277ff7a9fc94c674705f81/frontend/public/images/logo.png
--------------------------------------------------------------------------------
/frontend/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
12 |
13 |
17 |
18 |
27 | Shall We Sound?
28 |
29 |
30 |
31 |
32 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/frontend/public/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "short_name": "React App",
3 | "name": "Create React App Sample",
4 | "icons": [
5 | {
6 | "src": "favicon.ico",
7 | "sizes": "64x64 32x32 24x24 16x16",
8 | "type": "image/x-icon"
9 | }
10 | ],
11 | "start_url": ".",
12 | "display": "standalone",
13 | "theme_color": "#000000",
14 | "background_color": "#ffffff"
15 | }
16 |
--------------------------------------------------------------------------------
/frontend/public/robots.txt:
--------------------------------------------------------------------------------
1 | # https://www.robotstxt.org/robotstxt.html
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/frontend/src/components/App.tsx:
--------------------------------------------------------------------------------
1 | import { useState, useEffect} from 'react';
2 | import { Room } from '../pages/Room';
3 | import { MainPage } from '../pages/Main';
4 | import { ResultPage } from '../pages/Result';
5 | import { LoginPage } from '../pages/Login';
6 | import '../stylesheets/reset.css';
7 | import { BrowserRouter as Router, Route, Redirect, Switch } from 'react-router-dom';
8 | import { Cookies } from 'react-cookie';
9 | import config from '../config.host.json';
10 | import HeaderComponent from '../components/Header/Header';
11 |
12 | function App() {
13 | const cookies = new Cookies();
14 | const [jwt, ] = useState(cookies.get('jwt'));
15 | const [authenticate, setAuthenticate] = useState(false);
16 |
17 | const authAsync= async()=>{
18 | if (!jwt || jwt === undefined) {
19 | return false;
20 | }else{
21 | const result = await fetch(`${config.localhost}/oauth/authenticate`, {
22 | method: 'POST',
23 | credentials: 'include',
24 | headers: {
25 | 'Content-Type': 'application/json',
26 | },
27 | body: JSON.stringify({ jwt: cookies.get('jwt') }),
28 | })
29 | const authenticateResponse = await result.json();
30 | if(authenticate != authenticateResponse.isOK){
31 | setAuthenticate(authenticateResponse.isOK);
32 | }
33 | return true;
34 | }
35 |
36 | }
37 | useEffect(() => {
38 | (async()=>{
39 | await authAsync();
40 | })()
41 | }, [])
42 |
43 | return (
44 | <>
45 |
46 |
47 | {
51 | if (!authenticate) {
52 | return ;
53 | } else {
54 | return ;
55 | }
56 | }}
57 | />
58 | <>
59 |
60 | {
64 | if (!authenticate) {
65 | return ;
66 | } else {
67 | return ;
68 | }
69 | }}
70 | />
71 | {
75 | if (!authenticate) {
76 | return ;
77 | } else {
78 | return ;
79 | }
80 | }}
81 | />
82 | {
85 | if (!authenticate) {
86 | return ;
87 | } else {
88 | return ;
89 | }
90 | }}
91 | />
92 | {
95 | if (!authenticate) {
96 | return ;
97 | } else {
98 | return ;
99 | }
100 | }}
101 | />
102 | >
103 |
104 |
105 | >
106 | );
107 | }
108 |
109 | export default App;
110 |
--------------------------------------------------------------------------------
/frontend/src/components/Header/CreateRoomButton.tsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState, useRef } from 'react';
2 | import { RouteComponentProps } from 'react-router';
3 | import { Socket } from 'socket.io-client';
4 | import { useSocket } from '../../context/MyContext';
5 | import { apiFetch, fadeOut } from '../../hooks/utils';
6 | import '../../stylesheets/header.scss';
7 | import { Room } from '../../types';
8 |
9 | function CreateRoomModal({ history, onClose }: { history: RouteComponentProps['history']; onClose: () => void }) {
10 | const socket: Socket = useSocket()!;
11 | const alertRef = useRef(null);
12 | const [dialogInput, setDialogInput] = useState({
13 | id: '',
14 | name: '',
15 | description: '',
16 | totalUser: 0,
17 | });
18 |
19 | function changeDialogRoomName(e: React.BaseSyntheticEvent) {
20 | setDialogInput({
21 | ...dialogInput,
22 | name: e.target.value,
23 | });
24 | }
25 |
26 | function changeDialogRoomDescription(e: React.BaseSyntheticEvent) {
27 | setDialogInput({
28 | ...dialogInput,
29 | description: e.target.value,
30 | });
31 | }
32 |
33 | function createRoom() {
34 | if (
35 | dialogInput.name.split('').every(val => val === ' ') ||
36 | dialogInput.description.split('').every(val => val === ' ')
37 | ) {
38 | fadeOut(alertRef.current!);
39 | return;
40 | }
41 |
42 | if (dialogInput.name && dialogInput.description) {
43 | socket.emit('createRoom', {
44 | id: 0,
45 | name: dialogInput.name,
46 | description: dialogInput.description,
47 | });
48 |
49 | onClose();
50 | } else {
51 | fadeOut(alertRef.current!);
52 | }
53 | }
54 |
55 | return (
56 |
57 |
63 |
방 생성
64 |
78 |
79 |
82 |
85 |
86 | 공백만 입력할 수 없습니다.
87 | 다시 입력해주세요.
88 |
89 |
90 |
91 | 입력 칸을 다 채워 주세요
92 |
93 |
94 | );
95 | }
96 |
97 | function CreateRoomButton({ history }: { history: RouteComponentProps['history'] }) {
98 | const [viewModal, setViewModal] = useState(false);
99 | const socket: Socket = useSocket()!;
100 | const [locations, setLocation] = useState(window.location.pathname);
101 | function appearModal() {
102 | if (!window.location.pathname.includes('room')) {
103 | setViewModal(true);
104 | } else {
105 | socket.emit('leaveRoom');
106 | history.push('/main');
107 | }
108 | }
109 |
110 | function disappearModal() {
111 | setViewModal(false);
112 | }
113 |
114 | useEffect(() => {
115 | setLocation(window.location.pathname);
116 | });
117 |
118 | return (
119 |
120 |
146 | {viewModal &&
}
147 |
148 | );
149 | }
150 |
151 | export default CreateRoomButton;
152 |
--------------------------------------------------------------------------------
/frontend/src/components/Header/Header.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useRef } from 'react';
2 | import UploadModal from './UploadModal';
3 | import { timeoutRef } from '../../types';
4 | import { RouteComponentProps } from 'react-router';
5 | import CreateRoomButton from './CreateRoomButton';
6 | import { withRouter } from 'react-router-dom';
7 | import { useSocket } from '../../context/MyContext';
8 | import UserButton from './UserButton';
9 | import { Socket } from 'socket.io-client';
10 | import { useMediaQuery } from 'react-responsive';
11 |
12 | function HeaderComponent({ history }: { history: RouteComponentProps['history'] }) {
13 | const socket: Socket = useSocket()!;
14 | const timerRef = useRef({
15 | timer: setTimeout(() => {
16 | /*this is empty timer*/
17 | }),
18 | });
19 | const [searchInput, setSearchInput] = useState('');
20 | const [toggle, setToggle] = useState(false);
21 |
22 | function searchInputChange(e: React.ChangeEvent) {
23 | if (timerRef.current) {
24 | clearTimeout(timerRef.current.timer!);
25 | }
26 | const searchTimer = setTimeout(() => {
27 | setSearchInput(e.target.value);
28 | }, 17);
29 | timerRef.current.timer = searchTimer;
30 | }
31 |
32 | function goMain() {
33 | if (window.location.pathname.includes('room')) socket.emit('leaveRoom');
34 |
35 | history.push(`/main`);
36 | }
37 |
38 | function doSearch() {
39 | if (searchInput) {
40 | if (window.location.pathname.includes('room')) socket.emit('leaveRoom');
41 | history.push(`/result/${searchInput}`);
42 | }
43 | }
44 |
45 | function searchInputSubmit(e: React.KeyboardEvent) {
46 | if (e.key === 'Enter') {
47 | doSearch();
48 | }
49 | }
50 |
51 | const isPC = useMediaQuery({
52 | query: '(min-width: 900px)',
53 | });
54 |
55 | return (
56 |
57 |

58 |
59 | {(isPC || toggle) && (
60 | <>
61 |
62 |
63 |
64 | >
65 | )}
66 |
67 |
68 |
75 |

76 |
77 | {!isPC &&
78 |
setToggle(prev => !prev)}>
79 |
80 |
메뉴
81 |
82 | }
83 |
84 | );
85 | }
86 |
87 | export default withRouter(HeaderComponent);
88 |
--------------------------------------------------------------------------------
/frontend/src/components/Header/UploadModal.tsx:
--------------------------------------------------------------------------------
1 | import styles from '../../stylesheets/style.module.scss';
2 | import React, { useState, useRef} from 'react';
3 | import {FileType, timeoutRef, fileUploadObject} from '../../types'
4 | import uploadController from '../Util/uploadController';
5 |
6 | function UploadModalInner() {
7 | const alertRef: React.RefObject = useRef(null);
8 | const textAlertRef: React.RefObject = useRef(null);
9 | const fileAlertRef: React.RefObject = useRef(null);
10 | const singerRef = useRef(null);
11 | const descriptionRef = useRef(null);
12 | const musicFileRef = useRef(null);
13 | const thumbnailFileRef = useRef(null);
14 | const timerRef = useRef({timer:setTimeout(() => {/*초기화용 빈 타이머*/})});
15 | const [uploadedFile, setUploadedFile] = useState({
16 | musicName:'파일선택',
17 | thumbnailName: '파일선택',
18 | singer:'',
19 | descript:'',
20 | musicFile:null,
21 | thumbnailFile:null,
22 | });
23 |
24 | const isFileUpload = (e: React.ChangeEvent) => {
25 | uploadController.fileUploadController(e, setUploadedFile, uploadedFile)
26 | };
27 |
28 | const isThumbUpload = (e: React.ChangeEvent) => {
29 | uploadController.thumbnailUploadController(e, setUploadedFile, uploadedFile)
30 | };
31 |
32 | const fileUploadMethod = () => {
33 | const curObj:fileUploadObject={
34 | descriptionRef,
35 | singerRef,
36 | musicFileRef,
37 | thumbnailFileRef,
38 | uploadedFile,
39 | setUploadedFile,
40 | timerRef,
41 | textAlertRef,
42 | fileAlertRef
43 | }
44 | uploadController.fileUploadMethodController(curObj);
45 | };
46 |
47 | const writeSingerName = (e: React.ChangeEvent) => {
48 | uploadController.writeSingerNameController(e, timerRef, uploadedFile, setUploadedFile);
49 | };
50 |
51 | const writeDescription = (e: React.ChangeEvent) => {
52 | uploadController.writeDescriptionController(e, timerRef, uploadedFile, setUploadedFile);
53 | };
54 |
55 | const dropListener = (event: React.DragEvent) => {
56 | uploadController.dropListenerController(event, uploadedFile, setUploadedFile, alertRef);
57 | };
58 |
59 | const overrideEventDefaults = (event: Event | React.DragEvent) => {
60 | event.preventDefault();
61 | event.stopPropagation();
62 | };
63 |
64 | return (
65 |
66 |
67 |
77 |
86 |
95 |
음악파일
96 |
102 |
103 |
104 |
114 |
115 |
124 |
썸네일 이미지
125 |
131 |
132 |
142 |
143 |
144 |
147 |
148 |
149 | 음악은 mp3, 썸네일은 jpeg, png만 업로드 가능합니다!
150 |
151 |
152 | 아티스트 이름과 곡 설명은 반드시 적어주셔야 합니다!
153 |
154 |
155 | mp3 파일과 썸네일 이미지 파일를 반드시 첨부해주셔야 합니다!
156 |
157 |
158 | );
159 | }
160 |
161 | function UploadModal() {
162 | const [isModalVisible, setVisible] = useState(false);
163 |
164 | const modalVisibleChange = () => {
165 | setVisible(!isModalVisible);
166 | };
167 |
168 | return (
169 |
170 |
174 | {isModalVisible &&
}
175 |
176 | );
177 | }
178 |
179 | export default UploadModal;
180 |
181 |
--------------------------------------------------------------------------------
/frontend/src/components/Header/UserButton.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from "react";
2 | import { RouteComponentProps } from 'react-router';
3 | import { Cookies } from 'react-cookie';
4 |
5 | function UserModal({ onClose, history }: { onClose: () => void, history: RouteComponentProps['history'] }) {
6 | const cookies = new Cookies();
7 |
8 | function Logout () {
9 | cookies.remove('jwt');
10 | cookies.remove('userID');
11 | cookies.remove('userEmail');
12 | window.location.href=`/login`;
13 | }
14 |
15 | return (
16 |
17 |
23 |
안녕하세요,
{cookies.get('userID')} 님!
24 |
28 |
29 | );
30 | }
31 |
32 | function UserButton ({ history }: { history: RouteComponentProps['history'] }) {
33 | const [viewModal, setViewModal] = useState(false);
34 |
35 | function appearModal() {
36 | setViewModal(true);
37 | }
38 |
39 | function disappearModal() {
40 | setViewModal(false);
41 | }
42 | return (
43 |
44 |
48 | {viewModal &&
}
49 |
50 | )
51 | }
52 |
53 | export default UserButton;
54 |
--------------------------------------------------------------------------------
/frontend/src/components/Main/RoomItem.tsx:
--------------------------------------------------------------------------------
1 | import { Cookies } from 'react-cookie';
2 | import { useSocket } from '../../context/MyContext';
3 | import { Socket } from 'socket.io-client';
4 |
5 | const RoomItem = ({
6 | id,
7 | name,
8 | description,
9 | total,
10 | }: {
11 | id: string;
12 | name: string;
13 | description: string;
14 | total: string;
15 | }) => {
16 | const socket: Socket = useSocket()!;
17 | const cookies = new Cookies();
18 |
19 | const joinRoom = (e: React.MouseEvent) => {
20 | socket.emit('redundancyCheck', { userID: cookies.get('userID'), roomID: id });
21 | };
22 |
23 | return (
24 |
25 |
{name}
26 |
{description}
27 |
{total}
28 |
29 | );
30 | };
31 |
32 | export default RoomItem;
33 |
--------------------------------------------------------------------------------
/frontend/src/components/Room/Chat/ChatComponent.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useRef, useEffect } from 'react';
2 | import styles from '../../../stylesheets/style.module.scss';
3 | import * as _ from 'lodash';
4 | import { useSocket } from '../../../context/MyContext';
5 | import { Socket } from 'socket.io-client';
6 |
7 | interface ChatType {
8 | id: number;
9 | msg: string;
10 | }
11 | type event = React.ChangeEvent;
12 | function ChatComponent() {
13 | const socket: Socket = useSocket()!;
14 | const [chats, setChats] = useState([]);
15 | const [newChat, setNewChat] = useState('');
16 | const chatListRef = useRef(null);
17 | const scrollToBottom = () => {
18 | if (chatListRef.current) {
19 | chatListRef.current.scrollTop = chatListRef.current.scrollHeight;
20 | }
21 | };
22 | useEffect(() => {
23 | socket?.on('chatMessage', ({ id, msg }: ChatType) => {
24 | const curChat = _.cloneDeep(chats);
25 | curChat.push({ id: id, msg: msg });
26 | setChats(curChat);
27 | });
28 | scrollToBottom();
29 |
30 | return () => {
31 | socket.off('chatMessage');
32 | };
33 | }, [chats]);
34 |
35 | function MakeChatList() {
36 | const chatlist = chats.map((chat, idx) => {
37 | if (chat.id !== -1) {
38 | const writer = `by ${chat.id}`;
39 | return (
40 |
41 |
{writer}
42 |
{chat.msg}
43 |
44 | );
45 | } else {
46 | return (
47 |
50 | );
51 | }
52 | });
53 | return {chatlist}
;
54 | }
55 | const changeHandler = (e: event) => {
56 | setNewChat(e.target.value);
57 | };
58 | const clickHandler = () => {
59 | socket?.emit('chatMessage', newChat);
60 | const curChat = _.cloneDeep(chats);
61 | curChat.push({ id: -1, msg: newChat });
62 | setNewChat('');
63 | setChats(curChat);
64 | };
65 | const keyUpHandler = (e: React.KeyboardEvent) => {
66 | if (e.key === 'Enter') {
67 | clickHandler();
68 | }
69 | };
70 | return (
71 |
72 |
73 |
74 |
75 |
76 |
84 |
85 |
86 |
87 |
88 |
89 | );
90 | }
91 |
92 | export default ChatComponent;
93 |
--------------------------------------------------------------------------------
/frontend/src/components/Room/MusicPlayer/MusicPlayer.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect, useRef } from 'react';
2 | import { useSocket } from '../../../context/MyContext';
3 | import '../../../stylesheets/MusicPlayer.scss';
4 | import Title from './Title';
5 | import ThumbnailPlayer from './ThumbnailPlayer';
6 | import { Socket } from 'socket.io-client';
7 | import { music } from '../../../types';
8 | import Progress from '../../Util/Progress';
9 |
10 | function MusicPlayer({ isHost }: { isHost: boolean }) {
11 | const socket: Socket = useSocket()!;
12 | const musicControl = useRef(null);
13 | const [musicInfo, setMusicInfo] = useState();
14 | const [musicPlayerState, setMusicPlayerState] = useState({
15 | currentTime: "0:00",
16 | duration: "0:00",
17 | progressDegree: 0,
18 | });
19 | const [musicVolumeState, setMusicVolumeState] = useState({
20 | volume: 10,
21 | backupVolume: 50,
22 | progressDegree: 10,
23 | })
24 |
25 | const playController = (playType: string) => {
26 | switch (playType) {
27 | case 'play':
28 | musicControl.current?.play();
29 | break;
30 | case 'pause':
31 | musicControl.current?.pause();
32 | break;
33 | default:
34 | if (musicControl.current) {
35 | musicControl.current.currentTime = parseInt(playType);
36 | }
37 | }
38 | };
39 |
40 | const sync = (hostCurrentTime: number) => {
41 | if (musicControl.current) {
42 | musicControl.current.currentTime = hostCurrentTime;
43 | }
44 | };
45 |
46 | const emitHostCurrentTime = () => {
47 | socket.emit('responseTime', musicControl.current?.currentTime);
48 | };
49 |
50 | const setInfo = (musicData: music) => {
51 | setMusicInfo({
52 | ...musicInfo,
53 | ...musicData,
54 | });
55 | };
56 |
57 | const autoPlayFake = () => {
58 | setTimeout(() => {
59 | if (musicControl.current) {
60 | musicControl.current.muted = false;
61 | }
62 | }, 200);
63 | };
64 |
65 | function goPrevMusic() {
66 | socket.emit('prevMusicReq');
67 | }
68 | function goNextMusic() {
69 | socket.emit('nextMusicReq');
70 | }
71 |
72 | function changeFormatToTime(number: number) {
73 | const minute = Math.floor(number / 60);
74 | const second = Math.floor(number % 60);
75 | const formattedSecond = second >= 10 ? second : '0' + second.toString();
76 |
77 | return `${minute}:${formattedSecond}`;
78 | }
79 |
80 | function playOrPauseMusic() {
81 | const playingMusic = musicControl?.current;
82 | if (playingMusic?.paused) {
83 | playingMusic.play();
84 | playingMusic.onplay = () => {
85 | socket.emit('playControl', 'play');
86 | };
87 | } else if (playingMusic?.paused === false) {
88 | playingMusic.pause();
89 | playingMusic.onpause = () => {
90 | socket.emit('playControl', 'pause');
91 | };
92 | }
93 | }
94 |
95 | function updateMusic() {
96 | musicControl?.current?.play();
97 | }
98 |
99 | function updateCurrentTime() {
100 | const playingMusic = musicControl.current;
101 | if (playingMusic) {
102 | setMusicPlayerState({
103 | ...musicPlayerState,
104 | currentTime: changeFormatToTime(playingMusic.currentTime),
105 | duration: changeFormatToTime(playingMusic.duration),
106 | progressDegree: playingMusic.currentTime * 100 / playingMusic.duration,
107 | });
108 | playingMusic.onseeked = () => {
109 | socket.emit('playControl', playingMusic.currentTime);
110 | };
111 | }
112 | }
113 |
114 | function onChangeMusicProgress(val: number) {
115 | const playingMusic = musicControl.current;
116 | if (playingMusic) {
117 | playingMusic.currentTime = val;
118 | updateCurrentTime();
119 | }
120 | }
121 |
122 | function onChangeVolume(e: number) {
123 | const playingMusic = musicControl.current;
124 | if (playingMusic) {
125 | playingMusic.volume = e / 100;
126 | setMusicVolumeState({
127 | ...musicVolumeState,
128 | volume: e,
129 | progressDegree: e,
130 | });
131 | }
132 | }
133 |
134 | function toggleVolume() {
135 | const playingMusic = musicControl.current;
136 | if (playingMusic) {
137 | if (playingMusic.volume > 0) {
138 | setMusicVolumeState({
139 | ...musicVolumeState,
140 | volume: 0,
141 | backupVolume: playingMusic.volume * 100,
142 | progressDegree: 0,
143 | });
144 | playingMusic.volume = 0;
145 | } else {
146 | setMusicVolumeState({
147 | ...musicVolumeState,
148 | volume: musicVolumeState.backupVolume,
149 | progressDegree: musicVolumeState.backupVolume,
150 | })
151 | playingMusic.volume = musicVolumeState.backupVolume / 100;
152 | }
153 | }
154 | }
155 |
156 | useEffect(() => {
157 | socket.on('requestTime', emitHostCurrentTime);
158 | socket.on('sync', sync);
159 | socket.on('changeMusicInfo', setInfo);
160 | socket.on('playControl', playController);
161 | autoPlayFake();
162 | }, []);
163 |
164 | useEffect(()=>{
165 | if(musicControl && musicControl.current) musicControl.current.volume = 0.1;
166 |
167 | }, []);
168 |
169 |
170 | let musicProgressProps = {
171 | tops: [musicPlayerState.currentTime, musicPlayerState.duration],
172 | min: 0,
173 | max: musicControl.current && musicControl.current.duration,
174 | progressDegree: musicPlayerState.progressDegree,
175 | disabled: !isHost,
176 | onChange: onChangeMusicProgress,
177 | }
178 |
179 | let musicVolumeProps = {
180 | lefts: [musicControl.current?.volume === 0 ? (
181 |
182 | ) : (
183 |
184 | )],
185 | min: 0,
186 | max: 100,
187 | progressDegree: musicVolumeState.progressDegree,
188 | onChange: onChangeVolume,
189 | }
190 |
191 | return (
192 | <>
193 |
194 |
203 |
204 |
205 |

206 |
212 |

213 |
214 |
215 |
216 |
219 | {isHost &&
220 |
221 |

222 | {musicControl.current?.paused ?
223 |

:
224 |

225 | }
226 |

227 |
228 | }
229 |
230 |
231 | >
232 | );
233 | }
234 |
235 | export default MusicPlayer;
236 |
--------------------------------------------------------------------------------
/frontend/src/components/Room/MusicPlayer/ThumbnailPlayer.tsx:
--------------------------------------------------------------------------------
1 | import { useState, MouseEventHandler } from 'react';
2 |
3 |
4 | function ThumbnailPlayer({
5 | name,
6 | thumbnail,
7 | musicControl,
8 | onClick,
9 | }: {
10 | name: string | undefined;
11 | thumbnail: string | undefined;
12 | musicControl: React.MutableRefObject;
13 | onClick: MouseEventHandler;
14 | }) {
15 | const [isHover, setIsHover] = useState(false);
16 | function onMouseEnter() {
17 | setIsHover(true);
18 | }
19 | function onMouseLeave() {
20 | setIsHover(false);
21 | }
22 |
23 | return (
24 |
25 |
26 | {thumbnail ? (
27 |

28 | ) : (
29 |

30 | )}
31 | {isHover && (
32 | <>
33 |
34 | {musicControl.current?.paused ? (
35 |

36 | ) : (
37 |

38 | )}
39 | >
40 | )}
41 |
42 |
43 | );
44 | }
45 |
46 | export default ThumbnailPlayer;
47 |
--------------------------------------------------------------------------------
/frontend/src/components/Room/MusicPlayer/Title.tsx:
--------------------------------------------------------------------------------
1 | import { useRef } from 'react';
2 | import styled, { keyframes } from 'styled-components';
3 | import '../../../stylesheets/palette.scss';
4 |
5 | function Title({ name = 'Title', singer = 'Singer' }: { name: string | undefined; singer: string | undefined }) {
6 | const movedItem = useRef(null);
7 |
8 | const isOverflow = () => {
9 | if (!movedItem.current) return false;
10 | return movedItem.current.scrollWidth > movedItem.current.clientWidth;
11 | };
12 |
13 | return (
14 |
15 |
16 |
17 | {name}
18 |
19 |
20 | {singer}
21 |
22 | );
23 | }
24 |
25 | const moveTitle = (length: number, isOverflow: boolean) => {
26 | if (!isOverflow) return null;
27 |
28 | const point = -length * 3.8;
29 |
30 | return keyframes`
31 | from {
32 | transform: translateX(0%)
33 | }
34 | to {
35 | transform: translateX(${point}%)
36 | }
37 | `;
38 | };
39 |
40 | const Wrapper = styled.div`
41 | box-sizing: border-box;
42 | outline: thick double #f9f9f9;
43 | border-radius: 0.5rem;
44 | color: #f9f9f9;
45 | padding: 0.5rem;
46 | width: 100%;
47 | text-align: center;
48 | display: flex;
49 | flex-direction: column;
50 | white-space: nowrap;
51 | `;
52 |
53 | const TitleWrapper = styled.div`
54 | font-size: 1.75rem;
55 | font-weight: 700;
56 | overflow: hidden;
57 | text-overflow: ellipsis;
58 | margin-bottom: 0.25rem;
59 | `;
60 |
61 | interface TitleTextProps {
62 | length: number;
63 | isOverflow: boolean;
64 | }
65 |
66 | const TitleText = styled.div`
67 | animation: ${props => moveTitle(props.length, props.isOverflow)} ${props => props.length / 5}s linear infinite;
68 | animation-delay: 1s;
69 | overflow: visible;
70 | `;
71 |
72 | const SingerWrapper = styled.div`
73 | font-style: italic;
74 | font-size: 1.25rem;
75 | overflow: hidden;
76 | text-overflow: ellipsis;
77 | `;
78 |
79 | export default Title;
80 |
--------------------------------------------------------------------------------
/frontend/src/components/Room/PlayList/MusicSearch/MusicSearch.tsx:
--------------------------------------------------------------------------------
1 | import { useState, useRef, useEffect, useReducer, useCallback } from 'react';
2 | import styled from 'styled-components';
3 | import config from '../../../../config.host.json';
4 | import SearchBar from '../../../Util/SearchBar';
5 | import MusicSearchItem from './MusicSearchItem';
6 | import CircleButton from '../../../Util/CircleButton';
7 | import { useSocket } from '../../../../context/MyContext';
8 | import PopUp from '../../../Util/PopUp';
9 | import Loading from '../../../Util/Loading';
10 | import { Music } from '../../../../types';
11 | import { reducer as addMusicStatusReducer } from './reducer/addMusicState';
12 | import { reducer as searchResultReducer } from './reducer/searchResult';
13 |
14 | import { useInfiniteScroll } from '../../../../hooks/useinfiniteScroll';
15 | import ScrollBar from '../../../Util/scrollbar';
16 |
17 | const MusicSearch = () => {
18 | const socket: any = useSocket();
19 | const scrollBar = useRef(null);
20 | const page = useRef(0);
21 | const [keyword, setKeyword] = useState('');
22 | const [searchResult, dispatchSearchResult] = useReducer(searchResultReducer, {
23 | result: [],
24 | selectedMusicInResult: [],
25 | hasMore: false,
26 | loading: false,
27 | });
28 | const [addMusicState, dispatchAddMusicState] = useReducer(addMusicStatusReducer, {
29 | success: false,
30 | fail: false,
31 | });
32 |
33 | const { result, selectedMusicInResult, hasMore, loading } = searchResult;
34 | const { success, fail } = addMusicState;
35 |
36 | const fetchMusic = useCallback(
37 | async (more = true) => {
38 | dispatchSearchResult({ type: 'FETCH_LOADING' });
39 | try {
40 | const res = await fetch(`${config.localhost}/api/music?keyword=${keyword}&page=${page.current}`);
41 | const json = await res.json();
42 | const musics = json.result;
43 |
44 | if (more) {
45 | dispatchSearchResult({ type: 'FETCH_MORE_SUCCESS', result: musics, hasMore: json.hasMore });
46 | } else {
47 | dispatchSearchResult({ type: 'FETCH_SUCCESS', result: musics, hasMore: json.hasMore });
48 | scrollBar.current?.scrollTo(0, 0);
49 | }
50 | } catch (e) {
51 | dispatchSearchResult({ type: 'INIT' });
52 | }
53 | },
54 | [keyword],
55 | );
56 |
57 | useEffect(() => {
58 | let popUpTimer: NodeJS.Timeout;
59 |
60 | socket.on('duplicatedMusicInPlayList', () => {
61 | dispatchAddMusicState({ type: 'FAILURE' });
62 |
63 | popUpTimer = setTimeout(() => {
64 | dispatchAddMusicState({ type: 'INIT' });
65 | }, 700);
66 | });
67 |
68 | socket.on('successAddMusic', () => {
69 | dispatchAddMusicState({ type: 'SUCCESS' });
70 |
71 | popUpTimer = setTimeout(() => {
72 | dispatchAddMusicState({ type: 'INIT' });
73 | }, 700);
74 | });
75 |
76 | return () => {
77 | socket.off('duplicatedMusicInPlayList');
78 | socket.off('successAddMusic');
79 | clearTimeout(popUpTimer);
80 | };
81 | }, [socket]);
82 |
83 | useEffect(() => {
84 | page.current = 0;
85 | fetchMusic(false);
86 | }, [fetchMusic]);
87 |
88 | useEffect(() => {
89 | page.current = result.length;
90 | }, [result]);
91 |
92 | const onKeywordChange = (value: string) => {
93 | setKeyword(value);
94 | };
95 |
96 | const isSelected = (MID: number): boolean => (selectedMusicInResult.indexOf(MID) >= 0 ? true : false);
97 |
98 | const onSelectMusic = (MID: number) => {
99 | if (isSelected(MID)) {
100 | const newSelectedList = selectedMusicInResult.filter((id: number) => id !== MID);
101 | dispatchSearchResult({ type: 'SELECT_MUSIC', selectedInResult: newSelectedList });
102 | } else {
103 | dispatchSearchResult({ type: 'SELECT_MUSIC', selectedInResult: [...selectedMusicInResult, MID] });
104 | }
105 | };
106 |
107 | const addMusicInPlayList = () => {
108 | socket.emit('addMusicInPlayListReq', selectedMusicInResult);
109 |
110 | dispatchSearchResult({ type: 'REQUEST_ADD_MUSIC_IN_PLAYLIST' });
111 | };
112 |
113 | const setObserveTarget = useInfiniteScroll(fetchMusic);
114 |
115 | if (fail) {
116 | return (
117 |
118 |
119 |
120 | );
121 | }
122 |
123 | if (success) {
124 | return (
125 |
126 |
127 |
128 | );
129 | }
130 |
131 | return (
132 |
133 |
134 |
135 |
136 | {result.length
137 | ? result.map((music: Music, i: number) => (
138 | onSelectMusic(+music.MID)}
146 | />
147 | ))
148 | : !loading && 검색 결과 없음
}
149 |
150 | {loading ? : null}
151 |
152 |
153 |
154 |
155 | +
156 |
157 |
158 |
159 | );
160 | };
161 |
162 | const Layout = styled.div`
163 | display: flex;
164 | flex-direction: column;
165 | align-items: center;
166 | height: 100%;
167 | `;
168 |
169 | const ResultWrapper = styled(Layout)`
170 | line-height: 1.2rem;
171 | overflow-x: hidden;
172 | `;
173 |
174 | const ButtonWrapper = styled.div`
175 | position: absolute;
176 | bottom: 1rem;
177 | left: 50%;
178 | transform: translateX(-50%);
179 | `;
180 |
181 | const PopUpWrapper = styled.div`
182 | position: fixed;
183 | top: 50%;
184 | left: 50%;
185 | transform: translate(-50%, -50%);
186 | `;
187 |
188 | const Spinner = styled.div`
189 | margin: 0 50.7%;
190 | `;
191 |
192 | export default MusicSearch;
193 |
--------------------------------------------------------------------------------
/frontend/src/components/Room/PlayList/MusicSearch/MusicSearchItem.tsx:
--------------------------------------------------------------------------------
1 | import { useState, useRef } from 'react';
2 | import styled, { keyframes } from 'styled-components';
3 |
4 | interface Props {
5 | name: string;
6 | singer: string;
7 | description: string;
8 | thumbnail: string;
9 | selected: boolean;
10 | onClick?: any;
11 | }
12 |
13 | const MusicSearchItem = ({ name, singer, thumbnail, description, selected, onClick }: Props) => {
14 | const item = useRef(null);
15 | const [detail, setDetail] = useState(false);
16 | const onDetail = () => {
17 | setDetail(true);
18 | };
19 | const onDetailOut = () => {
20 | setDetail(false);
21 | };
22 |
23 | const isOverflow = () => {
24 | if (!item.current) return false;
25 | return item.current.scrollWidth > item.current.clientWidth;
26 | };
27 |
28 | return (
29 | <>
30 |
31 |
32 |
33 | {name}
34 | {singer}
35 |
36 |
37 |
38 | {detail ? (
39 |
40 | {description}
41 |
42 | ) : null}
43 | >
44 | );
45 | };
46 |
47 | const moveTitle = (length: number, isOverflow: boolean) => {
48 | if (!isOverflow) return null;
49 |
50 | const point = -(length * 5);
51 |
52 | return keyframes`
53 | from {
54 | transform: translateX(0%)
55 | }
56 | to {
57 | transform: translateX(${point}%)
58 | }
59 | `;
60 | };
61 |
62 | interface SearchResultItemProps {
63 | selected: boolean;
64 | length: number;
65 | isOverflow: boolean;
66 | }
67 |
68 | const Title = styled.div`
69 | font-size: 16px;
70 | padding: 0.2rem 0;
71 | overflow: hidden;
72 | text-overflow: ellipsis;
73 | `;
74 |
75 | const SearchResultItem = styled.div`
76 | display: flex;
77 | flex-direction: row;
78 | align-items: center;
79 | justify-content: space-between;
80 | padding: 0.6rem;
81 | width: 15rem;
82 | height: 3rem;
83 | border-bottom: 1px solid #f2f3f4;
84 | border-radius: 0.3rem;
85 | cursor: pointer;
86 |
87 | background-color: ${prop => (prop.selected ? '#e5e7e9' : '#ffffff')};
88 |
89 | &:hover {
90 | background-color: #f2f3f4;
91 |
92 | ${Title} {
93 | animation: ${props => moveTitle(props.length, props.isOverflow)} ${props => props.length / 7}s linear infinite;
94 | animation-delay: 0.5s;
95 | overflow: visible;
96 | }
97 | }
98 |
99 | &:active {
100 | background-color: #e5e7e9;
101 | }
102 | `;
103 |
104 | const Image = styled.img`
105 | width: 3rem;
106 | margin: 0 0.8rem 0 0;
107 | display: flex;
108 | align-items: center;
109 | font-size: 0.5rem;
110 | `;
111 |
112 | const TextWrapper = styled.div`
113 | display: flex;
114 | flex-direction: column;
115 | justify-content: center;
116 | white-space: nowrap;
117 | overflow: hidden;
118 | width: calc(100% * 0.8);
119 | padding: 0 0.2rem;
120 | `;
121 |
122 | const Singer = styled.div`
123 | font-size: 14px;
124 | color: #969696;
125 | `;
126 |
127 | const DescriptionIcon = styled.div`
128 | position: relative;
129 | width: 3px;
130 | height: 3px;
131 | border-radius: 50%;
132 | background-color: #d3d3d3;
133 |
134 | &:before,
135 | &:after {
136 | content: '';
137 | position: absolute;
138 | width: 3px;
139 | height: 3px;
140 | background-color: inherit;
141 | border-radius: inherit;
142 | }
143 |
144 | &:before {
145 | top: -5px;
146 | }
147 |
148 | &:after {
149 | top: 5px;
150 | }
151 | `;
152 |
153 | const Description = styled.div`
154 | width: 14.5rem;
155 | font-size: 0.8rem;
156 | border: 1px solid #cacfd2;
157 | color: #969696;
158 | border-radius: 0.5rem;
159 | padding: 0.8rem;
160 | text-align: justify;
161 | display: flex;
162 | justify-content: center;
163 | `;
164 |
165 | export default MusicSearchItem;
166 |
--------------------------------------------------------------------------------
/frontend/src/components/Room/PlayList/MusicSearch/reducer/addMusicState.tsx:
--------------------------------------------------------------------------------
1 | interface Action {
2 | type: string;
3 | }
4 |
5 | interface State {
6 | success: boolean;
7 | fail: boolean;
8 | }
9 |
10 | export const reducer = (state: State, action: Action) => {
11 | switch (action.type) {
12 | case 'INIT':
13 | return {
14 | success: false,
15 | fail: false,
16 | };
17 | case 'SUCCESS':
18 | return {
19 | success: true,
20 | fail: false,
21 | };
22 | case 'FAILURE':
23 | return {
24 | success: false,
25 | fail: true,
26 | };
27 | default:
28 | return {
29 | ...state,
30 | };
31 | }
32 | };
33 |
--------------------------------------------------------------------------------
/frontend/src/components/Room/PlayList/MusicSearch/reducer/searchResult.tsx:
--------------------------------------------------------------------------------
1 | import { Music } from '../../../../../types';
2 |
3 | interface State {
4 | result: Music[];
5 | selectedMusicInResult: number[];
6 | hasMore?: boolean;
7 | loading?: boolean;
8 | }
9 |
10 | interface Action {
11 | type: string;
12 | result?: Music[];
13 | selectedInResult?: number[];
14 | hasMore?: boolean;
15 | loading?: boolean;
16 | }
17 |
18 | export const reducer = (state: State, action: Action) => {
19 | switch (action.type) {
20 | case 'INIT':
21 | return {
22 | result: [],
23 | selectedMusicInResult: [],
24 | hasMore: false,
25 | loading: false,
26 | };
27 | case 'FETCH_LOADING':
28 | return {
29 | ...state,
30 | loading: true,
31 | };
32 | case 'FETCH_SUCCESS':
33 | return {
34 | result: action.result ?? [],
35 | selectedMusicInResult: [],
36 | hasMore: action.hasMore,
37 | loading: false,
38 | };
39 | case 'FETCH_MORE_SUCCESS':
40 | return {
41 | ...state,
42 | result: [...state.result, ...(action.result ?? [])],
43 | hasMore: action.hasMore,
44 | loading: false,
45 | };
46 | case 'REQUEST_ADD_MUSIC_IN_PLAYLIST':
47 | return {
48 | ...state,
49 | selectedMusicInResult: [],
50 | loading: false,
51 | };
52 | case 'SELECT_MUSIC':
53 | return {
54 | ...state,
55 | selectedMusicInResult: action.selectedInResult ?? [],
56 | };
57 | default:
58 | return {
59 | ...state,
60 | };
61 | }
62 | };
63 |
--------------------------------------------------------------------------------
/frontend/src/components/Room/PlayList/PlayList.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState, useEffect } from 'react';
2 | import styled from 'styled-components';
3 | import type { Music } from '../../../types';
4 | import PlayListItem from './PlayListItem';
5 | import CircleButton from '../../Util/CircleButton';
6 | import Modal from '../../Util/Modal';
7 | import MusicSearch from './MusicSearch/MusicSearch';
8 | import { useSocket } from '../../../context/MyContext';
9 | import ScrollBar from '../../Util/scrollbar';
10 |
11 | const PlayList = ({ isHost }: { isHost: boolean }) => {
12 | const socket: any = useSocket();
13 | const [modalVisible, setModalVisible] = useState(false);
14 | const [playList, setPlayList] = useState([]);
15 |
16 | useEffect(() => {
17 | socket.on('responsePlayList', (data: Music[]) => {
18 | setPlayList([...data]);
19 | });
20 |
21 | return () => {
22 | socket.off('responsePlayList');
23 | };
24 | }, [socket]);
25 |
26 | const toggleModal = () => setModalVisible(!modalVisible);
27 |
28 | return (
29 |
30 | P L A Y L I S T
31 |
32 | {playList.length !== 0 ? (
33 | playList.map((music: Music, i: number) => (
34 |
42 | ))
43 | ) : (
44 | 방장이 아직 곡을 추가하지 않았습니다. 잠시만 기다려주세요!
45 | )}
46 |
47 |
48 | {isHost && (
49 |
50 | +
51 |
52 | )}
53 |
54 |
55 | {modalVisible ? (
56 |
57 |
58 |
59 | ) : null}
60 |
61 | );
62 | };
63 |
64 | const Container = styled.div`
65 | background: #beaee2;
66 | border-radius: 10px;
67 | width: 400px;
68 | height: 300px;
69 | float: right;
70 | position: relative;
71 | margin-right: 2rem;
72 |
73 | @media screen and (min-height: 768px) {
74 | height: calc(100% - 220px - 1rem);
75 | }
76 |
77 | @media screen and (min-height: 968px) {
78 | height: calc(100% - 420px - 1rem);//300px;
79 | }
80 | `;
81 |
82 | const Title = styled.div`
83 | color: #ffffff;
84 | font-weight: 500;
85 | font-size: 16px;
86 | display: flex;
87 | align-items: center;
88 | justify-content: center;
89 | height: 30px;
90 | margin: 10px 0px;
91 | `;
92 |
93 | const ButtonWrapper = styled.div`
94 | position: absolute;
95 | bottom: 30px;
96 | left: 50%;
97 | transform: translateX(-50%);
98 | `;
99 |
100 | export default PlayList;
101 |
--------------------------------------------------------------------------------
/frontend/src/components/Room/PlayList/PlayListItem.tsx:
--------------------------------------------------------------------------------
1 | import React, { useState } from 'react';
2 | import styled from 'styled-components';
3 | import { useSocket } from '../../../context/MyContext';
4 |
5 | type Props = {
6 | MID: number;
7 | title: string;
8 | singer: string;
9 | isPlayed: boolean;
10 | isHost: boolean;
11 | };
12 |
13 | type TextProps = {
14 | color: string;
15 | weight: string;
16 | size: string;
17 | };
18 |
19 | const PlayListItem = ({ MID, title, singer, isPlayed, isHost }: Props) => {
20 | const socket: any = useSocket();
21 | const [isHover, setIsHover] = useState(false);
22 |
23 | const hoverOn = () => setIsHover(true);
24 | const hoverOut = () => setIsHover(false);
25 |
26 | const clickPlay = () => {
27 | if (isHost) socket.emit('clickAndPlayMusic', title);
28 | };
29 |
30 | const onRemove = (e: React.MouseEvent) => {
31 | e.stopPropagation();
32 | socket.emit('removeMusicInPlayListReq', MID);
33 | };
34 |
35 | return (
36 | -
37 |
38 |
39 |
40 | {title}
41 |
42 |
43 | {singer}
44 |
45 |
46 | {isHover && isHost ? X : }
47 |
48 |
49 | );
50 | };
51 |
52 | const Item = styled.div<{ isPlayed: boolean }>`
53 | height: 50px;
54 | margin: 0px 20px;
55 | padding: 4px 0px;
56 | line-height: 25px;
57 | background: ${props => (props.isPlayed ? '#ffffff1a' : 'transparent')};
58 |
59 | &:not(:last-child) {
60 | border-bottom: 1px solid #ecdff5;
61 | }
62 | `;
63 |
64 | const Layout = styled.div`
65 | display: flex;
66 | justify-content: space-between;
67 | align-items: center;
68 |
69 | &:hover {
70 | cursor: pointer;
71 | opacity: 0.5;
72 | }
73 | `;
74 |
75 | const TextWrapper = styled.div`
76 | width: 100%;
77 | white-space: nowrap;
78 | overflow: hidden;
79 | `;
80 |
81 | const Text = styled.div`
82 | color: ${props => props.color};
83 | font-weight: ${props => props.weight};
84 | font-size: ${props => props.size};
85 | margin: 0px 10px;
86 | overflow: hidden;
87 | text-overflow: ellipsis;
88 | `;
89 |
90 | const Detail = styled.div`
91 | position: relative;
92 | width: 4px;
93 | height: 4px;
94 | border-radius: 50%;
95 | background-color: #ffffff;
96 | margin-right: 10px;
97 |
98 | &:before,
99 | &:after {
100 | content: '';
101 | position: absolute;
102 | width: 4px;
103 | height: 4px;
104 | background-color: inherit;
105 | border-radius: inherit;
106 | }
107 |
108 | &:before {
109 | top: -7px;
110 | }
111 |
112 | &:after {
113 | top: 7px;
114 | }
115 | `;
116 |
117 | const CancelButton = styled.button`
118 | background: transparent;
119 | border: none;
120 | color: #ffffff;
121 | cursor: pointer;
122 | `;
123 |
124 | export default PlayListItem;
125 |
--------------------------------------------------------------------------------
/frontend/src/components/Room/UserList/UserItem.tsx:
--------------------------------------------------------------------------------
1 | import { Socket } from 'socket.io-client';
2 | import React, { useState } from 'react';
3 | import styled from 'styled-components';
4 | import { useSocket } from '../../../context/MyContext';
5 | const UserSelectModal = ({ userName, off }: { userName: string; off: Function }) => {
6 | const [color, setColor] = useState('black');
7 | const socket: Socket = useSocket()!;
8 | const delegateEvent = () => {
9 | socket.emit('delegateManual', userName);
10 | off();
11 | };
12 |
13 | return (
14 | <>
15 | {
17 | setColor('#cdf0ea');
18 | }}
19 | onMouseLeave={() => {
20 | setColor('black');
21 | }}
22 | color={color}
23 | onClick={delegateEvent}
24 | >
25 | 방장 위임
26 |
27 | >
28 | );
29 | };
30 |
31 | const UserItem = ({ userString, userName, isHost }: { userString: string; userName: string; isHost: boolean }) => {
32 | const [isClicked, setIsClicked] = useState(false);
33 |
34 | const clickUserItem = () => {
35 | if (!userString.includes('👑')) isClicked ? setIsClicked(false) : setIsClicked(true);
36 | };
37 |
38 | const off = () => {
39 | setIsClicked(false);
40 | };
41 |
42 | return (
43 | <>
44 |
45 |
46 | {userString}
47 |
48 | {isClicked && isHost ? : null}
49 |
50 | >
51 | );
52 | };
53 |
54 | export default UserItem;
55 |
56 | const Delegate = styled.span`
57 | position: absolute;
58 | padding-left: 15px;
59 | cursor: pointer;
60 | color: ${props => props.color};
61 | `;
62 |
--------------------------------------------------------------------------------
/frontend/src/components/Room/UserList/UserList.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import '../../../stylesheets/userList.scss';
3 | import { Socket } from 'socket.io-client';
4 | import { useSocket } from '../../../context/MyContext';
5 | import ScrollBar from '../../Util/scrollbar';
6 | import UserItem from './UserItem';
7 |
8 | const UserList = ({ user, isHost }: { user: string[]; isHost: boolean }) => {
9 | const socket: Socket = useSocket();
10 |
11 | const userList = user.map((val, idx) => {
12 | if (idx === 0 && val === socket.id) return `👑 ${val} (나)`;
13 | else if (idx === 0) return `👑 ${val}`;
14 | else if (val === socket.id) return `🧑 ${val} (나)`;
15 | else return `🧑 ${val}`;
16 | });
17 |
18 | return (
19 |
20 |
참가자 {user.length}명
21 |
22 |
23 |
24 | {userList.map((userName, idx) => (
25 | <>
26 |
27 | >
28 | ))}
29 |
30 |
31 |
32 | );
33 | };
34 |
35 | export default UserList;
36 |
--------------------------------------------------------------------------------
/frontend/src/components/Util/CircleButton.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import styled from 'styled-components';
3 |
4 | interface Props {
5 | children: string;
6 | size: string;
7 | colorP: string;
8 | onClick?: () => void;
9 | }
10 |
11 | const CircleButton = ({ children, size, colorP, onClick }: Props) => {
12 | return (
13 | <>
14 |
15 | {children}
16 |
17 | >
18 | );
19 | };
20 |
21 | const StyledButton = styled.button`
22 | width: ${props => props.size};
23 | height: ${props => props.size};
24 | background: ${props => props.colorP};
25 | border-radius: 50%;
26 | border: none;
27 | padding: 0;
28 | box-shadow: rgb(0 0 0 / 30%) 0px 10px 25px;
29 | cursor: pointer;
30 |
31 | &:hover {
32 | transform: scale(0.95);
33 | }
34 | `;
35 |
36 | export default CircleButton;
37 |
--------------------------------------------------------------------------------
/frontend/src/components/Util/Loading.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import styled, { keyframes } from 'styled-components';
3 |
4 | const Loading = () => {
5 | return ;
6 | };
7 |
8 | const spin = keyframes`
9 | from {
10 | transform:translate(-50%, -50%) rotate(0);
11 | }
12 | to {
13 | transform:translate(-50%, -50%) rotate(360deg);
14 | }
15 | `;
16 |
17 | const Circle = styled.div`
18 | border-radius: 100%;
19 | border: 5px solid#ffffff;
20 | border-top-color: #d3d3d3;
21 | width: 15px;
22 | height: 15px;
23 | animation: ${spin} 1s infinite;
24 | `;
25 |
26 | export default Loading;
27 |
--------------------------------------------------------------------------------
/frontend/src/components/Util/Modal.tsx:
--------------------------------------------------------------------------------
1 | import { useEffect } from 'react';
2 | import styled, { keyframes } from 'styled-components';
3 |
4 | interface Props {
5 | widthP: string;
6 | heightP: string;
7 | onToggle: () => void;
8 | children: JSX.Element;
9 | }
10 |
11 | interface StyledProps {
12 | widthP: string;
13 | heightP: string;
14 | }
15 |
16 | const Modal = ({ widthP, heightP, onToggle, children }: Props) => {
17 | useEffect(() => {
18 | document.body.style.overflow = 'hidden';
19 |
20 | return () => {
21 | document.body.style.overflow = 'auto';
22 | };
23 | }, []);
24 |
25 | return (
26 | <>
27 |
28 | e.stopPropagation()}>
29 |
30 | X
31 |
32 | {children}
33 |
34 | >
35 | );
36 | };
37 |
38 | const moveUp = keyframes`
39 | from {
40 | top: 70%
41 | }
42 | to {
43 | top: 50%
44 | }
45 | `;
46 |
47 | const ModalOverlay = styled.div`
48 | box-sizing: border-box;
49 | position: fixed;
50 | top: 0;
51 | left: 0;
52 | bottom: 0;
53 | right: 0;
54 | background: rgba(0, 0, 0, 0.4);
55 | z-index: 100;
56 | `;
57 |
58 | const StyledModal = styled.div`
59 | width: ${props => props.widthP};
60 | height: ${props => props.heightP};
61 | background: #ffffff;
62 | border-radius: 10px;
63 | box-shadow: rgb(0 0 0 / 100%) 0px 10px 25px;
64 | position: fixed;
65 | top: 50%;
66 | left: 50%;
67 | transform: translate(-50%, -50%);
68 | z-index: 200;
69 | animation: ${moveUp} 0.5s ease-out;
70 | `;
71 |
72 | const Head = styled.div`
73 | height: 3rem;
74 | display: flex;
75 | align-items: center;
76 | justify-content: flex-end;
77 | padding: 0px 15px;
78 | `;
79 |
80 | const CloseButton = styled.button`
81 | width: 20px;
82 | height: 20px;
83 | cursor: pointer;
84 | background-color: transparent;
85 | border: none;
86 | padding: 0;
87 | `;
88 |
89 | export default Modal;
90 |
--------------------------------------------------------------------------------
/frontend/src/components/Util/PopUp.tsx:
--------------------------------------------------------------------------------
1 | import styled from 'styled-components';
2 |
3 | interface Props {
4 | text: string;
5 | }
6 |
7 | const PopUp = ({ text }: Props) => {
8 | return (
9 | <>
10 | {text}
11 | >
12 | );
13 | };
14 |
15 | const Container = styled.div`
16 | z-index: 1000;
17 | background-color: #ffffff;
18 | display: flex;
19 | align-items: center;
20 | border-radius: 10px;
21 | padding: 1rem;
22 | box-shadow: rgb(0 0 0 / 20%) 0px 10px 25px;
23 | `;
24 |
25 | export default PopUp;
26 |
--------------------------------------------------------------------------------
/frontend/src/components/Util/Progress.tsx:
--------------------------------------------------------------------------------
1 | import React, { useRef, useEffect } from "react";
2 | import '../../stylesheets/Progress.scss';
3 |
4 | type DecoType = (string | number | null | HTMLImageElement)[];
5 |
6 | interface TypeProgress {
7 | tops?: DecoType,
8 | lefts?: DecoType,
9 | rights?: DecoType,
10 | bottoms?: DecoType,
11 | disabled?: boolean,
12 | min: number,
13 | max: number,
14 | progressDegree: number,
15 | onUseEffect: () => void | null,
16 | onChange: (arg: number) => void | null,
17 | }
18 |
19 | function Progress ( prop: any ) {
20 | const {
21 | tops, lefts, bottoms, rights,
22 | min, max, progressDegree, disabled = false,
23 | onUseEffect,
24 | onChange,
25 | }: TypeProgress = { ...prop.prop };
26 | const ProgressInput = useRef(null);
27 |
28 | useEffect(() => {
29 | if (onUseEffect) { onUseEffect() }
30 | }, [onUseEffect]);
31 |
32 | useEffect(() => {
33 | const ProgressInputCurrent = ProgressInput.current;
34 | if (ProgressInputCurrent) {
35 | ProgressInputCurrent.value = (progressDegree / 100 * parseFloat(ProgressInputCurrent.max)).toString();
36 | ProgressInputCurrent.style.backgroundSize = progressDegree + "% 100%";
37 | }
38 | }, [progressDegree]);
39 |
40 | function changeInputRange(e: React.BaseSyntheticEvent) {
41 | if (onChange) { onChange(e.target.value) }
42 | }
43 |
44 | return (
45 |
46 | {tops &&
47 |
48 | {tops.map(el => {el})}
49 |
}
50 |
51 | {lefts &&
52 |
53 | {lefts.map(el => {el})}
54 |
}
55 |
64 | {rights &&
65 |
66 | {rights.map(el => {el})}
67 |
}
68 |
69 | {bottoms &&
70 |
71 | {bottoms.map(el => {el})}
72 |
}
73 |
74 | )
75 | }
76 |
77 | export default Progress;
--------------------------------------------------------------------------------
/frontend/src/components/Util/SearchBar.tsx:
--------------------------------------------------------------------------------
1 | import React, { useCallback } from 'react';
2 | import styled from 'styled-components';
3 | import searchIcon from '../../images/search.png';
4 | import { throttle } from 'lodash';
5 |
6 | interface Props {
7 | onKeywordChange: (value: string) => void;
8 | }
9 |
10 | const SearchBar = ({ onKeywordChange }: Props) => {
11 | //eslint-disable-next-line react-hooks/exhaustive-deps
12 | const onChange = useCallback(
13 | throttle(
14 | (e: React.ChangeEvent) => {
15 | onKeywordChange(e.target.value);
16 | },
17 | 200,
18 | { leading: false },
19 | ),
20 | [],
21 | );
22 |
23 | return (
24 | <>
25 |
26 |
27 |
28 |
29 |
30 | >
31 | );
32 | };
33 |
34 | const Container = styled.div`
35 | display: flex;
36 | align-items: center;
37 | border: 2px solid #000000;
38 | padding: 0.1rem 0.4rem;
39 | margin: 1rem 0;
40 |
41 | &:focus-within {
42 | border: 2px solid;
43 | border-image: linear-gradient(94.75deg, #918fe7 6.7%, #699eef 85.54%);
44 | border-image-slice: 1;
45 | }
46 | `;
47 |
48 | const StyledInput = styled.input`
49 | width: 13rem;
50 | border: none;
51 | padding: 0.5rem;
52 | font-size: 0.9rem;
53 | &:focus {
54 | outline: none;
55 | }
56 | `;
57 |
58 | export default SearchBar;
59 |
--------------------------------------------------------------------------------
/frontend/src/components/Util/scrollbar.tsx:
--------------------------------------------------------------------------------
1 | import styled from 'styled-components';
2 |
3 | interface Props {
4 | color_?: string;
5 | }
6 |
7 | const ScrollBar = styled.div`
8 | height: 80%;
9 | overflow: auto;
10 | -ms-overflow-style: none; /* IE and Edge */
11 | scrollbar-width: none; /* Firefox */
12 |
13 | &::-webkit-scrollbar {
14 | /* Chrome, Safari, Opera*/
15 | width: 6px;
16 | }
17 | &::-webkit-scrollbar-thumb {
18 | height: 17%;
19 | background-color: ${props => props.color_ ?? 'rgba(255, 255, 255, 1)'};
20 | border-radius: 10px;
21 | }
22 | `;
23 |
24 | export default ScrollBar;
25 |
--------------------------------------------------------------------------------
/frontend/src/components/Util/uploadController.ts:
--------------------------------------------------------------------------------
1 | import {FileType, timeoutRef, fileUploadObject} from '../../types'
2 | import * as _ from 'lodash'
3 |
4 | const fileUploadController = (e:React.ChangeEvent,
5 | setState:React.Dispatch>,
6 | state:FileType) =>{
7 | const curObj = _.cloneDeep(state);
8 | curObj.musicFile = e.target.files!
9 | curObj.musicName = e.target.files![0].name;
10 | setState(curObj);
11 | }
12 |
13 | const thumbnailUploadController = (e:React.ChangeEvent,
14 | setState:React.Dispatch>,
15 | state:FileType) =>{
16 | const curObj = _.cloneDeep(state);
17 | curObj.thumbnailFile = e.target.files!
18 | curObj.thumbnailName = e.target.files![0].name;
19 | setState(curObj);
20 | }
21 |
22 | const checkSingerAndDescriptController = (
23 | descriptionRef:React.RefObject,
24 | singerRef:React.RefObject
25 | )=>{
26 | if(descriptionRef.current!.value === null || descriptionRef.current!.value === '' || singerRef.current!.value === null || singerRef.current!.value === ''){
27 | return false;
28 | }else{
29 | return true;
30 | }
31 |
32 | }
33 |
34 | const checkFileController=(
35 | musicFileRef:React.RefObject,
36 | thumbnailFileRef:React.RefObject,
37 | uploadedFile:FileType
38 | )=>{
39 | if(musicFileRef.current!.value ===null || musicFileRef.current!.value==='' || thumbnailFileRef.current!.value === null || thumbnailFileRef.current!.value === '' ){
40 | if(uploadedFile.musicFile===null || uploadedFile.thumbnailFile === null){
41 | return false;
42 | }else{
43 | return true;
44 | }
45 | }else{
46 | return true;
47 | }
48 | }
49 |
50 | function fileUploadMethodController(fileUploadObj:fileUploadObject){
51 | if(!checkSingerAndDescriptController(fileUploadObj.descriptionRef, fileUploadObj.singerRef)){
52 | fileUploadObj.textAlertRef.current!.style.opacity = '1';
53 | setTimeout(() => {
54 | if (fileUploadObj.textAlertRef.current) fileUploadObj.textAlertRef.current!.style.opacity = '0';
55 | }, 3000);
56 | return;
57 | }
58 | if(!checkFileController(fileUploadObj.musicFileRef, fileUploadObj.thumbnailFileRef, fileUploadObj.uploadedFile)){
59 | fileUploadObj.fileAlertRef.current!.style.opacity = '1';
60 | setTimeout(() => {
61 | if (fileUploadObj.fileAlertRef.current) fileUploadObj.fileAlertRef.current!.style.opacity = '0';
62 | }, 3000);
63 | return;
64 | }
65 | if(fileUploadObj.timerRef.current){
66 | clearTimeout(fileUploadObj.timerRef.current.timer!);
67 | }
68 | const uploadTimer = setTimeout(async ()=>{
69 | const formData = new FormData();
70 | Object.values(fileUploadObj.uploadedFile.musicFile!).forEach(el=>{
71 | formData.append('userFile1', el);
72 | });
73 | Object.values(fileUploadObj.uploadedFile.thumbnailFile!).forEach(el=>{
74 | formData.append('userFile2', el);
75 | })
76 | formData.append('singer', fileUploadObj.uploadedFile.singer!);
77 | formData.append('description', fileUploadObj.uploadedFile.descript!);
78 | await fetch('/upload', {
79 | method:'POST',
80 | body: formData,
81 | })
82 | const curObj = resetFileState(_.cloneDeep(fileUploadObj.uploadedFile), fileUploadObj.descriptionRef, fileUploadObj.singerRef);
83 | fileUploadObj.setUploadedFile(curObj);
84 | fileUploadObj.musicFileRef.current!.value = '';
85 | fileUploadObj.thumbnailFileRef.current!.value='';
86 | }, 200)
87 | fileUploadObj.timerRef.current.timer = uploadTimer;
88 | return;
89 | }
90 |
91 | const resetFileState = (
92 | curObj:FileType,
93 | descriptionRef:React.RefObject,
94 | singerRef:React.RefObject,):FileType => {
95 | curObj.musicName='파일선택';
96 | curObj.thumbnailName='파일선택';
97 | curObj.musicFile=null;
98 | curObj.thumbnailFile=null;
99 | curObj.singer='';
100 | curObj.descript='';
101 | descriptionRef.current!.value = '';
102 | singerRef.current!.value = '';
103 | return curObj;
104 | }
105 |
106 | const writeSingerNameController = (
107 | e: React.ChangeEvent,
108 | timerRef: React.MutableRefObject,
109 | uploadedFile:FileType,
110 | setUploadedFile:React.Dispatch>,
111 | ) =>{
112 | if(timerRef.current){
113 | clearTimeout(timerRef.current.timer!);
114 | }
115 | const timer = setTimeout(function(){
116 | const curObj = _.cloneDeep(uploadedFile);
117 | curObj.singer = e.target.value;
118 | setUploadedFile(curObj);
119 | }, 200)
120 | timerRef.current!.timer = timer;
121 | }
122 |
123 | const writeDescriptionController = (
124 | e: React.ChangeEvent,
125 | timerRef: React.MutableRefObject,
126 | uploadedFile:FileType,
127 | setUploadedFile:React.Dispatch>,
128 | ) =>{
129 | if(timerRef.current){
130 | clearTimeout(timerRef.current.timer!);
131 | }
132 | const timer = setTimeout(function(){
133 | const curObj = _.cloneDeep(uploadedFile);
134 | curObj.descript = e.target.value;
135 | setUploadedFile(curObj);
136 | }, 200)
137 | timerRef.current!.timer = timer;
138 | }
139 |
140 | const dropListenerController = (
141 | event: React.DragEvent,
142 | uploadedFile:FileType,
143 | setUploadedFile:React.Dispatch>,
144 | alertRef:React.RefObject) =>{
145 | overrideEventDefaults(event);
146 | const curObj = _.cloneDeep(uploadedFile);
147 | const imageType = { 'image/jpeg':true, 'image/png':true}
148 | if (event.dataTransfer.files && event.dataTransfer.files[0]) {
149 | if(event.dataTransfer.files[0].type in imageType){
150 | curObj.thumbnailFile = event.dataTransfer.files;
151 | curObj.thumbnailName = event.dataTransfer.files[0].name;
152 | }else if(event.dataTransfer.files[0].type=== 'audio/mpeg'){
153 | curObj.musicFile = event.dataTransfer.files;
154 | curObj.musicName = event.dataTransfer.files[0].name;
155 | }else{
156 | alertRef.current!.style.opacity = '1';
157 | setTimeout(() => {
158 | if (alertRef.current) alertRef.current!.style.opacity = '0';
159 | }, 3000);
160 | }
161 | }
162 | setUploadedFile(curObj);
163 | }
164 |
165 | const overrideEventDefaults = (event: Event | React.DragEvent) => {
166 | event.preventDefault();
167 | event.stopPropagation();
168 | };
169 |
170 | const uploadController = {
171 | fileUploadController:fileUploadController,
172 | thumbnailUploadController:thumbnailUploadController,
173 | fileUploadMethodController:fileUploadMethodController,
174 | writeSingerNameController:writeSingerNameController,
175 | writeDescriptionController:writeDescriptionController,
176 | dropListenerController:dropListenerController
177 | }
178 |
179 | export default uploadController
--------------------------------------------------------------------------------
/frontend/src/config.host.json:
--------------------------------------------------------------------------------
1 | {
2 | "deploy": "http://localhost:3000",
3 | "localhost": "https://shallwesound.p-e.kr"
4 | }
5 |
--------------------------------------------------------------------------------
/frontend/src/context/MyContext.tsx:
--------------------------------------------------------------------------------
1 | import { createContext, ReactElement, useContext } from 'react';
2 | import io, { Socket } from 'socket.io-client';
3 | import config from '../config.host.json';
4 |
5 | const socket: Socket = io(`${config.localhost}/music`);
6 |
7 | const SocketContext = createContext(socket);
8 |
9 | const ContextProvider = ({ children }: { children: ReactElement }) => {
10 | return {children};
11 | };
12 |
13 | const useSocket = () => useContext(SocketContext);
14 |
15 | export { ContextProvider, useSocket };
16 |
--------------------------------------------------------------------------------
/frontend/src/hooks/useAsync.tsx:
--------------------------------------------------------------------------------
1 | import { useReducer, useEffect } from 'react';
2 | import { fetchState, Action } from '../types';
3 |
4 | const reducer = (state: fetchState, action: Action): fetchState => {
5 | switch (action.type) {
6 | case 'LOADING':
7 | return {
8 | loading: true,
9 | data: [],
10 | error: null,
11 | };
12 | case 'SUCCESS':
13 | return {
14 | loading: false,
15 | data: action.data,
16 | error: null,
17 | };
18 | case 'ERROR':
19 | return {
20 | loading: false,
21 | data: [],
22 | error: action.error,
23 | };
24 | default:
25 | throw new Error(`Unhandled action type: ${action.type}`);
26 | }
27 | };
28 |
29 | const useAsync = (callback: Function, apiQuery: string, dep = []) => {
30 | const initialState = { loading: false, data: [], error: null };
31 |
32 | const [state, dispatch] = useReducer(reducer, initialState);
33 |
34 | const fetchUser: any = async () => {
35 | try {
36 | const result = await callback(apiQuery); // session 쓸때 credentials : 'include' 설정해주기
37 |
38 | dispatch({ type: 'SUCCESS', data: result });
39 | } catch (e) {
40 | dispatch({ type: 'ERROR', error: new Error() });
41 | }
42 | };
43 |
44 | useEffect(() => {
45 | fetchUser();
46 | }, dep);
47 |
48 | return [state, fetchUser];
49 | };
50 |
51 | export { useAsync };
52 |
--------------------------------------------------------------------------------
/frontend/src/hooks/useinfiniteScroll.tsx:
--------------------------------------------------------------------------------
1 | import { useState, useEffect } from 'react';
2 |
3 | const defaultOption = {
4 | root: null,
5 | rootMargin: '1px',
6 | threshold: 0.1,
7 | };
8 |
9 | export const useInfiniteScroll = (callback: () => {}, option = defaultOption) => {
10 | const [ref, setRef] = useState(null);
11 |
12 | useEffect(() => {
13 | let observer: IntersectionObserver;
14 |
15 | if (ref) {
16 | observer = new IntersectionObserver(([entry]) => {
17 | if (entry.isIntersecting) {
18 | callback();
19 | }
20 | }, option);
21 | observer.observe(ref);
22 | }
23 |
24 | return () => {
25 | observer && observer.disconnect();
26 | };
27 | }, [ref, option, callback]);
28 |
29 | return setRef;
30 | };
31 |
--------------------------------------------------------------------------------
/frontend/src/hooks/utils.tsx:
--------------------------------------------------------------------------------
1 | import config from '../config.host.json';
2 |
3 | const apiFetch = async (apiQuery: string) => {
4 | const result = await fetch(`${config.localhost}/api/${apiQuery}`, {
5 | credentials: 'include',
6 | });
7 | const res = await result.json();
8 | return res.list;
9 | };
10 |
11 | const fadeOut = (targetDomElement: HTMLElement) => {
12 | if (targetDomElement !== null) {
13 | targetDomElement.style.opacity = '1';
14 | setTimeout(() => {
15 | targetDomElement.style.opacity = '0';
16 | }, 3000);
17 | }
18 | };
19 |
20 | export { apiFetch, fadeOut };
21 |
--------------------------------------------------------------------------------
/frontend/src/images/search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/boostcampwm-2021/WEB21-ShallWeSound/169272ba5855b5f76b277ff7a9fc94c674705f81/frontend/src/images/search.png
--------------------------------------------------------------------------------
/frontend/src/index.css:
--------------------------------------------------------------------------------
1 | body {
2 | margin: 0;
3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
4 | 'Droid Sans', 'Helvetica Neue', sans-serif;
5 | -webkit-font-smoothing: antialiased;
6 | -moz-osx-font-smoothing: grayscale;
7 | }
8 |
9 | code {
10 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
11 | }
12 |
--------------------------------------------------------------------------------
/frontend/src/index.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import ReactDOM from 'react-dom';
3 | import './stylesheets/global.scss';
4 | import App from './components/App';
5 |
6 | import { ContextProvider } from './context/MyContext';
7 |
8 | ReactDOM.render(
9 |
10 |
11 | <>
12 |
13 | >
14 |
15 | ,
16 |
17 | document.getElementById('root'),
18 | );
19 |
--------------------------------------------------------------------------------
/frontend/src/pages/Login.tsx:
--------------------------------------------------------------------------------
1 | import '../stylesheets/login.scss';
2 | import config from '../config.host.json';
3 | const LoginPage = () => {
4 | const kakaoLogin = async () => {
5 | window.location.href = `${config.localhost}/oauth/kakao`;
6 | };
7 | const githubLogin = async () => {
8 | window.location.href = `${config.localhost}/oauth/github`;
9 | };
10 | return (
11 | <>
12 |
13 |
14 |
그 노래, 같이 들어요!
15 |
16 |

17 |
github login
18 |
19 |
20 |

21 |
kakao login
22 |
23 |
24 | >
25 | );
26 | };
27 |
28 | export { LoginPage };
29 |
--------------------------------------------------------------------------------
/frontend/src/pages/Main.tsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useRef } from 'react';
2 | import { Socket } from 'socket.io-client';
3 | import { useSocket } from '../context/MyContext';
4 | import { useAsync } from '../hooks/useAsync';
5 | import { RouteComponentProps } from 'react-router';
6 | import { apiFetch, fadeOut } from '../hooks/utils';
7 | import RoomItem from '../components/Main/RoomItem';
8 | import '../stylesheets/main.scss';
9 | import { fetchState, joinData } from '../types';
10 |
11 | export const MainPage = ({ history }: { history: RouteComponentProps['history'] }) => {
12 | const socket: Socket = useSocket()!;
13 | const alertRef: React.RefObject = useRef(null);
14 | const [state, fetchUser] = useAsync(apiFetch, 'room', []);
15 | const { data: roomList } = state as fetchState;
16 |
17 | const userRedundancyModalBlink = (joinCheck: joinData) => {
18 | if (!joinCheck.isRedundancy) {
19 | history.push(`/room/${joinCheck.roomID}`);
20 | } else fadeOut(alertRef.current!);
21 | };
22 |
23 | useEffect(() => {
24 | socket.on('redundancyCheck', userRedundancyModalBlink);
25 | socket.on('updateRoomList', fetchUser);
26 | socket.on('routingAfterCreateRoom', (roomNumber: number) => {
27 | history.push(`/room/${roomNumber}`);
28 | });
29 | socket.emit('leaveRoom');
30 | return () => {
31 | socket.off('redundancyCheck');
32 | socket.off('updateRoomList');
33 | socket.off('routingAfterCreateRoom');
34 | };
35 | }, []);
36 |
37 | return (
38 |
39 |
40 | {roomList.length ? (
41 | <>
42 |
방 참가하기
43 |
44 | {roomList.map(val => (
45 |
51 | ))}
52 |
53 | >
54 | ) : (
55 |
56 |

57 |
열려 있는 방이 존재하지 않습니다!
58 |
59 | 아직 만들어진 방이 없다면,
60 |
61 | 직접 방을 만들어 음악을 함께 하는 건 어떨까요?
62 |
63 |
64 | )}
65 |
66 | 이미 접속해 있는 방입니다.
67 |
68 |
69 |
70 | );
71 | };
72 |
--------------------------------------------------------------------------------
/frontend/src/pages/Result.tsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState, useRef, forwardRef } from 'react';
2 | import config from '../config.host.json';
3 | import { useInfiniteScroll } from '../hooks/useinfiniteScroll';
4 | import { musicResultItem } from '../types';
5 | import Progress from '../components/Util/Progress';
6 | import { useSocket } from '../context/MyContext';
7 | import { Socket } from 'socket.io-client';
8 | import { RouteComponentProps } from 'react-router';
9 |
10 | interface ResultState {
11 | musicList: musicResultItem[];
12 | hasMore: boolean;
13 | }
14 |
15 | function SearchedMusicPlayer({ path, isPlay }: { path: string; isPlay: boolean }) {
16 | const musicControl = useRef(null);
17 | const [musicPlayerState, setMusicPlayerState] = useState({
18 | currentTime: '',
19 | duration: '',
20 | progressDegree: 0,
21 | });
22 | const [musicVolumeState, setMusicVolumeState] = useState({
23 | volume: 10,
24 | backupVolume: 50,
25 | progressDegree: 10,
26 | });
27 |
28 | useEffect(() => {
29 | const playingMusic = musicControl.current;
30 | if (playingMusic) {
31 | isPlay ? playingMusic.play() : playingMusic.pause();
32 | }
33 | }, [isPlay]);
34 |
35 | function changeFormatToTime(number: number) {
36 | const minute = Math.floor(number / 60);
37 | const second = Math.floor(number % 60);
38 | const formattedSecond = second >= 10 ? second : '0' + second.toString();
39 |
40 | return `${minute}:${formattedSecond}`;
41 | }
42 |
43 | function updateCurrentTime() {
44 | const playingMusic = musicControl.current;
45 | if (playingMusic) {
46 | setMusicPlayerState({
47 | ...musicPlayerState,
48 | currentTime: changeFormatToTime(playingMusic.currentTime),
49 | duration: changeFormatToTime(playingMusic.duration),
50 | progressDegree: (playingMusic.currentTime * 100) / playingMusic.duration,
51 | });
52 | }
53 | }
54 |
55 | function onChangeMusicProgress(val: number) {
56 | const playingMusic = musicControl.current;
57 | if (playingMusic) {
58 | playingMusic.currentTime = val;
59 | updateCurrentTime();
60 | }
61 | }
62 |
63 | function onChangeVolume(e: number) {
64 | const playingMusic = musicControl.current;
65 | if (playingMusic) {
66 | playingMusic.volume = e / 100;
67 | setMusicVolumeState({
68 | ...musicVolumeState,
69 | volume: e,
70 | progressDegree: e,
71 | });
72 | }
73 | }
74 |
75 | function toggleVolume() {
76 | const playingMusic = musicControl.current;
77 | if (playingMusic) {
78 | if (playingMusic.volume > 0) {
79 | setMusicVolumeState({
80 | ...musicVolumeState,
81 | volume: 0,
82 | backupVolume: playingMusic.volume * 100,
83 | progressDegree: 0,
84 | });
85 | playingMusic.volume = 0;
86 | } else {
87 | setMusicVolumeState({
88 | ...musicVolumeState,
89 | volume: musicVolumeState.backupVolume,
90 | progressDegree: musicVolumeState.backupVolume,
91 | });
92 | playingMusic.volume = musicVolumeState.backupVolume / 100;
93 | }
94 | }
95 | }
96 |
97 | useEffect(() => {
98 | setMusicPlayerState({
99 | ...musicPlayerState,
100 | currentTime: changeFormatToTime(0),
101 | duration: musicControl.current ? changeFormatToTime(musicControl.current.duration) : '0',
102 | });
103 | toggleVolume();
104 | toggleVolume();
105 | }, []);
106 |
107 |
108 | useEffect(()=>{
109 | if(musicControl && musicControl.current) musicControl.current.volume = 0.1;
110 | }, [musicControl]);
111 |
112 | let musicProgressProps = {
113 | tops: [musicPlayerState.currentTime, musicPlayerState.duration],
114 | min: 0,
115 | max: musicControl.current && musicControl.current.duration,
116 | progressDegree: musicPlayerState.progressDegree,
117 | onChange: onChangeMusicProgress,
118 | };
119 |
120 | let musicVolumeProps = {
121 | lefts: [
122 | musicControl.current?.volume === 0 ? (
123 |
124 | ) : (
125 |
126 | ),
127 | ],
128 | min: 0,
129 | max: 100,
130 | progressDegree: musicVolumeState.progressDegree,
131 | onChange: onChangeVolume,
132 | };
133 |
134 | return (
135 | <>
136 |
137 | {musicControl && (
138 |
144 | )}
145 | >
146 | );
147 | }
148 |
149 | function SearchResultItem({
150 | name,
151 | singer,
152 | thumbnail,
153 | description,
154 | path,
155 | }: {
156 | name: string;
157 | singer: string;
158 | thumbnail: string;
159 | description: string;
160 | path: string;
161 | }) {
162 | const [playMusic, setPlayMusic] = useState(false);
163 | const [isOpen, setIsOpen] = useState(false);
164 |
165 | function togglePlayMusic() {
166 | if (!isOpen) {
167 | setIsOpen(true);
168 | }
169 | setPlayMusic(!playMusic);
170 | }
171 |
172 | return (
173 |
174 |
175 |

176 |
177 |
{name.slice(0, name.lastIndexOf('.'))}
178 |
{singer}
179 |
{description}
180 |
181 |
182 |
183 | {playMusic ? (
184 |
188 | ) : (
189 |
193 | )}
194 |
195 |
196 | {isOpen &&
}
197 |
198 | );
199 | }
200 |
201 | const ResultPages = ({ history }: { history: RouteComponentProps['history'] }) => {
202 | const [resultList, setResultList] = useState({
203 | musicList: [],
204 | hasMore: false,
205 | });
206 | const scrollBar = useRef(null);
207 | const keyword = useRef('');
208 | const page = useRef(0);
209 |
210 | const socket: Socket = useSocket()!;
211 |
212 | const fetchMusics = async (more = true) => {
213 | fetch(`${config.localhost}/api/music?keyword=${keyword.current}&page=${page.current}`)
214 | .then(res => res.json())
215 | .then(data => {
216 | if (more) {
217 | setResultList({
218 | musicList: [...musicList, ...data.result],
219 | hasMore: data.hasMore,
220 | });
221 | } else {
222 | setResultList({
223 | musicList: data.result,
224 | hasMore: data.hasMore,
225 | });
226 | scrollBar.current?.scrollTo(0, 0);
227 | }
228 | });
229 | };
230 |
231 | const { musicList, hasMore } = resultList;
232 |
233 | useEffect(() => {
234 | page.current = 0;
235 | keyword.current = window.location.pathname.match(/[^/]+/gm)![1];
236 | fetchMusics(false);
237 | }, [window.location.pathname]);
238 |
239 | useEffect(() => {
240 | page.current = musicList.length;
241 | }, [musicList]);
242 |
243 | useEffect(() => {
244 | socket.on('routingAfterCreateRoom', (roomNumber: number) => {
245 | history.push(`/room/${roomNumber}`);
246 | });
247 |
248 | return () => {
249 | socket.off('routingAfterCreateRoom');
250 | };
251 | }, []);
252 |
253 | const setObserveTarget = useInfiniteScroll(fetchMusics);
254 |
255 | return (
256 |
257 |
258 |
259 |
현재까지 '{musicList.length}'개의 결과가 검색 되었습니다.
260 | {musicList.map(val => (
261 |
268 | ))}
269 |
270 |
271 |
272 |
273 | );
274 | };
275 |
276 | const ResultPage = forwardRef(ResultPages);
277 |
278 | export { ResultPage };
279 |
--------------------------------------------------------------------------------
/frontend/src/pages/Room.tsx:
--------------------------------------------------------------------------------
1 | import React, { useEffect, useState, useRef } from 'react';
2 | import '../stylesheets/main.scss';
3 | import MusicPlayer from '../components/Room/MusicPlayer/MusicPlayer';
4 | import PlayList from '../components/Room/PlayList/PlayList';
5 | import ChatComponent from '../components/Room/Chat/ChatComponent';
6 | import UserList from '../components/Room/UserList/UserList';
7 | import { useSocket } from '../context/MyContext';
8 | import { useAsync } from '../hooks/useAsync';
9 | import { RouteComponentProps } from 'react-router';
10 | import { fetchState } from '../types';
11 | import { Cookies } from 'react-cookie';
12 | import { apiFetch, fadeOut } from '../hooks/utils';
13 | import { Socket } from 'socket.io-client';
14 |
15 | const Room = ({ history }: { history: RouteComponentProps['history'] }) => {
16 | const socket: Socket = useSocket()!;
17 | const cookie = new Cookies();
18 | const alertRef: React.RefObject = useRef(null);
19 | const roomData = decodeURI(window.location.pathname.match(/[^/]+/gm)![1]).toString();
20 | const [isHost, setIsHost] = useState(false);
21 | const [state, refetchUserList] = useAsync(apiFetch, `userList?roomTitle=${roomData}`, []);
22 | const { data: userList } = state as fetchState;
23 |
24 | const hostDelegated = (isHostServer: boolean) => {
25 | setIsHost(isHostServer);
26 | fadeOut(alertRef.current!);
27 | };
28 |
29 | useEffect(() => {
30 | socket.emit('joinRoom', { roomID: roomData, userID: cookie.get('userID') });
31 | }, []);
32 |
33 |
34 | useEffect(() => {
35 | socket.on('updateUserList', refetchUserList);
36 | socket.on('delegateHost', hostDelegated);
37 |
38 | return () => {
39 | socket.off('updateUserList');
40 | socket.off('delegateHost');
41 | };
42 | }, []);
43 |
44 |
45 | useEffect(() => {
46 | if (userList[0] === cookie.get('userID')) setIsHost(true);
47 | }, [userList]);
48 |
49 | if (userList[0] === 'bad') {
50 | return (
51 |
52 |
55 |
잘못된 요청입니다.
56 |
57 | );
58 | }
59 |
60 | return (
61 |
62 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | 방장 권한이 위임 되었습니다.
73 |
74 |
75 | );
76 | };
77 |
78 | export { Room };
79 |
--------------------------------------------------------------------------------
/frontend/src/react-app-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/frontend/src/stylesheets/MusicPlayer.scss:
--------------------------------------------------------------------------------
1 | @import './palette.scss';
2 |
3 | .musicplayer {
4 | box-sizing: border-box;
5 | position: relative;
6 | display: flex;
7 | flex-direction: column;
8 | justify-content: center;
9 | // align-items: center;
10 | background-color: $purple;
11 | padding: 1.5rem;
12 | margin-right: 2rem;
13 | margin-bottom: 1rem;
14 | width: 400px;
15 | height: calc(100% - 300px - 1rem);
16 | min-height: 220px;
17 | border-radius: 0.25rem;
18 |
19 | @media screen and (min-height: 768px) {
20 | height: 220px;//calc(100% - 500px - 1rem);
21 | }
22 |
23 | @media screen and (min-height: 968px) {
24 | height: 420px;//calc(100% - 300px - 1rem);
25 | }
26 |
27 | .hover {
28 | position: absolute;
29 | width: 100%;
30 | height: 100%;
31 | color: $black;
32 | box-sizing: border-box;
33 | border: 200px solid black;
34 | z-index: 3;
35 | visibility: visible;
36 |
37 | .icon {
38 | position: absolute;
39 | width: 96px;
40 | height: 96px;
41 | top: calc(50% - 48px);
42 | left: calc(50% - 48px);
43 | z-index: 5;
44 | cursor: pointer;
45 | }
46 | }
47 |
48 | video {
49 | display: none;
50 | }
51 |
52 | & > * {
53 | margin-top: 0.5rem;
54 | margin-bottom: 0.5rem;
55 | }
56 |
57 | &-body {
58 | width: 100%;
59 | height: 50%;
60 | display: none;
61 | justify-content: space-around;
62 | align-items: center;
63 |
64 | .icon {
65 | cursor: pointer;
66 | }
67 |
68 | @media screen and (min-height: 968px) {
69 | display: flex;
70 | }
71 | }
72 |
73 | .no-thumbnail {
74 | border: 10px solid $semi-white;
75 | border-radius: 999px;
76 | box-sizing: border-box;
77 | }
78 |
79 | &-cover {
80 | position: relative;
81 | box-sizing: border-box;
82 | border-radius: 999px;
83 | width: 50%;
84 | height: 176px;
85 |
86 | img {
87 | width: 100%;
88 | height: 176px;
89 | border-radius: 999px;
90 | }
91 |
92 | .cover-hover {
93 | position: relative;
94 | width: 100%;
95 | height: 100%;
96 | border-radius: 999px;
97 | cursor: pointer;
98 |
99 | .icon {
100 | width: 72px;
101 | height: 72px;
102 | position: absolute;
103 | display: inherit;
104 | top: calc(50% - 36px);
105 | left: calc(50% - 36px);
106 | }
107 |
108 | .only-hover {
109 | width: 100%;
110 | height: 100%;
111 | border-radius: 999px;
112 | position: absolute;
113 | top: 0;
114 | left: 0;
115 | background-color: $purple;
116 | opacity: 0.3;
117 | }
118 | }
119 |
120 | &:hover {
121 | background-color: lighten($color: $black, $amount: 30);
122 | }
123 | }
124 |
125 | .width-half {
126 | width: 50%;
127 | box-sizing: border-box;
128 | }
129 |
130 | .width-quarter {
131 | width: 25%;
132 | box-sizing: border-box;
133 | }
134 |
135 | .volume-wrap {
136 | display: flex;
137 | justify-content: flex-start;
138 | justify-content: space-between;
139 |
140 | .mini-controller {
141 | img {
142 | width: 24px;
143 | height: 24px;
144 | }
145 |
146 | img + img {
147 | margin-left: 0.5rem;
148 | }
149 |
150 | @media screen and (min-height: 968px) {
151 | display: none;
152 | }
153 | }
154 | }
155 |
156 | .serveral-icons {
157 | width: 100%;
158 | display: flex;
159 | flex-direction: row;
160 |
161 | .icon {
162 | cursor: pointer;
163 | }
164 |
165 |
166 | .progress-wrap {
167 | display: flex;
168 | justify-content: center;
169 | align-items: center;
170 | margin-left: 1rem;
171 | }
172 |
173 | .icon + .icon {
174 | margin-left: 1rem;
175 | }
176 | }
177 | }
178 |
--------------------------------------------------------------------------------
/frontend/src/stylesheets/Progress.scss:
--------------------------------------------------------------------------------
1 | @import './palette.scss';
2 |
3 | .progress {
4 | &-background {
5 | width: 100%;
6 | min-height: fit-content;
7 | box-sizing: border-box;
8 | position: relative;
9 | display: flex;
10 | flex-direction: column;
11 | justify-content: center;
12 | align-items: center;
13 | background-color: $purple;
14 | border-radius: 1.5rem;
15 | // padding: 1.5rem;
16 | }
17 |
18 | &-text {
19 | font-size: 1rem;
20 | font-weight: 700;
21 | color: $semi-white;
22 | }
23 |
24 | &-vertical {
25 | width: 100%;
26 | display: flex;
27 | justify-content: space-between;
28 | margin: 0.5rem 0;
29 |
30 | * {
31 | margin: 0;
32 | }
33 | }
34 |
35 | &-horizontal {
36 | width: 100%;
37 | display: flex;
38 | justify-content: center;
39 | align-items: center;
40 | }
41 |
42 | &-neighbor {
43 | display: flex;
44 | justify-content: center;
45 | align-items: center;
46 |
47 | span {
48 | display: block;
49 | }
50 | }
51 |
52 | &-left {
53 | span {
54 | margin-right: 0.5rem;
55 | }
56 | }
57 |
58 | &-right {
59 | span {
60 | margin-left: 0.5rem;
61 | }
62 | }
63 |
64 | &-bar {
65 | width: 100%;
66 | height: 6px;
67 | outline: 1px solid $semi-white;
68 | border-radius: 50px;
69 | cursor: pointer;
70 | position: relative;
71 | }
72 |
73 | }
74 |
75 | input[type='range'] {
76 | appearance: none;
77 | margin: 0;
78 | width: 100%;
79 | height: 6px;
80 | border-radius: 999px;
81 | background: $purple;
82 | background-image: linear-gradient($semi-white, $semi-white);
83 | background-size: 0% 100%;
84 | background-repeat: no-repeat;
85 | outline: 1px solid $semi-white;
86 | cursor: pointer;
87 |
88 | &::-webkit-slider-thumb {
89 | appearance: none;
90 | width: 12px;
91 | height: 12px;
92 | background: $semi-white;
93 | border-radius: 999px;
94 | }
95 | }
96 |
97 | img {
98 | cursor: pointer;
99 | }
--------------------------------------------------------------------------------
/frontend/src/stylesheets/global.scss:
--------------------------------------------------------------------------------
1 | @import './palette.scss';
2 | /* Color */
3 |
4 | $background: linear-gradient(#4b6cb7, #182848);
5 | $color-chatbox: #9bbbd4;
6 |
7 | body {
8 | min-width: 1024px;
9 | min-height: 768px;
10 | }
11 |
12 | #root {
13 | height: 100vh;
14 | min-height: 768px;
15 | position: relative;
16 | background-color: $pink;
17 | display: flex;
18 | flex-direction: column;
19 | justify-content: center;
20 | align-items: center;
21 | font-family: 'Jua', Arial, Helvetica, sans-serif;
22 |
23 | // @media screen and (max-width: 900px) {
24 | // height: 100%;
25 | // }
26 | }
27 |
28 | .record-image {
29 | height: 200px;
30 | position: absolute;
31 | right: 1.5rem;
32 | bottom: 1.5rem;
33 | opacity: 0.3;
34 | z-index: 0;
35 | }
36 |
37 | .body {
38 | position: relative;
39 | width: 100vw;
40 | min-width: 1024px;
41 | height: calc(90% - 130px - 1rem);
42 | margin-bottom: 1rem;
43 | display: flex;
44 | justify-content: center;
45 | align-items: flex-start;
46 | }
47 |
48 | @keyframes fade-in {
49 | from {
50 | opacity: 0;
51 | }
52 | to {
53 | opacity: 1;
54 | }
55 | }
56 |
57 | @keyframes fade-out {
58 | from {
59 | opacity: 1;
60 | }
61 | to {
62 | opacity: 0;
63 | }
64 | }
65 |
66 | .header {
67 | width: 80%;
68 | min-width: 1024px;
69 | height: 130px;
70 | padding: 0 4rem;
71 | margin-top: 1rem;
72 | margin-bottom: 1rem;
73 | box-sizing: border-box;
74 | background: $semi-white;
75 | color: $purple;
76 | border-radius: 999px;
77 | display: flex;
78 | justify-content: space-between;
79 | align-items: center;
80 | position: relative;
81 |
82 | button {
83 | font: inherit;
84 | }
85 |
86 | // @media screen and (max-width: 1300px) {
87 | // padding: 0;
88 | // }
89 |
90 | // @media screen and (max-width: 900px) {
91 | // height: 100%;
92 | // border-radius: 40px;
93 | // padding: 0;
94 | // justify-content: center;
95 | // }
96 |
97 | .header-left-wrap {
98 | display: flex;
99 | align-items: center;
100 |
101 | // @media screen and (max-width: 900px) {
102 | // flex-direction: column;
103 | // justify-content: center;
104 | // padding-top: 100px;
105 | // }
106 | }
107 |
108 | .header-logo {
109 | cursor: pointer;
110 |
111 | // @media screen and (max-width: 1200px) {
112 | // display: none;
113 | // }
114 | }
115 |
116 | // .header-search {
117 | // @media screen and (max-width: 900px) {
118 | // // position: absolute;
119 | // // top: 1.5rem;
120 | // }
121 | // }
122 |
123 | .header-right-wrap {
124 | display: flex;
125 | align-items: center;
126 | }
127 |
128 | &-search {
129 | display: flex;
130 | align-items: center;
131 |
132 | * + * {
133 | margin-left: 0.5rem;
134 | }
135 |
136 | img {
137 | width: 50px;
138 | height: 50px;
139 | cursor: pointer;
140 | }
141 | }
142 |
143 | &-search-input {
144 | width: 250px;
145 | height: 50px;
146 | font-family: inherit;
147 | font-weight: 700;
148 | font-size: 1.25rem;
149 | outline: none;
150 | background: transparent;
151 | border: 4px solid $purple;
152 | padding: 0.4rem;
153 | box-sizing: border-box;
154 | }
155 |
156 | // .menu {
157 | // @media screen and (max-width: 900px) {
158 | // position: absolute;
159 | // top: 1.5rem;
160 | // right: 1.5rem;
161 | // cursor: pointer;
162 |
163 | // .menu-line {
164 | // height: 3px;
165 | // width: 20px;
166 | // background-color: $purple;
167 | // margin: 3px 0px;
168 | // }
169 | // }
170 | // }
171 | }
172 |
173 | @mixin scrollbar($color: $white) {
174 | overflow: auto;
175 | -ms-overflow-style: none; /* IE and Edge */
176 | scrollbar-width: none; /* Firefox */
177 |
178 | &::-webkit-scrollbar {
179 | /* Chrome, Safari, Opera*/
180 | width: 6px;
181 | }
182 | &::-webkit-scrollbar-thumb {
183 | height: 17%;
184 | background-color: $color;
185 | border-radius: 10px;
186 | }
187 | }
188 |
189 | ::-webkit-input-placeholder {
190 | /* Chrome/Opera/Safari */
191 | color: rgba(0, 0, 0, 0.3);
192 | }
193 | ::-moz-placeholder {
194 | /* Firefox 19+ */
195 | color: rgba(0, 0, 0, 0.3);
196 | }
197 | :-ms-input-placeholder {
198 | /* IE 10+ */
199 | color: rgba(0, 0, 0, 0.3);
200 | }
201 | :-moz-placeholder {
202 | /* Firefox 18- */
203 | color: rgba(0, 0, 0, 0.3);
204 | }
205 |
--------------------------------------------------------------------------------
/frontend/src/stylesheets/header.scss:
--------------------------------------------------------------------------------
1 | @import './palette.scss';
2 |
3 | .modal-container {
4 | position: relative;
5 | }
6 |
7 | .header-button {
8 | border: 0;
9 | background: transparent;
10 | color: $purple;
11 | width: 140px;
12 | height: 120px;
13 | border-radius: 10px;
14 | font-weight: bold;
15 | font-size: large;
16 | cursor: pointer;
17 | stroke: none;
18 | fill: $purple;
19 | display: flex;
20 | flex-direction: column;
21 | justify-content: center;
22 | align-items: center;
23 |
24 | &:hover {
25 | svg {
26 | stroke: $semi-white;
27 | background-color: $purple;
28 | fill: $semi-white;
29 | }
30 | }
31 |
32 | svg {
33 | width: 50px;
34 | height: 50px;
35 | padding: 0.5rem;
36 | border-radius: 999px;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/frontend/src/stylesheets/login.scss:
--------------------------------------------------------------------------------
1 | @import './palette.scss';
2 |
3 | .loginBox {
4 | display: grid;
5 | place-items: center;
6 | background-color: $semi-white;
7 | width: 30em;
8 | height: 25em;
9 | border-radius: 10px;
10 |
11 | img {
12 | margin-left: 5%;
13 | margin-top: 3%;
14 | width: 2.5em;
15 | height: 2.5em;
16 | object-fit: cover;
17 | }
18 | .loginText {
19 | font-size: xx-large;
20 | }
21 | .Btn {
22 | div {
23 | width: 17em;
24 | padding-top: 0.8rem;
25 | text-align: center;
26 | font-size: xx-large;
27 | }
28 | display: flex;
29 | width: 20em;
30 | height: 4em;
31 | border: 5px solid $pink;
32 | border-radius: 10px;
33 | cursor: pointer;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/frontend/src/stylesheets/main.scss:
--------------------------------------------------------------------------------
1 | @import './palette.scss';
2 | @import './global.scss';
3 |
4 | .main-wrap {
5 | width: 80%;
6 | min-width: 1024px;
7 | height: 100%;
8 | background-color: $semi-white;
9 | color: $purple;
10 | // border: 4px double $white;
11 | box-sizing: border-box;
12 | padding: 2rem;
13 | border-radius: 3rem;
14 | display: flex;
15 | flex-direction: column;
16 | justify-content: center;
17 | align-items: center;
18 |
19 | h2 {
20 | width: 100%;
21 | font-weight: 700;
22 | font-size: 1.5rem;
23 | text-align: start;
24 | }
25 |
26 | .text-center {
27 | text-align: center;
28 | }
29 |
30 | .room-empty-notice {
31 | width: 100%;
32 | height: 100%;
33 | display: flex;
34 | flex-direction: column;
35 | color: $purple;
36 | font-size: 3rem;
37 | justify-content: center;
38 | align-items: center;
39 |
40 | img {
41 | width: 10rem;
42 | height: 10rem;
43 | margin-bottom: 3rem;
44 | }
45 |
46 | &-detail {
47 | margin-top: 1.5rem;
48 | font-size: 1.5rem;
49 | text-align: center;
50 | }
51 | }
52 | }
53 |
54 | .roomList {
55 | @include scrollbar(#d3d3d3);
56 | width: 100%;
57 | height: 90%;
58 | box-sizing: border-box;
59 | padding: 2rem;
60 | display: grid;
61 | gap: 20px;
62 |
63 | // @media screen and (min-width: 576px) {
64 | // grid-template-columns: 1fr;
65 | // }
66 |
67 | // @media screen and (min-width: 768px) {
68 | // grid-template-columns: 1fr 1fr;
69 | // }
70 | // @media screen and (min-width: 992px) {
71 | grid-template-columns: 1fr 1fr 1fr;
72 | // }
73 |
74 | @media screen and (min-width: 1200px) {
75 | grid-template-columns: 1fr 1fr 1fr 1fr;
76 | }
77 |
78 | .room {
79 | height: 6.5rem;
80 | border: 4px solid $purple;
81 | border-radius: 1rem;
82 | color: $purple;
83 | padding: 2rem;
84 | display: flex;
85 | flex-direction: column;
86 | cursor: pointer;
87 |
88 | &:hover {
89 | background-color: $purple;
90 | color: $semi-white;
91 | }
92 |
93 | p {
94 | display: inline-block;
95 | }
96 |
97 | p + p {
98 | margin-top: 1rem;
99 | }
100 |
101 | .room-name {
102 | font-size: 1.5rem;
103 | text-align: center;
104 | }
105 |
106 | .room-descripton {
107 | font-size: 0.875rem;
108 | }
109 | }
110 |
111 | .button {
112 | position: absolute;
113 | bottom: 0;
114 | right: 0;
115 | }
116 | }
117 |
118 | .modal {
119 | position: absolute;
120 | top: calc(130px); // 130px: header height
121 | left: -124px; // 124px: (modal width - button width) / 2
122 | width: 20rem;
123 | min-height: fit-content;
124 | background-color: $semi-white;
125 | border: 2px solid $purple;
126 | padding: 2rem;
127 | border-radius: 2rem;
128 | display: flex;
129 | flex-direction: column;
130 | justify-content: center;
131 | align-items: center;
132 | z-index: 9999;
133 |
134 | &-row {
135 | flex-direction: row;
136 | }
137 |
138 | *:nth-child(n) {
139 | margin: 0.5rem 0 0.5rem;
140 |
141 | button {
142 | margin: 0.5rem;
143 | }
144 | }
145 |
146 | .modal-close {
147 | position: absolute;
148 | top: 1rem;
149 | right: 1rem;
150 | width: 30px;
151 | height: 30px;
152 | border-radius: 999px;
153 | fill: $purple;
154 | cursor: pointer;
155 | display: flex;
156 | justify-content: center;
157 | align-items: center;
158 | margin-bottom: 0;
159 |
160 | svg {
161 | fill: inherit;
162 | margin: 0;
163 | }
164 |
165 | &:hover {
166 | fill: $semi-white;
167 | background-color: $purple;
168 | }
169 |
170 | .button {
171 | margin-left: 0.5rem;
172 | margin-right: 0.5rem;
173 | }
174 | }
175 |
176 | .modal-title {
177 | font-size: 1.75rem;
178 | text-align: center;
179 | }
180 |
181 | label {
182 | font-size: 1.25rem;
183 | }
184 |
185 | input {
186 | padding: 0.5rem;
187 | border: 4px solid $purple;
188 | outline: none;
189 | font: inherit;
190 | }
191 |
192 | textarea {
193 | padding: 0.5rem;
194 | border: 4px solid $purple;
195 | outline: none;
196 | font: inherit;
197 | font-size: 1rem;
198 | resize: none;
199 |
200 | &::placeholder {
201 | font-size: 1rem;
202 | font-weight: 400;
203 | }
204 | }
205 |
206 | .input-wrap {
207 | width: 100%;
208 | display: flex;
209 | flex-direction: column;
210 | }
211 |
212 | .button-wrap {
213 | display: flex;
214 | justify-content: center;
215 | }
216 | }
217 |
218 | .button {
219 | min-width: fit-content;
220 | max-width: fit-content;
221 | height: 50px;
222 | box-sizing: border-box;
223 | padding: 0.75rem 1rem;
224 | color: $purple;
225 | background-color: $semi-white;
226 | font-weight: 700;
227 | border: 4px solid $purple;
228 | border-radius: 1rem;
229 | cursor: pointer;
230 |
231 | &:hover {
232 | color: $semi-white;
233 | background-color: $purple;
234 | }
235 | }
236 |
237 | .room-wrap {
238 | width: 80%;
239 | min-width: 1024px;
240 | height: 100%;
241 | min-height: calc(768px - 130px - 1rem); // 130px: Header
242 | background-color: $semi-white;
243 | color: $purple;
244 | box-sizing: border-box;
245 | padding: 2rem;
246 | border-radius: 3rem;
247 | display: flex;
248 | position: relative;
249 | justify-content: center;
250 | align-items: center;
251 |
252 | &-left {
253 | height: 100%;
254 | }
255 |
256 | &-right {
257 | height: 100%;
258 | }
259 | }
260 |
261 | .search-main-wrap {
262 | width: 80%;
263 | height: 100%;
264 | background-color: $semi-white;
265 | color: $purple;
266 | position: relative;
267 | box-sizing: border-box;
268 | padding: 2rem;
269 | border-radius: 3rem;
270 | display: flex;
271 | flex-direction: column;
272 | justify-content: center;
273 | align-items: center;
274 | overflow: scroll;
275 |
276 | h2 {
277 | width: 100%;
278 | font-weight: 700;
279 | font-size: 1.5rem;
280 | text-align: start;
281 | }
282 |
283 | .room-empty-notice {
284 | color: $purple;
285 | font-size: 4rem;
286 | font-style: italic;
287 | }
288 | }
289 |
290 | .search-result {
291 | width: 70%;
292 | min-height: fit-content;
293 | border: 4px solid $purple;
294 | border-radius: 1rem;
295 | padding: 1rem;
296 | position: relative;
297 |
298 | video {
299 | width: 0;
300 | height: 0;
301 | }
302 |
303 | &-wrap {
304 | width: 100%;
305 | height: 100%;
306 | display: flex;
307 | flex-direction: column;
308 | align-items: center;
309 | overflow-y: auto;
310 |
311 | * + * {
312 | margin-top: 0.75rem;
313 | }
314 | }
315 |
316 | &-cnt {
317 | width: 100%;
318 | padding-bottom: 0.75rem;
319 | border-bottom: 4px double $purple;
320 | font-size: 1.5rem;
321 | margin-bottom: 0.75rem;
322 | }
323 |
324 | &-item {
325 | width: 100%;
326 | box-sizing: border-box;
327 | display: flex;
328 | align-items: center;
329 | margin-bottom: 0;
330 |
331 | // &:last-child {
332 | // margin-bottom: 1rem;
333 | // }
334 | }
335 |
336 | &-thumbnail {
337 | width: 100px;
338 | height: 100px;
339 | padding-right: 1rem;
340 | border-right: 2px solid $purple;
341 | margin-right: 1rem;
342 | }
343 |
344 | &-words {
345 | * + * {
346 | margin-bottom: 1rem;
347 | }
348 | }
349 |
350 | &-name {
351 | font-size: 1.5rem;
352 | }
353 |
354 | &-singer {
355 | font-size: 1.125rem;
356 | font-style: italic;
357 | }
358 |
359 | &-blank {
360 | width: 130px;
361 | height: 1px;
362 | }
363 |
364 | &-play {
365 | position: absolute;
366 | top: center;
367 | right: 2rem;
368 | cursor: pointer;
369 |
370 | svg {
371 | width: 40px;
372 | height: 40px;
373 | // padding: 0.5rem;
374 | border: 8px solid $purple;
375 | border-radius: 999px;
376 | fill: $purple;
377 |
378 | &:hover {
379 | fill: $semi-white;
380 | background-color: $purple;
381 | }
382 | }
383 | }
384 |
385 | &-end {
386 | color: $semi-white;
387 | }
388 | }
389 |
390 | .searched-musicplayer {
391 | box-sizing: border-box;
392 | position: relative;
393 | display: flex;
394 | flex-direction: column;
395 | justify-content: flex-start;
396 | // align-items: center;
397 | background-color: $purple;
398 | border-radius: 1.5rem;
399 | padding: 1.5rem;
400 | width: 100%;
401 |
402 | .musicplayer {
403 | &-timer {
404 | width: 100%;
405 | font-weight: 700;
406 | color: $semi-white;
407 | display: flex;
408 | justify-content: space-between;
409 |
410 | .max-duration {
411 | margin-top: 0;
412 | }
413 | }
414 |
415 | .progress {
416 | width: 100%;
417 | height: 6px;
418 | outline: 1px solid $semi-white;
419 | border-radius: 50px;
420 | cursor: pointer;
421 | position: relative;
422 |
423 | &-bar {
424 | height: inherit;
425 | width: 0%;
426 | position: relative;
427 | border: 0.5px solid $semi-white;
428 | border-radius: inherit;
429 | background-color: $semi-white;
430 |
431 | &::before {
432 | content: '';
433 | position: absolute;
434 | height: 18px;
435 | width: 18px;
436 | box-sizing: border-box;
437 | border-radius: 50%;
438 | top: -6px;
439 | right: -5px;
440 | z-index: 2;
441 | background-color: $semi-white;
442 | }
443 | }
444 | }
445 |
446 | output {
447 | width: 200px;
448 | height: 200px;
449 | }
450 | }
451 |
452 | .width-half {
453 | width: 50%;
454 | box-sizing: border-box;
455 | }
456 |
457 | .width-quarter {
458 | width: 25%;
459 | box-sizing: border-box;
460 | }
461 |
462 | input[type='range'] {
463 | appearance: none;
464 | width: 100%;
465 | height: 6px;
466 | border-radius: 999px;
467 | background: $purple;
468 | background-image: linear-gradient($semi-white, $semi-white);
469 | background-size: 0% 100%;
470 | background-repeat: no-repeat;
471 | outline: 1px solid $semi-white;
472 | cursor: pointer;
473 |
474 | &::-webkit-slider-thumb {
475 | appearance: none;
476 | width: 12px;
477 | height: 12px;
478 | background: $semi-white;
479 | border-radius: 999px;
480 | }
481 | }
482 |
483 | .serveral-icons {
484 | width: 100%;
485 | display: flex;
486 | flex-direction: row;
487 | justify-content: space-between;
488 |
489 | .icon {
490 | cursor: pointer;
491 | }
492 |
493 | .volume-wrap {
494 | display: flex;
495 | justify-content: center;
496 | }
497 |
498 | .progress-wrap {
499 | display: flex;
500 | justify-content: center;
501 | align-items: center;
502 | margin-top: 0;
503 | margin-left: 1rem;
504 | }
505 |
506 | .icon + .icon {
507 | margin-left: 1rem;
508 | }
509 | }
510 |
511 | @keyframes fadeOut {
512 | 0% {
513 | opacity: 1;
514 | }
515 | 100% {
516 | opacity: 0;
517 | }
518 | }
519 | }
520 |
521 | .delegate {
522 | opacity: 0;
523 | width: 250px;
524 | height: 100px;
525 | box-sizing: border-box;
526 | padding: 2rem;
527 | display: flex;
528 | flex-direction: row;
529 | justify-content: center;
530 | align-items: center;
531 | background-color: $lightgreen;
532 | border-radius: 1rem;
533 | color: $semi-black;
534 | position: absolute;
535 | left: 50%;
536 | top: 50%;
537 | transform: translate(-50%, -50%);
538 | z-index: 5;
539 | animation-name: fadeOut;
540 | // animation-duration: 4s;
541 | // animation-iteration-count: 1;
542 |
543 | transition: all 2s ease-in;
544 | }
545 |
--------------------------------------------------------------------------------
/frontend/src/stylesheets/palette.scss:
--------------------------------------------------------------------------------
1 | @import 'https://fonts.googleapis.com/css2?family=Jua&display=swap';
2 |
3 | $white: #fff;
4 | $semi-white: #f9f9f9;
5 | $pink: #f7dbf0;
6 | $purple: #beaee2;
7 | $lightgreen: #cdf0ea;
8 | $black: #000;
9 | $semi-black: #1e2222;
10 | $background: linear-gradient(#4b6cb7, #182848);
11 | $color-chatbox: #9bbbd4;
12 |
--------------------------------------------------------------------------------
/frontend/src/stylesheets/reset.css:
--------------------------------------------------------------------------------
1 | /* http://meyerweb.com/eric/tools/css/reset/
2 | v2.0 | 20110126
3 | License: none (public domain)
4 | */
5 |
6 | html, body, div, span, applet, object, iframe,
7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre,
8 | a, abbr, acronym, address, big, cite, code,
9 | del, dfn, em, img, ins, kbd, q, s, samp,
10 | small, strike, strong, sub, sup, tt, var,
11 | b, u, i, center,
12 | dl, dt, dd, ol, ul, li,
13 | fieldset, form, label, legend,
14 | table, caption, tbody, tfoot, thead, tr, th, td,
15 | article, aside, canvas, details, embed,
16 | figure, figcaption, footer, header, hgroup,
17 | menu, nav, output, ruby, section, summary,
18 | time, mark, audio, video {
19 | margin: 0;
20 | padding: 0;
21 | border: 0;
22 | /* font-size: 100%; */
23 | font: inherit;
24 | vertical-align: baseline;
25 | }
26 | /* HTML5 display-role reset for older browsers */
27 | article, aside, details, figcaption, figure,
28 | footer, header, hgroup, menu, nav, section {
29 | display: block;
30 | }
31 | body {
32 | line-height: 1;
33 | }
34 | ol, ul {
35 | list-style: none;
36 | }
37 | blockquote, q {
38 | quotes: none;
39 | }
40 | blockquote:before, blockquote:after,
41 | q:before, q:after {
42 | content: '';
43 | content: none;
44 | }
45 | table {
46 | border-collapse: collapse;
47 | border-spacing: 0;
48 | }
--------------------------------------------------------------------------------
/frontend/src/stylesheets/style.module.scss:
--------------------------------------------------------------------------------
1 | @import './palette.scss';
2 |
3 | .App {
4 | position: relative;
5 | background-size: cover;
6 | display: flex;
7 | min-height: calc(100vh - 40px); //calc(100vw - (100vw - 100%));
8 | justify-content: center;
9 | align-items: center;
10 | box-sizing: border-box;
11 | }
12 |
13 | .msgBallon {
14 | overflow: hidden;
15 | height: auto;
16 | margin-bottom: 0.5rem;
17 | color: $semi-black;
18 |
19 | .othersChat {
20 | display: block;
21 | height: auto;
22 | overflow: hidden;
23 | max-width: 50%;
24 | min-height: 25px;
25 | float: left;
26 | border-radius: 5px;
27 | padding: 0.4rem 0.8rem 0;
28 | margin-block-start: 0;
29 | margin-block-end: 5px;
30 | margin-left: 10px;
31 | background-color: white;
32 | }
33 | .myChat {
34 | float: right;
35 | max-width: 50%;
36 | min-height: 25px;
37 | height: auto;
38 | overflow: hidden;
39 | text-align: center;
40 | border-radius: 5px;
41 | padding: 0.4rem 0.8rem 0;
42 | margin-block-start: 0;
43 | margin-block-end: 5px;
44 | margin-right: 10px;
45 | background-color: #fee500;
46 | }
47 | .writer {
48 | display: block;
49 | margin-left: 10px;
50 | margin-bottom: 0.5rem;
51 | }
52 | }
53 |
54 | .chatBox {
55 | // background: none;//linear-gradient(#4b6cb7, #182848);
56 | background-color: $purple;
57 | // outline: 4px solid $white;
58 | width: 400px;
59 | height: calc(100% - 150px - 1rem - 40px); // 150px: UserList, 40px: chatForm
60 | position: relative;
61 | border-radius: 0.25rem;
62 |
63 | .chatList {
64 | box-sizing: border-box;
65 | padding: 1rem;
66 | height: 100%;
67 | width: 100%;
68 |
69 | overflow: auto;
70 | -ms-overflow-style: none; /* IE and Edge */
71 | scrollbar-width: none; /* Firefox */
72 |
73 | &::-webkit-scrollbar {
74 | /* Chrome, Safari, Opera*/
75 | width: 6px;
76 | }
77 | &::-webkit-scrollbar-thumb {
78 | height: 17%;
79 | background-color: rgba(255, 255, 255, 1);
80 | border-radius: 10px;
81 | }
82 | }
83 |
84 | .chatInputSquare {
85 | background-color: white;
86 | margin-top: 5px;
87 | position: absolute;
88 | left: 0;
89 | bottom: -40px;
90 |
91 | display: flex;
92 | border-radius: 4px;
93 | width: 100%;
94 | height: 40px;
95 | .chatInput {
96 | margin-top: 5px;
97 | width: 100%;
98 | height: 30px;
99 | border: none;
100 | }
101 | button {
102 | margin-left: 10px;
103 | height: 40px;
104 | width: 55px;
105 | display: hidden;
106 | border: none;
107 | border-radius: 4px;
108 | background-color: #fee500;
109 | &:active {
110 | background-color: darken($color: #fee500, $amount: 10);
111 | }
112 | }
113 | }
114 | }
115 |
116 | .headerUploadButton {
117 | border: 0;
118 | background: transparent;
119 | color: $purple;
120 | width: 140px;
121 | height: 120px;
122 | border-radius: 10px;
123 | font-weight: bold;
124 | font-size: large;
125 | cursor: pointer;
126 | stroke: none;
127 | fill: $purple;
128 |
129 | &:hover {
130 | svg {
131 | stroke: $semi-white;
132 | background-color: $purple;
133 | fill: $semi-white;
134 | }
135 | }
136 |
137 | svg {
138 | width: 50px;
139 | height: 50px;
140 | padding: 0.5rem;
141 | border-radius: 999px;
142 | }
143 | }
144 | .UploadModalInner {
145 | position: absolute;
146 | width: 300px;
147 | height: 530px;
148 | background-color: white;
149 | z-index: 100;
150 | border-radius: 10px;
151 | .uploadForm {
152 | position: relative;
153 | margin-top: 13%;
154 | margin-left: 2.5em;
155 | .input {
156 | display: none;
157 | }
158 | .submitButton {
159 | border: 0;
160 | height: 35px;
161 | width: 52px;
162 | background-color: $purple;
163 | color: white;
164 | float: right;
165 | margin-right: 42px;
166 | display: block;
167 | border-radius: 0.25em;
168 | cursor: pointer;
169 | }
170 | .musicForm {
171 | margin-bottom: 2em;
172 | }
173 | .thumbnailForm {
174 | margin-bottom: 2em;
175 | }
176 | .musicName {
177 | outline: none;
178 | border: 3px solid $purple;
179 | border-radius: 0.5em;
180 | height: 30px;
181 | width: 150px;
182 | }
183 | .thumbnailName {
184 | outline: none;
185 | border: 3px solid $purple;
186 | border-radius: 0.5em;
187 | height: 30px;
188 | width: 150px;
189 | }
190 | .title {
191 | margin-bottom: 0.5em;
192 | font-weight: bold;
193 | }
194 | .singer {
195 | outline: none;
196 | border: 3px solid $purple;
197 | border-radius: 0.5em;
198 | height: 30px;
199 | width: 210px;
200 | margin-bottom: 2em;
201 | }
202 | .descript {
203 | outline: none;
204 | border: 3px solid $purple;
205 | border-radius: 0.5em;
206 | resize: none;
207 | height: 100px;
208 | width: 212px;
209 | margin-bottom: 2em;
210 | }
211 |
212 | label {
213 | padding: 8px 12px;
214 | margin-left: 0.5em;
215 | color: white;
216 | vertical-align: middle;
217 | background-color: $purple;
218 | cursor: pointer;
219 | border-radius: 0.25em;
220 | }
221 | }
222 | }
223 |
--------------------------------------------------------------------------------
/frontend/src/stylesheets/userList.scss:
--------------------------------------------------------------------------------
1 | @import './palette.scss';
2 |
3 | .userList {
4 | width: 400px;
5 | height: 150px;
6 | background-color: #beaee2;
7 | color: #f9f9f9;
8 | margin-bottom: 1rem;
9 | padding: 1rem;
10 | box-sizing: border-box;
11 | border-radius: 0.25rem;
12 |
13 | &-userItem {
14 | cursor: pointer;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/frontend/src/types/index.ts:
--------------------------------------------------------------------------------
1 | type fileUploadObject={
2 | descriptionRef:React.RefObject,
3 | singerRef:React.RefObject,
4 | musicFileRef:React.RefObject,
5 | thumbnailFileRef:React.RefObject,
6 | uploadedFile:FileType,
7 | setUploadedFile:React.Dispatch>,
8 | timerRef: React.MutableRefObject,
9 | textAlertRef:React.RefObject,
10 | fileAlertRef:React.RefObject
11 | }
12 |
13 | type Room = {
14 | id: string;
15 | name: string;
16 | description: string;
17 | totalUser: number;
18 | };
19 |
20 | type Music = {
21 | MID: number;
22 | name: string;
23 | src: string;
24 | isPlayed: boolean;
25 | singer: string;
26 | thumbnail: string;
27 | description: string;
28 | };
29 |
30 | type music = {
31 | MID: number;
32 | name: string;
33 | singer: string;
34 | description: string;
35 | thumbnail: string;
36 | path: string;
37 | isPlayed: boolean;
38 | };
39 |
40 | type FileType = {
41 | musicName: string;
42 | thumbnailName: string;
43 | singer: string;
44 | descript: string;
45 | musicFile: FileList | null;
46 | thumbnailFile: FileList | null;
47 | };
48 |
49 | type timeoutRef = {
50 | timer: NodeJS.Timeout | null;
51 | };
52 |
53 | type fetchState = {
54 | loading: boolean;
55 | data: Room[] & string[];
56 | error: any;
57 | };
58 |
59 | type musicResultItem = {
60 | name: string;
61 | singer: string;
62 | thumbnail: string;
63 | description: string;
64 | path: string;
65 | };
66 |
67 | type Action =
68 | | { type: 'LOADING' }
69 | | { type: 'SUCCESS'; data: Room[] & string[] }
70 | | { type: 'ERROR'; error: Error }
71 | | { type: null };
72 |
73 | type joinData = {
74 | isRedundancy: boolean;
75 | roomID: string;
76 | };
77 |
78 | export type { Music, FileType, timeoutRef, fetchState, Room, Action, musicResultItem, joinData, music, fileUploadObject};
79 |
--------------------------------------------------------------------------------
/frontend/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": [
5 | "dom",
6 | "dom.iterable",
7 | "esnext"
8 | ],
9 | "allowJs": true,
10 | "skipLibCheck": true,
11 | "esModuleInterop": true,
12 | "allowSyntheticDefaultImports": true,
13 | "strict": true,
14 | "forceConsistentCasingInFileNames": true,
15 | "noFallthroughCasesInSwitch": true,
16 | "module": "esnext",
17 | "moduleResolution": "node",
18 | "resolveJsonModule": true,
19 | "isolatedModules": true,
20 | "noEmit": true,
21 | "jsx": "react-jsx"
22 | },
23 | "include": [
24 | "src"
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------