Skip to content

Commit c74f6b6

Browse files
authored
Merge pull request #82 from SWM-FIRE/FIRE-387-fe-env-깔끔하게-수정하기
FIRE-387-fe-env-깔끔하게-수정하기
2 parents a48eed8 + 550c9b7 commit c74f6b6

File tree

10 files changed

+53
-301
lines changed

10 files changed

+53
-301
lines changed

.env

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
11
SKIP_PREFLIGHT_CHECK=true
2-
REACT_APP_SERVER=https://172.16.101.93:3333/rooms
3-
REACT_APP_SOCKET_URL=https://xn--hq1br4kwqt.com/socket/room
4-
REACT_APP_ROOM=http://172.16.101.93:8282/room
5-
REACT_APP_SEND_USER_INFORMATION_URL=https://모도코.com/api/v1/users
6-
REACT_APP_SOCKET_CHAT_URL=https://모도코.com/socket/chat
7-
REACT_APP_SOCKET_VIDEO_URL=https://모도코.com/socket/video
8-
REACT_APP_SOCKET_ROOM_URL=https://모도코.com/socket/room
9-
REACT_APP_SOCKET_TEST=http://localhost:3001/socket/room
10-
REACT_APP_GET_USER_INFO=https://모도코.com/api/v1/users/
2+
REACT_APP_BASE_URL=https://모도코.com

.env.test

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SKIP_PREFLIGHT_CHECK=true
2+
REACT_APP_BASE_URL=https://localhost:3001

src/adapters/roomConnection.ts

+17-20
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import axios from 'axios';
33
import connectedUsersStore from '../stores/connectedUsersStore';
44
import roomSocket from './roomSocket';
55
import messageStore from '../stores/messagesStore';
6+
import { API } from '../config';
67

78
export const roomConnection = (roomId) => {
89
const { connectedUsers, appendUser, removeUser, findUser } =
@@ -38,22 +39,20 @@ export const roomConnection = (roomId) => {
3839
});
3940

4041
roomSocket.off('newUser').on('newUser', ({ sid, uid }) => {
41-
axios
42-
.get((process.env.REACT_APP_GET_USER_INFO as string) + uid)
43-
.then((res) => {
44-
setConnected({ sid, uid }, res);
45-
console.log('new', res.data.nickname, 'joined');
46-
appendMessages({
47-
uid,
48-
nickname: res.data.nickname,
49-
avatar: res.data.avatar,
50-
message: `${res.data.nickname}님이 입장하셨습니다.`,
51-
createdAt: '',
52-
type: 'join',
53-
isHideTime: false,
54-
isHideNicknameAndAvatar: false,
55-
});
42+
axios.get((API.USER as string) + uid).then((res) => {
43+
setConnected({ sid, uid }, res);
44+
console.log('new', res.data.nickname, 'joined');
45+
appendMessages({
46+
uid,
47+
nickname: res.data.nickname,
48+
avatar: res.data.avatar,
49+
message: `${res.data.nickname}님이 입장하셨습니다.`,
50+
createdAt: '',
51+
type: 'join',
52+
isHideTime: false,
53+
isHideNicknameAndAvatar: false,
5654
});
55+
});
5756
});
5857

5958
roomSocket
@@ -62,11 +61,9 @@ export const roomConnection = (roomId) => {
6261
console.log('existing users', users);
6362
console.log('i am ', current.sid);
6463
users.map((user) => {
65-
axios
66-
.get((process.env.REACT_APP_GET_USER_INFO as string) + user.uid)
67-
.then((res) => {
68-
setConnected(user, res);
69-
});
64+
axios.get((API.USER as string) + user.uid).then((res) => {
65+
setConnected(user, res);
66+
});
7067
return user;
7168
});
7269
});

src/adapters/roomSocket.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { io } from 'socket.io-client';
2+
import { API } from '../config';
23

3-
const roomSocket = io(process.env.REACT_APP_SOCKET_ROOM_URL as string);
4+
const roomSocket = io(API.SOCKET as string);
45

56
export default roomSocket;

src/components/login/UserInput.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import UserStore from '../../stores/userStore';
77
import Avater from './Avatar';
88
import Nickname from './Nickname';
99
import userInterface from '../../interface/user.interface';
10+
import { API } from '../../config';
1011

1112
let type: string;
1213

@@ -40,11 +41,9 @@ export default function UserInput({
4041
}, []);
4142

4243
const userRequest = async (newUser: userInterface) => {
43-
const API_URL: string = process.env
44-
.REACT_APP_SEND_USER_INFORMATION_URL as string;
4544
const { data } = await axios({
4645
method: type,
47-
url: API_URL,
46+
url: API.USER,
4847
data: newUser,
4948
});
5049
return data;

src/components/rtc/components/PeerConnectionSession.ts

-163
This file was deleted.

src/components/rtc/hooks/useStartPeerSession.ts

-85
This file was deleted.

src/config.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const BASE_URL = process.env.REACT_APP_BASE_URL;
2+
const API_VER = '/api/v1';
3+
const USER = '/users/';
4+
const ROOM = '/rooms/';
5+
const SOCKET = '/socket/room';
6+
7+
export const API = {
8+
SOCKET: `${BASE_URL}${SOCKET}`,
9+
ROOM: `${BASE_URL}${API_VER}${ROOM}`,
10+
USER: `${BASE_URL}${API_VER}${USER}`,
11+
};

0 commit comments

Comments
 (0)