Dietfriends Todo Demo App의 API Spec을 기반으로 진행한Todo API프로젝트입니다.
| 도구 | 버전 |
|---|---|
| Framework | Spring Boot 2.2.4 |
| OS | Windows 10, Ubuntu 18.04 |
| IDE | IntelliJ IDEA Ultimate |
| JDK | JDK 1.8+ |
| DataBase | MySQL Server 5.7, H2 |
| Build Tool | Gradle 4.8.1 |
세부정보
세부정보
-
준비사항.
-
GradleorIntelliJ IDEA -
JDK(>= 1.8) -
Spring Boot(>= 2.x)
-
-
저장소를
clone$ git clone https://github.com/donghL-dev/Dietfriends-Todo-Demo-App.git
-
DB는MySQL을 사용한다고 가정.- 다른
DB를 사용한다면, 그DB에 맞게 설정을 해야함.
- 다른
-
프로젝트 내
Dietfriends-Todo-Demo-App\src\main\resources경로에application.yml생성.- 밑의 양식대로 내용을 채운 뒤,
application.yml에 삽입.
spring: datasource: url: jdbc:mysql://localhost:3306/본인_DB?serverTimezone=UTC username: 본인_DB_User password: 본인_DB_User_Password driver-class-name: com.mysql.cj.jdbc.Driver jpa: hibernate: ddl-auto: create servlet: multipart: enabled: true max-file-size: 200MB max-request-size: 215MB file: upload-dir: ./uploads todo: jjwt: secret: secret key expiration: 만료 시간
- 밑의 양식대로 내용을 채운 뒤,
-
IntelliJ IDEA(>= 2018.3)에서 해당 프로젝트를Open-
또는 터미널을 열어서 프로젝트 경로에 진입해서 다음 명령어를 실행.
-
Windows 10$ gradlew bootRun
-
Ubuntu 18.04$ ./gradlew bootRun
-
세부정보
-
Spring Web -
Spring Data JPA -
Spring Security -
Spring Configuration Processor -
JSON Web Token Support For The JVM -
Apache Commons IO -
JUnit Jupiter API -
MySQL Driver -
H2 Database -
Lombok
세부정보
-
모든
API에 대한 반환은Content-Type: application/json; charset=utf-8를 기본으로 합니다.API명세에 따라서 일부API는HTTP Status Code만 반환합니다.
-
인증(
auth)은HTTP헤더를 사용해서 진행됩니다.Key Value Content-Type application/jsonAuthorization token -
Response-
User-
required-
username -
age
-
{ "idx": 2, "username": "...", "age": 25, "image": "...", "token": "..." } -
-
Single Todo-
required-
name -
completed
-
{ "idx": 2, "name": "...", "completed": "null or boolean", "completedAt": "null or datetime", "createdAt": "9999-99-99T00:00:00.000Z", "updatedAt": "9999-99-99T00:00:00.000Z" } -
-
Multiple Todos[ { "idx": 3, "name": "...", "completed": "null or boolean", "completedAt": "null or datetime", "url": "..." }, { "idx": 2, "name": "...", "completed": "null or boolean", "completedAt": "null or datetime", "url": "..." } ] -
Image ResponseImage File(jpeg, jpg, png) -
Index Response{ "name": "Dietfriends Todo Demo App", "documentation": "https://df-test.docs.stoplight.io/api-reference/intro", "github_repo": "https://github.com/donghL-dev/Dietfriends-Todo-Demo-App", "todoModel": { "createdAt": "Time", "updatedA": "Time", "name": "String", "completed": "Boolean", "completedA": "Time" }, "userModel": { "image": "String", "password": "String", "age": "Integer", "username": "String", "token": "String" }, "endPoints": { "todo": { "DELETE": "/todos/{todoId}", "POST": "/todos", "GET": [ "/todos", "/todos/{todoId}" ], "PUT": "/todos/{todoId}" }, "user": { "DELETE": [ "/user/logout", "/user/image" ], "POST": [ "/user", "/user/auth" ], "GET": [ "/user", "/user/image/{filename}" ], "PUT": "/user/image" } } } -
Errors Response-
required-
status -
error
-
{ "status": "...", "error": "...", "message": "..." } -
-
Default Success Response{ "status": "200 OK", "message": "Your request has been successfully processed." }
-
-
대표적인 에러 코드
-
401 for Unauthorized requests -
400 for Bad requests -
404 for Not found requests -
500 for Server Error requests
-
-
End Point
User API
Title HTTP Method URL Request Response Success HTTP Status Auth RegistrationPOST/user{ "name": "test_name", "age": 25, "password": "test_password1@" }User201NOAuthenticationPOST/users/auth{ "name": "test_name", "password": "test_password1@" }User201NOAuthentication expirationDELETE/user/logoutDefault Success Response200YESCurrent UserGET/userUser200YESProfile Image ReadGET/user/image/{filename}Image Response200NOProfile Image CustomPUT/user/imageform-data(file: ImageFile)User200YESProfile Image InitializationDELETE/user/imageUser200YESTodo API
Title HTTP Method URL Request Response Success HTTP Status Auth Index AccessGET/Index Response200NOList TodosGET/todosMultiple Todos200NOLimit Number of TodosGET/todos?limit={number}Multiple Todos200NOSkip Number of TodosGET/todos?skip={number}Multiple Todos200NOGet TodoGET/todos/{todoId}Single Todo200NOCreate TodoPOST/todos{ "name" : "create todo", "completed": false } Single Todo201YESUpdate TodoPUT/todos/{todoId}{ "name" : "modifyed todo", "completed": true } Single Todo200YESDelete TodoDelete/todos/{todoId}204YES