Skip to content

Commit 70c007f

Browse files
authored
merge: [BE] 릴리즈 머지 (#261)
merge: [BE] 릴리즈 머지 (#261)
2 parents e2729df + beda034 commit 70c007f

File tree

6 files changed

+53
-32
lines changed

6 files changed

+53
-32
lines changed

README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<h3>동료들과 함께 소통하며 알고리즘 학습을 할 수 있는 플랫폼</h3>
66
<h5>🗝️ KeyWords<h5>
7-
#WebRTC #Socket #CRDT
7+
<p>#WebRTC #Socket #CRDT</p>
88
<br>
99
<div align="center">
1010
<img src="https://img.shields.io/badge/node-339933?&logo=node.js&logoColor=white">
@@ -94,8 +94,6 @@ Pub/Sub을 활용해 다중 서버 환경에서도 채팅을 할 수 있습니
9494
- 429 Error 및 InMemory 용량부족 해결 과정 (16만건 처리에 걸리는 시간 64% 감소)
9595
- [도커 이미지 최적화](https://energetic-palm-634.notion.site/f35c15bc99a842a18ce095fa6bf1c806?v=efbb8ec67beb43b89792200fc1f3c9a1&pvs=4)
9696
- 도커 이미지 사이즈 85% 감소시킨 이야기
97-
- [서버에서 OAuth 처리하여 자원 보호하기](https://energetic-palm-634.notion.site/69f2e78273884a65b52c370debb83073?v=2b272ead31924af59732edbda24cef84&pvs=4)
98-
- OAuth2.0을 도입하고 안전하게 자원을 관리하는 이야기
9997

10098
# 🔎 개발기
10199
개발하면서 공부한 내용들과 고민 과정, 이유, 해결 방법을 기록했습니다.
@@ -112,8 +110,8 @@ Pub/Sub을 활용해 다중 서버 환경에서도 채팅을 할 수 있습니
112110
- [Transaction 관심사 분리하기](https://energetic-palm-634.notion.site/AsyncLocalStorage-Transaction-34f42523c0ec43f4b633eb7944c0b29d?pvs=4)
113111
- [SSL Termination을 통해 안전하게 HTTP 통신하기](https://energetic-palm-634.notion.site/SSL-Termination-HTTP-70c76949740f4452a2899fa1e617628a?pvs=4)
114112
- [Blue-Green으로 무중단 배포하기](https://energetic-palm-634.notion.site/57396ff1e3174251ba2c7487ab070a53?pvs=4)
115-
- [Clove X 도입하기](https://www.notion.so/Clova-Studio-d990f41d3e814b708906e64fd4707a24?pvs=4)
116-
113+
- [Clove X 도입하기](https://energetic-palm-634.notion.site/Clova-Studio-d990f41d3e814b708906e64fd4707a24?pvs=4)
114+
- [서버에서 OAuth 처리하여 자원 보호하기](https://energetic-palm-634.notion.site/OAuth-2-0-2bc01496ac9c4ed6b0118642c887828d?pvs=4)
117115

118116
[👉 더 많은 기술정리 보러가기](https://www.notion.so/f4562ec49e0245d2b6ef203588c031ea?v=fbfeb754b1a4471e8ffc174a45c64346&pvs=4)
119117

@@ -126,8 +124,11 @@ Pub/Sub을 활용해 다중 서버 환경에서도 채팅을 할 수 있습니
126124
| **Front-End** | **Front-End** | **Back-End** | **Back-End** |
127125
| [@HBSPS](https://github.com/HBSPS) | [@d0422](https://github.com/d0422) | [@HKLeeeee](https://github.com/HKLeeeee) | [@Gseungmin](https://github.com/Gseungmin) |
128126

127+
![AlgoITNi](https://github.com/boostcampwm2023/web05-AlgoITNi/assets/84272873/db73a539-bb3f-4cf0-af23-81e23adc6b17)
128+
129129

130130
## 우리가 일하는 방식
131+
131132
- [그라운드 룰](https://energetic-palm-634.notion.site/1f2cbea527e341c7ad1c8fd84ed5104d?pvs=4)
132133
- [깃 컨벤션](https://energetic-palm-634.notion.site/Git-Convention-8563596644404eb49148a940773d2be8?pvs=4)
133134
- [게더타운 규칙](https://energetic-palm-634.notion.site/b3b67313c1f748e7b58abf99466b000b?pvs=4)

backEnd/api/src/auth/auth.controller.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ export class AuthController {
5151
const id_token: string = await this.googleService.getIDToken(code);
5252
const user: UserDto = await this.googleService.getUserInfo(id_token);
5353
let findUser = await this.userService.findUser(user);
54+
this.logger.error(JSON.stringify(findUser));
5455
if (findUser === null) {
55-
await this.userService.addUser(user, 'google');
56-
findUser = await this.userService.findUser(user);
56+
findUser = await this.userService.getUserAfterAddUser(user, 'google');
5757
}
58+
this.logger.error(JSON.stringify(findUser));
59+
5860
const returnTo: string = await this.authService.login(findUser, res, req);
5961
return res.redirect(returnTo);
6062
}
@@ -83,10 +85,12 @@ export class AuthController {
8385
const accessToken = await this.githubService.getGithubAccessToken(code);
8486
const user: UserDto = await this.githubService.getUserInfo(accessToken);
8587
let findUser = await this.userService.findUser(user);
88+
this.logger.error(JSON.stringify(findUser));
8689
if (findUser === null) {
87-
await this.userService.addUser(user, 'github');
88-
findUser = await this.userService.findUser(user);
90+
findUser = await this.userService.getUserAfterAddUser(user, 'github');
8991
}
92+
this.logger.error(JSON.stringify(findUser));
93+
9094
const returnTo: string = await this.authService.login(findUser, res, req);
9195

9296
return res.redirect(returnTo);

backEnd/api/src/common/transaction/transaction.service.ts

+17-14
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,23 @@ export class TransactionService implements OnModuleInit {
5858
return async function (...args: any[]) {
5959
const qr = await dataSource.createQueryRunner();
6060

61-
await queryRunnerLocalStorage.run({ qr }, async function () {
62-
try {
63-
await qr.startTransaction();
64-
const result = await originalMethod.apply(instance, args);
65-
await qr.commitTransaction();
66-
return result;
67-
} catch (e) {
68-
await qr.rollbackTransaction();
69-
this.logger.error(e);
70-
throw new TransactionRollback();
71-
} finally {
72-
await qr.release();
73-
}
74-
});
61+
const result = await queryRunnerLocalStorage.run(
62+
{ qr },
63+
async function () {
64+
try {
65+
await qr.startTransaction();
66+
const result = await originalMethod.apply(instance, args);
67+
await qr.commitTransaction();
68+
return result;
69+
} catch (e) {
70+
await qr.rollbackTransaction();
71+
throw new TransactionRollback();
72+
} finally {
73+
await qr.release();
74+
}
75+
},
76+
);
77+
return result;
7578
};
7679
}
7780

backEnd/api/src/users/users.service.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,23 @@ export class UsersService {
1515
private usersRepository: Repository<UserEntity>,
1616
) {}
1717
@Transactional('typeorm')
18-
async addUser(userDTO: UserDto, oauth: OAUTH) {
18+
async getUserAfterAddUser(
19+
userDTO: UserDto,
20+
oauth: OAUTH,
21+
): Promise<UserEntity> {
1922
const user = new UserEntity();
2023
user.name = userDTO.name;
2124
user.authServiceID = userDTO.authServiceID;
2225
user.oauth = oauth;
2326
const repository = getLocalStorageRepository(UserEntity);
2427
await repository.save<UserEntity>(user);
28+
29+
const find = await repository.findOne({
30+
where: {
31+
authServiceID: userDTO.authServiceID,
32+
},
33+
});
34+
return find as UserEntity;
2535
}
2636

2737
async findUser(userDTO: UserDto): Promise<UserEntity> {

backEnd/chat/src/chat/chat.gateway.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class ChatGateway implements OnGatewayConnection, OnGatewayDisconnect {
120120
try {
121121
await this.publisherClient.publish(
122122
SOCKET.REDIS_CHAT_CHANEL,
123-
JSON.stringify({ using: true }),
123+
JSON.stringify({ room: room, using: true }),
124124
);
125125

126126
const llmMessageDto: LLMMessageDto = await this.processAIResponse(

backEnd/running/src/codes/codes.service.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export class CodesService {
2525
process.env.NODE_ENV === 'dev'
2626
? path.join(__dirname, '..', 'tmp')
2727
: '/algoitni';
28-
private killSignal: NodeJS.Signals = 'SIGINT';
28+
private readonly killSignal: NodeJS.Signals = 'SIGINT';
29+
private readonly killCode: number = 130;
2930
private readonly timeOut = 5000;
3031
constructor() {
3132
if (!fs.existsSync(this.tempDir)) {
@@ -40,7 +41,6 @@ export class CodesService {
4041
try {
4142
fs.writeFileSync(filePath, code);
4243
const { stdout, stderr } = await this.runCommand(filePaths, language);
43-
this.logger.debug(`${stdout}, ${stderr}`);
4444
if (stderr) {
4545
throw new RunningException(stderr.trim());
4646
}
@@ -62,7 +62,6 @@ export class CodesService {
6262
language: supportLang,
6363
): Promise<runCommandResult> {
6464
const commands = languageCommand(language, filePaths);
65-
this.logger.debug(JSON.stringify(commands));
6665

6766
let command;
6867
if (commands.length > 1) {
@@ -99,10 +98,10 @@ export class CodesService {
9998
this.logger.log(`child process exited with code ${code}, ${signal}`);
10099
clearTimeout(timer);
101100
const out = Buffer.concat(stdout).toString();
102-
const err =
103-
signal === this.killSignal
104-
? Messages.TIMEOUT
105-
: Buffer.concat(stderr).toString();
101+
let err = Buffer.concat(stderr).toString();
102+
if (this.isTimeout(code, signal)) {
103+
err = Messages.TIMEOUT;
104+
}
106105
resolve({ stdout: out, stderr: err });
107106
});
108107
} catch (e) {
@@ -164,4 +163,8 @@ export class CodesService {
164163
path.join(this.tempDir, `${uuid}${distExtension}`),
165164
];
166165
}
166+
167+
isTimeout(code: number, signal: NodeJS.Signals) {
168+
return code === this.killCode || signal === this.killSignal;
169+
}
167170
}

0 commit comments

Comments
 (0)