-
Notifications
You must be signed in to change notification settings - Fork 33
[이제창] 스프린트미션5 #143
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
Open
Jerang2
wants to merge
65
commits into
codeit-bootcamp-nodejs:main
Choose a base branch
from
Jerang2:sprintmission5
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[이제창] 스프린트미션5 #143
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
f8faf87
[이제창] sprint2 (#43)
Jerang2 2564887
feat: sprintmission3
Jerang2 1439346
feat: image resize
Jerang2 f9a48f6
Merge branch '이제창' into main
rdd9223 39cde28
prisma.schema 수정
Jerang2 ac96417
prisma migrate
Jerang2 59e7d84
bcrypt install
Jerang2 ae377b5
UserService.js 생성
Jerang2 3f4b18c
users.router.js 생성
Jerang2 37122cf
ESM 방식 -> CommonJs 방식으로 수정
Jerang2 33c6e2b
회원가입 API 완료?
Jerang2 dab8731
오타 수정
Jerang2 d19e9be
UserService에 로그인 로직 추가
Jerang2 48dceef
users.router.js 로그인 API 추가
Jerang2 b6b9d10
articles.router.js 인증 미들웨어, 소유자 확인 로직 추가
Jerang2 f8b9b45
products.router.js 인증, 로그인 로직 추가
Jerang2 e1cf603
prisma.schema modify T.T
Jerang2 9b8d94e
바뀐 prisma.schema에 맞춰서 수정
Jerang2 48fcfe4
변경된 prisma.schema model로 products.router.js 수정
Jerang2 cb17c18
user.router.js 내 정보 수정 API 구현
Jerang2 71ca614
users.router.js 비밀번호 변경 API 추가
Jerang2 f8efc37
users.router.js 작성 상품 목록 조회 API 추가
Jerang2 df167d3
products.router.js에 좋아요 API 추가
Jerang2 5a421b0
오타 수정
Jerang2 f2f75e7
articles.router.js 좋아요 기능 추가
Jerang2 23a0531
optionalAuth.middleware.js 파일 생성
Jerang2 641ca6d
articles.router.js에 선택적 인증 미들웨어 추가
Jerang2 c4996fd
products.router.js에 상품목록조회 isLiked 필드 추가
Jerang2 a70d66d
articles.router.js에 isLiked 필드 추가
Jerang2 3cc2400
UseService.js의 로그인 로직을 access, refresh token를 받는 형식으로 변경
Jerang2 d9b1629
index.js에 cookie 미들웨어 추가
Jerang2 1d25f6f
오탈자 수정 및 index.js 라우트 설정 추가
Jerang2 4dcee1a
토큰 재발급 API 추가
Jerang2 f97e999
타입스크립트 js -> ts 로 변경
Jerang2 f434962
import문으로 수정
Jerang2 ac533c8
json수정, ts-node설치
Jerang2 b4e01d9
main.ts 수정
Jerang2 b665206
articels.router updateAt추가
Jerang2 57dfa67
products.router 수정
Jerang2 ae34280
select문 수정
Jerang2 d1bff8f
서버 구현 o
Jerang2 2032cc2
src로 이동후 repository add
Jerang2 29c9305
Service 리팩토링
Jerang2 60f5d7f
Controller 구현
Jerang2 b29cb20
roter 리팩토링
Jerang2 fa86962
DTO 생성
Jerang2 b7f019b
dto 추가, 사용하도록 수정
Jerang2 9bb1d8d
Service DTO 사용하도록 수정
Jerang2 4555a12
CommentService, LikeService 추가
Jerang2 6d7c540
Comment, LikeService 로 리팩토링
Jerang2 9c3506a
prisma와 관계 연결
Jerang2 823e702
import문 수정
Jerang2 9b6f392
controller - select문 수정
Jerang2 9261f17
controller - select문 수정 2
Jerang2 72f1bf1
findlikes 추가
Jerang2 e460353
signUp 메서드 수정
Jerang2 b60f8e1
UserService import 수정
Jerang2 ba427c8
import문 수정
Jerang2 64f1a15
cursor, data 객체 수정
Jerang2 b73fd07
Prisma.Product -> Product로 수정
Jerang2 a1b0d28
Prisma.Like -> Like
Jerang2 6c306f9
Prisma.xxx -> xxx 로 수정
Jerang2 3d9c8ec
README.md
Jerang2 d24de79
prettier 추가 및 실행
Jerang2 4c89673
Merge branch 'sprintmission5' of https://github.com/Jerang2/4-sprint-…
Jerang2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| node_modules | ||
| # Keep environment variables out of version control | ||
| .env | ||
| node_modules | ||
| uploads | ||
| /generated/prisma |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "semi": true, | ||
| "trailingComma": "all", | ||
| "singleQuote": true, | ||
| "printWidth": 100, | ||
| "tabWidth": 2 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 스프린트 미션5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| class ArticleService { | ||
| constructor(articleRepository) { | ||
| this.articleRepository = articleRepository; | ||
| } | ||
| async createArticle(data) { | ||
| const { userId, ...rest } = data; | ||
| return this.articleRepository.createArticle({ | ||
| ...rest, | ||
| user: { connect: { id: userId } }, | ||
| }); | ||
| } | ||
| async getArticleById(id) { | ||
| return this.articleRepository.findArticleById(id); | ||
| } | ||
| async getArticles(options) { | ||
| return this.articleRepository.findArticles(options); | ||
| } | ||
| async updateArticle(id, data) { | ||
| return this.articleRepository.updateArticle(id, data); | ||
| } | ||
| async deleteArticle(id) { | ||
| return this.articleRepository.deleteArticle(id); | ||
| } | ||
| } | ||
| exports.default = ArticleService; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| class CommentService { | ||
| constructor(commentRepository) { | ||
| this.commentRepository = commentRepository; | ||
| } | ||
| async createComment(data) { | ||
| const { userId, productId, articleId, ...rest } = data; | ||
| return this.commentRepository.createComment({ | ||
| ...rest, | ||
| user: { connect: { id: userId } }, | ||
| ...(productId && { product: { connect: { id: productId } } }), | ||
| ...(articleId && { article: { connect: { id: articleId } } }), | ||
| }); | ||
| } | ||
| async getCommentById(id) { | ||
| return this.commentRepository.findCommentById(id); | ||
| } | ||
| async getComments(options) { | ||
| return this.commentRepository.findComments(options); | ||
| } | ||
| async updateComment(id, data) { | ||
| return this.commentRepository.updateComment(id, data); | ||
| } | ||
| async deleteComment(id) { | ||
| return this.commentRepository.deleteComment(id); | ||
| } | ||
| } | ||
| exports.default = CommentService; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| class LikeService { | ||
| constructor(likeRepository) { | ||
| this.likeRepository = likeRepository; | ||
| } | ||
| async createLike(data) { | ||
| const { userId, productId, articleId, ...rest } = data; | ||
| return this.likeRepository.createLike({ | ||
| ...rest, | ||
| user: { connect: { id: userId } }, | ||
| ...(productId && { product: { connect: { id: productId } } }), | ||
| ...(articleId && { article: { connect: { id: articleId } } }), | ||
| }); | ||
| } | ||
| async deleteLike(id) { | ||
| return this.likeRepository.deleteLike(id); | ||
| } | ||
| async findLikeByUserIdAndProductId(userId, productId) { | ||
| return this.likeRepository.findLikeByUserIdAndProductId(userId, productId); | ||
| } | ||
| async findLikeByUserIdAndArticleId(userId, articleId) { | ||
| return this.likeRepository.findLikeByUserIdAndArticleId(userId, articleId); | ||
| } | ||
| async findLikes(options) { | ||
| return this.likeRepository.findLikes(options); | ||
| } | ||
| } | ||
| exports.default = LikeService; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| class ProductService { | ||
| constructor(productRepository) { | ||
| this.productRepository = productRepository; | ||
| } | ||
| async createProduct(data) { | ||
| const { userId, ...rest } = data; | ||
| return this.productRepository.createProduct({ | ||
| ...rest, | ||
| user: { connect: { id: userId } }, | ||
| }); | ||
| } | ||
| async getProductById(id) { | ||
| return this.productRepository.findProductById(id); | ||
| } | ||
| async getProducts(options) { | ||
| return this.productRepository.findProducts(options); | ||
| } | ||
| async updateProduct(id, data) { | ||
| return this.productRepository.updateProduct(id, data); | ||
| } | ||
| async deleteProduct(id) { | ||
| return this.productRepository.deleteProduct(id); | ||
| } | ||
| } | ||
| exports.default = ProductService; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const bcrypt_1 = __importDefault(require("bcrypt")); | ||
| const jsonwebtoken_1 = __importDefault(require("jsonwebtoken")); | ||
| class UserService { | ||
| constructor(userRepository) { | ||
| // 회원가입 로직 | ||
| this.signUp = async (userData) => { | ||
| const { email, nickname, password } = userData; | ||
| // 이메일 중복 확인 | ||
| const existingUser = await this.userRepository.findUserByEmail(email); | ||
| if (existingUser) { | ||
| throw new Error('이미 사용중인 이메일입니다.'); | ||
| } | ||
| // 비밀번호 해싱 | ||
| const hashedPassword = await bcrypt_1.default.hash(password, 10); | ||
| // 유저 생성 | ||
| const user = await this.userRepository.createUser({ | ||
| email, | ||
| nickname, | ||
| password: hashedPassword, | ||
| }); | ||
| // 사용자 정보 반환 | ||
| const { password: _, refreshToken: __, ...userWithoutPassword } = user; | ||
| return userWithoutPassword; | ||
| }; | ||
| this.signIn = async (email, password) => { | ||
| // 이메일로 사용자 조회 | ||
| const user = await this.userRepository.findUserByEmail(email); | ||
| if (!user) { | ||
| throw new Error('존재하지 않는 이메일입니다.'); | ||
| } | ||
| // 비밀번호 확인 | ||
| const isPasswordMatched = await bcrypt_1.default.compare(password, user.password); | ||
| if (!isPasswordMatched) { | ||
| throw new Error('비밀번호가 일치하지 않습니다.'); | ||
| } | ||
| // Access Token 생성 (12시간) | ||
| const accessToken = jsonwebtoken_1.default.sign({ userId: user.id }, process.env.JWT_SECRET_KEY, { expiresIn: '12h' }); | ||
| // Refresh Token 생성 (7일) | ||
| const refreshToken = jsonwebtoken_1.default.sign({ userId: user.id }, process.env.REFRESH_TOKEN_SECRET_KEY, { expiresIn: '7d' }); | ||
| // Refresh Token을 해싱해서 DB에 저장 | ||
| await this.userRepository.updateUser(user.id, { | ||
| refreshToken: await bcrypt_1.default.hash(refreshToken, 10), | ||
| }); | ||
| return { accessToken, refreshToken }; | ||
| }; | ||
| this.getUserById = async (id) => { | ||
| return this.userRepository.findUserById(id); | ||
| }; | ||
| this.updateUser = async (id, data) => { | ||
| return this.userRepository.updateUser(id, data); | ||
| }; | ||
| this.updatePassword = async (id, newPasswordHash) => { | ||
| return this.userRepository.updateUser(id, { password: newPasswordHash }); | ||
| }; | ||
| this.getProductsByUserId = async (userId) => { | ||
| return this.userRepository.findProductsByUserId(userId); | ||
| }; | ||
| this.userRepository = userRepository; | ||
| } | ||
| } | ||
| exports.default = UserService; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
dist 하위의 빌드 파일은 커밋할 필요 없습니다.
.gitignore에 해당 디렉토리를 추가해주세요.