Git Product home page Git Product logo

realworld-backend's Introduction

RealWorld Example App

[YOUR_FRAMEWORK] codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

This codebase was created to demonstrate a fully fledged fullstack application built with [YOUR_FRAMEWORK] including CRUD operations, authentication, routing, pagination, and more.

We've gone to great lengths to adhere to the [YOUR_FRAMEWORK] community styleguides & best practices.

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

How it works

Describe the general architecture of your app here

Getting started

npm install, npm start, etc.

realworld-backend's People

Contributors

milktea24 avatar ericsimons avatar geromegrignon avatar alonski avatar esakkiraj avatar optikfluffel avatar segmentationfaulter avatar

Watchers

 avatar

realworld-backend's Issues

feat: user 관련 API 개발

개요

API 명세서에 있는 user 관련 API 개발한 후 테스트

세부 사항

  • POST /api/users/login 구현 및 테스트
  • POST /api/users 구현 및 테스트
  • GET /api/user 구현 및 테스트
  • PUT /api/user 구현 및 테스트

docs: 문제 해결 모음

GradleWorkerMain not found 해결

Issue

#1

문제 상황

JaCoCo 도입 중 html 파일이 아닌 xml 파일로 결과를 출력하도록 build.gradle을 바꾸었으나 xml 파일이 생성되지 않았다.
그래서 jacocoTestReport 부분만 따로 실행하니 :test에서 아래와 같은 오류가 발생하였다.

오류: 기본 클래스 worker.org.gradle.process.internal.worker.GradleWorkerMain을(를) 찾거나 로드할 수 없습니다.
원인: java.lang.ClassNotFoundException: worker.org.gradle.process.internal.worker.GradleWorkerMain

해결 방법

결론부터 말하면 Gradle User Home의 경로에 한글이 포함되어서 생긴 문제였다.

Gradle Wrapper도 존재하는 것 확인했고 Build and run using도 IntelliJ IDEA로 변경해주었다.
VM 옵션에서 Dfile 인코딩 옵션도 지워보고 annotation processing를 활성화해봐도 해결이 되지 않았다.

그 뒤로 다양한 삽질을 해보던 중 Gradle User Home에 한글이 포함되면 이러한 에러가 발생할 수 있다고 들었다.
image

Gradle user home 변경하기

  1. 시스템 환경 변수에서 GRADLE_USER_HOME이란 이름을 가진 변수를 생성하고 값으로 한글이 포함되지 않는 .gradle 경로를 작성하면 된다. 나의 경우 D:.gradle을 값으로 넣어주었다.

  2. IntelliJ를 재시작한다.

  3. 이제 Gradle user home이 환경 변수에 입력한 값으로 변경됨을 IntelliJ에서 확인할 수 있고 build가 성공적으로 실행되어 xml 파일이 생성됨을 확인할 수 있다.
    image

image

결론

사용자 이름이든 디렉토리 명이든 개발 환경에서 절대 한글을 넣지 말자...

Reference

https://kaydaela.tistory.com/99
https://oysu.tistory.com/87

fix: Redis로 jwt 토큰 블랙리스트 구현하기

개요

이메일 수정 기능을 위해 Redis 도입

세부 사항

RealWorld API 스펙 상 이메일, 비밀번호로 로그인함에도 본인 이메일을 수정할 수 있어야 한다..
문제는 이메일을 수정하면 jwt 토큰 자체가 변경되어야 하는데(payload에 이메일을 담으므로) 이전에 발급한 jwt 토큰은 만료시간 이전에 무효화시킬 방법이 없다는 것이다. Access Token과 Refresh Token을 사용하는 방법이 가장 좋을 것 같지만 현재 요구 스펙에서는 토큰 하나만을 사용하므로 각 사용자와 토큰을 1대1 대응하여 그 외의 토큰이 들어오면 거부하는 방식으로 일단 구현해야 할 것 같다. Access Token과 Refresh Token을 이용한 구현은 고도화 때 구현한다.

  • Redis 연결
  • Email을 Key로 Value를 Token으로 하여 Token의 검증 로직 수행

feat: profiles 관련 API 개발

개요

API 명세에 있는 profiles 관련 API 구현

세부 사항

  • GET /api/profiles/:username 구현 및 테스트
  • POST /api/profiles/:username/follow 구현 및 테스트
  • DELETE /api/profiles/:username/follow 구현 및 테스트

conf: 프로젝트 환경설정하기

개요

프로젝트 개발 시 사용하기 위한 여러 의존성을 추가

상세 내용

의존성

  • 일단 개발 과정에서 데이터베이스는 H2 database를 사용
  • System.out.println 대신 Slf4j와 logback을 이용하여 로그 출력
  • Jacoco를 활용하여 소프트웨어공학에서 학습한 코드 커버리지를 내 프로젝트에서 확인

엔티티

설계한 ERD를 바탕으로 엔티티 생성

체크리스트

의존성

  • H2 database
  • Slf4j
  • Jacoco

엔티티

  • article 도메인(Article, ArticleTag, Comment, FavoriteArticle, Tag)
  • user 도메인(Follow, User)

feat: 로그인 기능 구현

개요

Spring Security를 활용하여 로그인 기능을 구현

상세 내용

image

  • Filter, AuthenticationProvider 구현
  • UserDetails, UserDetailsService 구현
  • 테스트

refactor: UserService 예외 발생 메서드 분리

UserService 내 예외 발생 메서드를 UserValidationService라는 새로운 서비스를 생성하여 옮긴다.
이를 통해 UserService 내 예외 처리에 대한 관심사를 분리하여 중복을 줄이고 유지보수성을 증가시키는 것이 목표이다.

  • UserService와 ProfileService에 있는 예외 발생 메서드를 UserValidationService로 옮기기
  • 예외 발생 메서드 내 if else 문 제거하고 Optional의 orElseThrow를 사용하도록 변경

refactor: 1주차 개선사항

개요

1주차에 개선이 필요한 부분 다시 작성

세부 사항

  • Jwt Token에 Authorities를 추가함으로써 JwtAuthenticationFilter에서 BoardUserDetailsService 의존성 제거
  • UsernamePasswordAuthenticationProvider가 동작하는지 확인
  • Mock 클래스와 테스트 상수 효율적으로 관리할 수 있는 방법 찾아보기

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.