Skip to content

Commit

Permalink
Merge pull request #131 from boostcampwm-2021/develop
Browse files Browse the repository at this point in the history
[Hotfix] 엔티티 수정에 따라 추가 배포
  • Loading branch information
LeeMir authored Nov 22, 2021
2 parents 44f0262 + 3a17611 commit 99d27c2
Show file tree
Hide file tree
Showing 41 changed files with 511 additions and 352 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ https://www.boostteams.kro.kr/
- 채팅방 인원의 팀원 초대 기능
- 채팅방 관리자의 팀원 강퇴, 채팅방 이름 변경 기능
- 채팅 코멘트(이모지) 기능

### 팀 일정
- 팀 공유 달력 기능
- 새로운 일청 추가 기능
- 새로운 일정 추가 기능
- 상세 일정 확인 기능
- 일정 삭제 기능

### 팀 보드
- 팀이 공유하는 사무실의 화이트보드와 같은 기능
- 포스트잇 생성 및 drag & drop으로 이동
Expand All @@ -58,5 +60,5 @@ https://www.boostteams.kro.kr/

- [Backlog: Google Docs](https://docs.google.com/spreadsheets/d/1xsavcgsEpVtQNjWshUdCxH5Vqc1FIca0p2LQfSkZy4g)

- [DB Schema: Notion](https://www.notion.so/DB-Schema-1dadf07949f4445c9102ed82acb19ab5)
- [DB Schema: Github Wiki](https://github.com/boostcampwm-2021/WEB29-BoostTeams/wiki/DB-%EC%8A%A4%ED%82%A4%EB%A7%88)

11 changes: 11 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@
### .env

```
PORT=[SERVER PORT]
FRONT_URL=[CLIENT URL]
DB_HOST=[DB HOST]
DB_PORT=[DB PORT]
DB_USERNAME=[DB Username]
DB_PASSWORD=[DB UserPW]
DB_DATABASENAME=[DB Name]
GITHUB_CLIENT_ID=[Github Client ID]
GITHUB_CLIENT_SECRET=[Github Client Secret]
GITHUB_CALLBACK_URL=[Github Callback URL]
JWT_SECRET_KEY=[JWT Secret Key]
AES_KEY=[AES Secret Key]
SALT_OR_ROUNDS=[Bcrypt Round]
```
2 changes: 2 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"passport": "^0.5.0",
"passport-github": "^1.1.0",
"passport-local": "^1.0.0",
"redis": "^3.1.2",
"reflect-metadata": "^0.1.13",
"socket.io": "^4.3.1",
"typeorm": "^0.2.38",
Expand All @@ -35,6 +36,7 @@
"@types/node": "^16.11.6",
"@types/passport-github": "^1.1.6",
"@types/passport-local": "^1.0.34",
"@types/redis": "^2.8.32",
"@types/uuid": "^8.3.1",
"@typescript-eslint/eslint-plugin": "^5.2.0",
"@typescript-eslint/parser": "^5.2.0",
Expand Down
10 changes: 5 additions & 5 deletions backend/src/entities/chat_room-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import { User } from './user';
export class ChatRoomUser {
@PrimaryGeneratedColumn()
chat_room_user_id!: number;

@Column()
user_id: number;

@Column()
chat_room_id: number;

@ManyToOne(() => User, (user) => user.user_id)
@JoinColumn({ name: 'user_id' })
user: User;

@ManyToOne(() => ChatRoom, (chatRoom) => chatRoom.chat_room_id)
@JoinColumn({ name: 'chat_room_id' })
chat_room: ChatRoom;
}
}
10 changes: 5 additions & 5 deletions backend/src/entities/chat_room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Entity, PrimaryGeneratedColumn, ManyToOne, JoinColumn, Column, OneToMan
import { ChatRoomUser } from './chat_room-user';
import { Message } from './message';
import { Team } from './team';

@Entity({ name: 'chat_room' })
export class ChatRoom {
@PrimaryGeneratedColumn()
Expand All @@ -14,13 +14,13 @@ export class ChatRoom {
@ManyToOne(() => Team, (team) => team.team_id, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'team_id' })
team: Team;

@Column()
chat_room_name: string;

@OneToMany(() => ChatRoomUser, (chatRoomUser) => chatRoomUser.chat_room)
chat_room_users: ChatRoomUser[];

@OneToMany(() => Message, (message) => message.chat_room)
messages: Message[];
}
}
5 changes: 4 additions & 1 deletion backend/src/entities/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ export class User {
@Column()
user_name: string;

@Column()
github_id?: string;

@Column()
github_name?: string;

@Column()
user_state: number;
user_color: number;

@OneToMany(() => TeamUser, (teamUser) => teamUser.user)
team_users: TeamUser[];
Expand Down
2 changes: 2 additions & 0 deletions backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dotenv.config();

import 'reflect-metadata';
import { createConnection } from 'typeorm';
import Redis from './redis';
import express from 'express';
import cors from 'cors';

Expand Down Expand Up @@ -39,6 +40,7 @@ class App {
console.log('DB Connected');
})
.catch((error) => console.error(error));
new Redis();
}

private middleware() {
Expand Down
12 changes: 8 additions & 4 deletions backend/src/passport/github-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ const GITHUB_CONFIG = {
const getUserRawData = (userJson) => {
const user_email = userJson.id;
const user_password = userJson.node_id;
const user_name = userJson.name;
return { user_email, user_password, user_name };
const github_name = userJson.name;
const github_id = userJson.login;
return { user_email, user_password, github_name, github_id };
};

const githubLoginCallback = async (accessToken, refreshToken, profile, callback) => {
const { user_email, user_password, user_name } = getUserRawData(profile._json);
const { user_email, user_password, github_name, github_id } = getUserRawData(profile._json);
let user = await UserService.getInstance().getUserByEmail(user_email);
if (!user) user = await UserService.getInstance().createUser(user_email, user_password, user_name, user_name);
if (!user)
user = await UserService.getInstance().createUser(user_email, user_password, github_name, github_id, github_name);
if (user && (github_id !== user.github_id || github_name !== user.github_name))
UserService.getInstance().updateUserToGithub(user.user_id, github_id, github_name);
return callback(null, user);
};

Expand Down
26 changes: 26 additions & 0 deletions backend/src/redis/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { createClient, RedisClient } from 'redis';

export default class Redis {
static instance: Redis;
static client: RedisClient;
constructor() {
if (Redis.instance) return Redis.instance;
else {
Redis.client = createClient({
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
password: process.env.REDIS_PASSWORD
});
Redis.instance = this;
Redis.client.on('connect', () => console.log('Redis connect'));
Redis.client.on('error', (error) => console.log(error));
}
return Redis.instance;
}
get(key: string) {
console.log('redis get');
}
set(key: string, value: any) {
console.log('redis set');
}
}
26 changes: 19 additions & 7 deletions backend/src/services/user-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,29 @@ class UserService {
return undefined;
}

const { user_id, user_email, user_name, user_state, github_name } = user;
return { user_id, user_email, user_name, user_state, github_name };
const { user_id, user_email, user_name, user_color, github_id, github_name } = user;
return { user_id, user_email, user_name, user_color, github_id, github_name };
}

async createUser(user_email: string, encryptedPassword: string, user_name: string, github_name?: string) {
async createUser(
user_email: string,
encryptedPassword: string,
user_name: string,
github_id?: string,
github_name?: string
) {
const decryptedPassword = Crypto.AES.decrypt(encryptedPassword, process.env.AES_KEY).toString();
const user_password = bcrypt.hashSync(decryptedPassword, Number(process.env.SALT_OR_ROUNDS));
const user_state = Math.floor(Math.random() * 12); // TODO : user_color로 바꾸기
const github = github_name ?? '';
const user_color = Math.floor(Math.random() * 12);
const githubId = github_id ?? '';
const githubName = github_name ?? '';
const newUser = await this.userRepository.save({
user_email,
user_password,
user_name,
user_state,
github_name: github
user_color,
github_id: githubId,
github_name: githubName
});
return newUser;
}
Expand All @@ -49,6 +57,10 @@ class UserService {
return await this.userRepository.update({ user_id }, { user_name: newName });
}

async updateUserToGithub(user_id: number, github_id: string, github_name: string) {
return await this.userRepository.update({ user_id }, { github_id, github_name });
}

async getUserByEmail(user_email: string) {
const user = await this.userRepository.findOne({
where: { user_email }
Expand Down
39 changes: 39 additions & 0 deletions backend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,13 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc"
integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==

"@types/redis@^2.8.32":
version "2.8.32"
resolved "https://registry.yarnpkg.com/@types/redis/-/redis-2.8.32.tgz#1d3430219afbee10f8cfa389dad2571a05ecfb11"
integrity sha512-7jkMKxcGq9p242exlbsVzuJb57KqHRhNl4dHoQu2Y5v9bCAbtIXXH0R3HleSQW4CTOqpHIYUW3t6tpUj4BVQ+w==
dependencies:
"@types/node" "*"

"@types/serve-static@*":
version "1.13.10"
resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.10.tgz#f5e0ce8797d2d7cc5ebeda48a52c96c4fa47a8d9"
Expand Down Expand Up @@ -875,6 +882,11 @@ delegates@^1.0.0:
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"
integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=

denque@^1.5.0:
version "1.5.1"
resolved "https://registry.yarnpkg.com/denque/-/denque-1.5.1.tgz#07f670e29c9a78f8faecb2566a1e2c11929c5cbf"
integrity sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==

denque@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/denque/-/denque-2.0.1.tgz#bcef4c1b80dc32efe97515744f21a4229ab8934a"
Expand Down Expand Up @@ -2595,6 +2607,33 @@ readdirp@~3.6.0:
dependencies:
picomatch "^2.2.1"

redis-commands@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/redis-commands/-/redis-commands-1.7.0.tgz#15a6fea2d58281e27b1cd1acfb4b293e278c3a89"
integrity sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==

redis-errors@^1.0.0, redis-errors@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/redis-errors/-/redis-errors-1.2.0.tgz#eb62d2adb15e4eaf4610c04afe1529384250abad"
integrity sha1-62LSrbFeTq9GEMBK/hUpOEJQq60=

redis-parser@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/redis-parser/-/redis-parser-3.0.0.tgz#b66d828cdcafe6b4b8a428a7def4c6bcac31c8b4"
integrity sha1-tm2CjNyv5rS4pCin3vTGvKwxyLQ=
dependencies:
redis-errors "^1.0.0"

redis@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/redis/-/redis-3.1.2.tgz#766851117e80653d23e0ed536254677ab647638c"
integrity sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==
dependencies:
denque "^1.5.0"
redis-commands "^1.7.0"
redis-errors "^1.2.0"
redis-parser "^3.0.0"

reflect-metadata@^0.1.13:
version "0.1.13"
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08"
Expand Down
32 changes: 23 additions & 9 deletions frontend/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
const path = require('path');

module.exports = {
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
'stories': [
'../src/**/*.stories.mdx',
'../src/**/*.stories.@(js|jsx|ts|tsx)'
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/preset-create-react-app"
]
}
'addons': [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/preset-create-react-app'
],
'webpackFinal': async config => {
config.resolve.alias['@'] = path.resolve(__dirname, '../src/');
config.resolve.alias['@apis'] = path.resolve(__dirname, '../src/apis/');
config.resolve.alias['@components'] = path.resolve(__dirname, '../src/components/');
config.resolve.alias['@pages'] = path.resolve(__dirname, '../src/pages/');
config.resolve.alias['@routes'] = path.resolve(__dirname, '../src/routes/');
config.resolve.alias['@stores'] = path.resolve(__dirname, '../src/stores/');
config.resolve.alias['@styles'] = path.resolve(__dirname, '../src/styles/');
config.resolve.alias['@templates'] = path.resolve(__dirname, '../src/templates/');
config.resolve.alias['@utils'] = path.resolve(__dirname, '../src/utils/');
return config;
}
}
50 changes: 6 additions & 44 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,8 @@
# Getting Started with Create React App
## Frontend README

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
### .env

## Available Scripts

In the project directory, you can run:

### `yarn start`

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

The page will reload if you make edits.\
You will also see any lint errors in the console.

### `yarn test`

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

### `yarn build`

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

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.

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.

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.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).
```
REACT_APP_SERVER=[Server URL]
REACT_APP_AES_KEY=[AES Secret Key] (BE와 동일해야 함)
```
1 change: 1 addition & 0 deletions frontend/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = override(
'@stores': path.resolve(__dirname, 'src/stores'),
'@styles': path.resolve(__dirname, 'src/styles'),
'@templates': path.resolve(__dirname, 'src/templates'),
'@types': path.resolve(__dirname, 'src/types'),
'@utils': path.resolve(__dirname, 'src/utils'),
}),
);
Loading

0 comments on commit 99d27c2

Please sign in to comment.