Skip to content

[윤세준] Sprint11#46

Merged
basilry merged 4 commits intocodeit-sprint-fullstack:express-윤세준from
YSJ0228:express-윤세준-sprint11
Jun 25, 2025

Hidden character warning

The head ref may contain hidden characters: "express-\uc724\uc138\uc900-sprint11"
Merged

[윤세준] Sprint11#46
basilry merged 4 commits intocodeit-sprint-fullstack:express-윤세준from
YSJ0228:express-윤세준-sprint11

Conversation

@YSJ0228
Copy link

@YSJ0228 YSJ0228 commented Jun 15, 2025

공통

  • Github에 위클리 미션 PR을 만들어 주세요.
  • React 및 Express를 사용해 진행합니다.
  • TypeScript를 활용해 프로젝트의 필요한 곳에 타입을 명시해 주세요.
  • any 타입의 사용은 최소화해 주세요.
  • 복잡한 객체 구조나 배열 구조를 가진 변수에 인터페이스 또는 타입 별칭을 사용하세요.
  • Union, Intersection, Generics 등 고급 타입을 적극적으로 사용해 주세요.
  • 타입 별칭 또는 유틸리티 타입을 사용해 타입 복잡성을 줄여주세요.
  • 타입스크립트 컴파일러가 에러 없이 정상적으로 작동해야 합니다.

백엔드

  • 기존 Express.js 프로젝트를 타입스크립트 프로젝트로 마이그레이션 해주세요.
  • tsconfig.json 파일을 생성하고, 필요한 컴파일러 옵션을 설정해야 합니다. (예: outDir).
  • TypeScript 관련 명령어를 package.json에 설정해 주세요. (예: 빌드 및 개발 서버 실행 명령어).
  • ts-node와 nodemon을 사용하여 개발 환경을 구성합니다.
  • nodemon과 함께 ts-node를 사용하여 .ts 파일이 변경될 때 서버를 자동으로 재시작하도록 설정합니다.
  • Mongoose나 Prisma 등 ORM을 사용하는 경우, 모델에 대한 인터페이스 또는 타입을 정의합니다.
  • 필요한 경우, declare를 사용하여 타입을 오버라이드하거나 확장합니다.

아직 자유게시판 부분을 완성하지 못했습니다ㅠ

@YSJ0228 YSJ0228 changed the base branch from main to express-윤세준 June 20, 2025 15:34
Copy link
Contributor

@basilry basilry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전체적으로 코드 스타일이 깔끔하고 잘 정제되어 있습니다.

프론트 소스도 그렇지만 정말 잘 하시네요.

다만 타입스크립트로 마이그레이션 하는 과정에서 unknown 타입이나 강제캐스팅 as를 사용하시는 경향이 많은데,

이런 부분들은 불확실성을 증대시키므로 지양하시는게 좋습니다.

고생하셨습니다.

console.error('Unhandled Rejection:', reason);
});
const app = express();
const PORT = 5001;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

보통 여기있는 포트나 밑의 origin 내 url은 env로 환경변수 처리하는게 좋습니다.

@@ -0,0 +1,58 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dist 폴더는 gitignore에 작성해서 뺴시는게 좋을 것 같습니다.

});

const app: Express = express();
const PORT: number = 5001;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위에서 말씀드린 내용이죠?

try {
const { userName, email, password }: { userName: string; email: string; password: string } = req.body;

const existingUser: User | null = await prisma.user.findUnique({ where: { email } });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가급적이면 타입에 null은 지양합시다.

import jwt, { JwtPayload } from 'jsonwebtoken';
import { User } from '@prisma/client';

const SECRET_KEY = process.env.JWT_SECRET || "panda-secret";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

시크릿 키를 왜 하드코딩으로 or 연산자 처리를 하였나요?

무조건 환경변수로 처리해주세요~


const router: Router = express.Router();

router.post("/signup", signup as unknown as RequestHandler);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 굳이 as로 강제 타입캐스팅을 할 필요가 있었을까요?

const router: Router = express.Router();

// 댓글 조회
router.get("/:productId/comments", getComments as unknown as RequestHandler);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 동일하네요. 심지어 unknown으로 강제캐스팅은 초큼...

수정바랍니다~

const upload = multer({ storage });

router.post("/upload", verifyToken, upload.single("file"), (req, res) => {
router.post("/upload", verifyToken as unknown as RequestHandler, upload.single("file"), ((req: Request, res: Response) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 있네요. 동일 문제에 대해 더 언급 안하겠습니다.

@basilry basilry merged commit bfaed4c into codeit-sprint-fullstack:express-윤세준 Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants