Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend#123/nodejs서버추가 #126

Merged
merged 6 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 8 additions & 1 deletion .github/workflows/githubAction.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: Java CI with Gradle

on:
push:
branches: [ "develop","Backend#105/https설정2", "1차데모" ] # develop 브랜치에 푸쉬하면 스크립트 실행
branches: [ "develop","Backend#123/nodejs서버추가" ] # develop 브랜치에 푸쉬하면 스크립트 실행
pull_request:
branches: [ "develop" ] # develop 브랜치에 풀리퀘되면 스크립트 실행

Expand Down Expand Up @@ -67,6 +67,13 @@ jobs:
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f ./frontend/dockerfile --platform linux/amd64 -t ${{ secrets.DOCKER_REPO }}:frontend ./frontend
docker push ${{ secrets.DOCKER_REPO }}:frontend

- name: Docker build nodejs & push to docker repo
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -f ./nodejs/dockerfile --platform linux/amd64 -t ${{ secrets.DOCKER_REPO }}:nodejs ./nodejs
docker push ${{ secrets.DOCKER_REPO }}:nodejs


# appleboy/ssh-action@master 액션을 사용하여 지정한 서버에 ssh로 접속하고, script를 실행합니다.
# script의 내용은 도커의 기존 프로세스들을 제거하고, docker repo로부터 방금 위에서 push한 내용을 pull 받아 실행하는 것입니다.
Expand Down
7 changes: 7 additions & 0 deletions backend/shareNote/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ services:
volumes:
- ./rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf

nodejs:
container_name: nodejs
image: qmfdnjssk/share_repository:nodejslocal
ports:
- "4000:4000"

restart: on-failure



Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.Backend.shareNote.domain.EmailService;

import jakarta.mail.internet.MimeMessage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.mail.MailProperties;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

Expand All @@ -19,21 +21,54 @@ public class EmailService {
private final JavaMailSender javaMailSender;
@Async
public boolean sendMail(EmailDTO emailDTO) {
boolean msg = false;
SimpleMailMessage message = new SimpleMailMessage();
log.info("이메일 어디로 갔을까?? : " + emailDTO.getTargetMail());
message.setTo(emailDTO.getTargetMail());
message.setSubject("너 내 동료가 돼라");
message.setFrom(mailProperties.getUsername());
message.setText("너 이 링크를 누르고 내 동료가 돼라!! from " +emailDTO.getNickname() + " " + emailDTO.getLink());

try {
javaMailSender.send(message);
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, "utf-8");

helper.setTo(emailDTO.getTargetMail());
helper.setSubject("sharenote 초대장");
helper.setFrom("your-email@example.com"); // 이메일 발신자 주소
String htmlMsg = """
<div style="font-family: 'Arial', sans-serif; color: #333;">
<h2>안녕하세요&nbsp; """ + emailDTO.getNickname() + """
님으로부터 도착한 초대장입니다.</h2>
<p>아래의 버튼을 눌러 노트를 작성해주세요!</p>
<div style="margin: 20px 0;">
<a href='""" + emailDTO.getLink() + """
' style="background-color: #4CAF50; color: white; padding: 14px 20px; text-align: center; text-decoration: none; display: inline-block; border-radius: 5px;">초대장</a>
</div>

</p>
</div>
""";

helper.setText(htmlMsg, true); // HTML 콘텐츠로 이메일 설정


javaMailSender.send(mimeMessage);
return true;
} catch (Exception e) {
e.printStackTrace();
return msg;
return false;
}
return msg = true;

}
}

// boolean msg = false;
// SimpleMailMessage message = new SimpleMailMessage();
// log.info("이메일 어디로 갔을까?? : " + emailDTO.getTargetMail());
// message.setTo(emailDTO.getTargetMail());
// message.setSubject("너 내 동료가 돼라");
// message.setFrom(mailProperties.getUsername());
// message.setText("너 이 링크를 누르고 내 동료가 돼라!! from " +emailDTO.getNickname() + " " + emailDTO.getLink());
//
// try {
// javaMailSender.send(message);
// } catch (Exception e) {
// e.printStackTrace();
// return msg;
// }
// return msg = true;

// }
//}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public ResponseEntity<Object> inviteOrganization(OrganizationInvitation invitati
//쿼리 파라미터로 동작
//이 링크 클릭 시 토큰을 localStorage에 저장하고
//login 시 토큰을 가져와서 organization 초대 수락하기
emailDTO.setLink("http://localhost:3000/organization/invitation/approve?token=" + Token);
//emailDTO.setLink("http://localhost:3000/organization/invitation/approve?token=" + Token);
emailDTO.setLink("http://sharenote.shop/organization/invitation/approve?token=" + Token);
emailService.sendMail(emailDTO);
return ResponseEntity.ok("초대장 전송 완료");
}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/Component/Page/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ function Page() {
const roomId = noteId;
const ydoc = getYDocInstance(roomId);
const provider = new WebsocketProvider(
"wss://demos.yjs.dev/ws", // 웹소켓 서버 주소, // 웹소켓 서버 주소
//"wss://demos.yjs.dev/ws", // 웹소켓 서버 주소, // 웹소켓 서버 주소
"ws://localhost:4000",
//"ws://nodejs:4000", //배포용
roomId, // 방 이름
ydoc
);
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/Component/imageToBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ function ImagetoBackend({ onImageUpload }) {
formData.append("multipartFile", selectedFile);

$.ajax({
url: "http://localhost:8080/api/image",
//url: "http://localhost:8080/api/image",
url: "http://sharenote.shop/api/image",
type: "POST",
data: formData,
processData: false,
Expand Down
20 changes: 20 additions & 0 deletions nodejs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 베이스 이미지로 Node.js 16 버전 사용
FROM node:16

# 작업 디렉토리 설정 (/app 내에서 모든 명령어 실행)
WORKDIR /app

# package.json 및 package-lock.json (있는 경우) 복사
COPY package*.json ./

# 패키지 의존성 설치
RUN npm install

# 나머지 서버 코드 복사
COPY . .

# 서버가 리스닝할 포트 번호 설정
EXPOSE 4000

# 서버 시작 명령어
CMD ["node", "server.js"]
1 change: 1 addition & 0 deletions nodejs/node_modules/.bin/0ecdsa-generate-keypair

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nodejs/node_modules/.bin/0gentesthtml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nodejs/node_modules/.bin/0serve

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nodejs/node_modules/.bin/errno

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nodejs/node_modules/.bin/node-gyp-build

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nodejs/node_modules/.bin/node-gyp-build-optional

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nodejs/node_modules/.bin/node-gyp-build-test

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nodejs/node_modules/.bin/y-websocket

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nodejs/node_modules/.bin/y-websocket-server

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading