Skip to content

[하동우]sprint5#97

Open
hadongwoo02 wants to merge 6 commits intocodeit-bootcamp-nodejs:mainfrom
hadongwoo02:스프린트

Hidden character warning

The head ref may contain hidden characters: "\uc2a4\ud504\ub9b0\ud2b8"
Open

[하동우]sprint5#97
hadongwoo02 wants to merge 6 commits intocodeit-bootcamp-nodejs:mainfrom
hadongwoo02:스프린트

Conversation

@hadongwoo02
Copy link
Collaborator

요구사항

기본

  • 기본 항목 1
  • 기본 항목 2

심화

  • 심화 항목 1
  • 심화 항목 2

주요 변경사항

스크린샷

image

멘토에게

  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

Copy link
Collaborator

@ac9831 ac9831 left a comment

Choose a reason for hiding this comment

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

  • .gitignore를 통해 dist 폴더는 제외해 주세요. 왜 필요가 없는지는 dist 폴더의 역할을 한번 찾아보시는 걸 추천드려요.

...(title !== undefined && { title }),
...(content !== undefined && { content }),
...(image !== undefined && { image }),
}, });
Copy link
Collaborator

Choose a reason for hiding this comment

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

title, content, image 변수가 보이지 않아요

where: { id },
data: { content },
});

Copy link
Collaborator

Choose a reason for hiding this comment

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

DB Update 이후 다음 동작이 있어야 할 것 같아요


try {
const { userId } = verifyAccessToken(accessToken);
const user = await prismaClient.user.findUnique({ where: { id: userId } });
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기서 사용하는 userId는 Int로 보이는데요. verifyAccesstoken에서 나오는 userId는 string으로 보이네요

declare global {
namespace Express {
interface Request {
user?: Omit<PrismaUser, 'password'> | null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

PrismaUser를 import 해야 할 것 같네요


const commentsWithCursor = await prismaClient.comment.findMany({
cursor: cursor ? { id: cursor } : undefined,
take: limit + 1,
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기 밑에 추가로 조건 및 패턴을 넣으면 더 정확한 값이 나올 수 있어요. cusor 레코드가 포함될 수 있으니 바꾸는 것을 추천 드립니다.

const articlesWithLikes = articles.map((article) => ({
...article,
likes: undefined,
likeCount: article.likes.length,
Copy link
Collaborator

Choose a reason for hiding this comment

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

이 방법보다는 다른 방법으로 각 article별 like를 가져오는 방법이 있어요.
_count를 한번 찾아보세요

productId Int?
article Article? @relation(fields: [articleId], references: [id], onDelete: Cascade)
articleId Int?
user User @relation(fields: [userId], references: [id])
Copy link
Collaborator

Choose a reason for hiding this comment

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

articleId와 productId가 둘다 null 허용인데요. 둘다 들어올 수도 있습니다.
이걸 막기위해서는 무엇을 해야 할까요?

import { create } from 'superstruct';
import bcrypt from 'bcrypt';
import { prismaClient } from '../lib/prismaClient.js';
import { generateTokens, verifyRefreshToken } from '../lib/token.js';
Copy link
Collaborator

Choose a reason for hiding this comment

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

.js로 가져오는 코드가 있네요.
ts 방식으로 바꾸는 것을 추천해요

@@ -0,0 +1,13 @@
import { Request, Response, NextFunction } from "express";

type asyncHandler = (req: Request, res: Response)=> Promise<void>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Promise로 되어 있는데요.
모든 반환이 void인가요? 아닌것도 있는거 같아서 타입 체크를 하면 틀리게 나올 때가 있을 것 같아요


export async function createArticle(req: Request, res: Response) {
if (!req.user) {
throw new UnauthorizedError('Unauthorized');
Copy link
Collaborator

Choose a reason for hiding this comment

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

에러는 모두 throw → globalErrorHandler에서 처리하는 것을 추천드려요

@ac9831
Copy link
Collaborator

ac9831 commented Jan 20, 2026

@hadongwoo02 머지 안되는 거 해결 부탁드려요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants