-
Notifications
You must be signed in to change notification settings - Fork 22
[김수경] sprint11 #42
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
[김수경] sprint11 #42
The head ref may contain hidden characters: "express-\uAE40\uC218\uACBD-sprint11"
Conversation
reach0908
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생많으셨습니다!
| const accessToken = req.headers.authorization?.split(" ")[1]!; | ||
| const decoded = jwt.verify( | ||
| accessToken, | ||
| process.env.JWT_SECRET_KEY! | ||
| ) as JwtPayload & { userId: number }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1]
액세스 토큰에 기반한 유저 정보를 주입해주는 것도 미들웨어로 만들면 좋을 것 같습니다.
VerfiyUserToken과 같은곳에서 토큰 검사 및 토큰이 유효하면 그에 맞는 정보를 req.locals.auth 와 같은 곳에 저장해서 사용하면 됩니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
216번째 줄에서 사용되는 auth.verifyAccessToke(src/middlewares/auth.ts)과 용도가 다를까요? 제가 토큰 검증 함수들을 중복으로 쓴거같긴합니다...
공통
프론트엔드
기존 React(혹은 Next) 프로젝트를 타입스크립트 프로젝트로 마이그레이션 해주세요.
TypeScript를 활용해 프로젝트의 필요한 곳에 타입을 명시해 주세요.
백엔드
기존 Express.js 프로젝트를 타입스크립트 프로젝트로 마이그레이션 해주세요.
tsconfig.json 파일을 생성하고, 필요한 컴파일러 옵션을 설정해야 합니다. (예: outDir).
TypeScript 관련 명령어를 package.json에 설정해 주세요. (예: 빌드 및 개발 서버 실행 명령어).
ts-node와 nodemon을 사용하여 개발 환경을 구성합니다.
nodemon과 함께 ts-node를 사용하여 . ts 파일이 변경될 때 서버를 자동으로 재시작하도록 설정합니다.
Mongoose나 Prisma 등 ORM을 사용하는 경우, 모델에 대한 인터페이스 또는 타입을 정의합니다.
필요한 경우, declare를 사용하여 타입을 오버라이드하거나 확장합니다.