---
# System prepended metadata

title: API 설계

---

# API 설계

User API를 제외한 모든 API에 header로 인증 token값을 넣는다.

```
headers:{
 'Authorization': 'Bearer ${tokenString}'
}

```

## User
| Method | url                                      | description                       |
| ------ | ----------------------------------------- | ------------------------------- |
| GET    | api/user/oauth/naver | naver 아이디로 로그인 |
| GET | api/user/me | 사용 중인 user의 정보 확인 |

## User GET API (naver 아이디로 로그인)

URL
```
GET /api/user/oauth/
```

redirect URL의 query값으로 token이 넘어온다.

## User GET API (사용중인 user의 정보 확인)

URL
```
GET /api/user/me
```

Response
```
{
    id: 1,
    name: "tony",
    email: "aaa@aaa",
}
```



## Project
### Project CRUD
| Method | url                                      | description                       |
| ------ | ----------------------------------------- | ------------------------------- |
| GET    | api/project | project 전체 조회 |
| GET    | api/project/:projectId | project 개별 조회 |
| POST   | api/project | project 생성 | 
| PATCH | api/project/:projectId | project 제목 수정 |
| PUT | api/project/:projectId | project 수정 |
| DELETE | api/project/:projectId | project 삭제 |

### Section CUD
| Method | url                                      | description                       |
| ------ | ----------------------------------------- | ------------------------------- |
| POST   | api/project/:projectId/section | section 생성 | 
| PATCH | api/project/:projectId/section/:sectionId | section 제목 수정 |
| DELETE | api/project/:projectId/section/:sectionId | section 삭제 |



## Project GET API (프로젝트 전체 조회)
URL
```
GET /api/project
```

Response
```
[
    {
        id : 1,
        title: '프로젝트 이름',
        taskCount: 3    
    }
]
```

## Project GET API (프로젝트 개별 조회)


URL
```
GET /api/project/:projectId
```

Response
```
{
    id : 1,
    title: '프로젝트 이름',
    type: 'list || board',
    sections: 
    [
        {
            id: 1,
            tasks: 
            [
                {
                    id : 1,
                    title: '작업1',
                    labels: [{id: 1, title: 'FE'},],
                    priority: {id: 1, title: '우선순위1'},
                    alarm: { ... },
                    dueDate: '2020-11-18',
                    createdAt: '2020-11-18T07:12:41.000Z',
                    updatedAt: '2020-11-18T07:12:41.000Z'
                    childTasks: [{id: 2, title: ...},{}, ...],
                }
            ]
        }
    ]
    
}

```


## Project Post API

URL
```
POST /api/project
```
Request
```
{
    title : '프로젝트 이름',
    type: 'list || board',
    isFavorite : true || false
}
```

Response
```
{
    message: 'ok',
    id: 1,
}
```

## Project Patch API
URL
```
Patch /api/project/:projectID
```
Request
```
{
    title : '새로운 프로젝트 이름', 
}
```

Response
```
{
    message: 'ok'
}
```

## Project Put API
URL
```
PUT /api/project/projectId
```
Request
```
{
    title : '프로젝트 이름',
    type: 'list || board',
    isFavorite : true || false
}
```

Response
```
{
    message: 'ok'
}
```

## Project Delete API
URL
```
DELETE /api/project/:projectId
```
Response
```
{
    message: 'ok'
}
```

## Project - Section POST API
URL
```
POST /api/project/:projectId/section
```
Request
```
{
    title : '새로운 섹션 이름', 
}
```

Response
```
{
    message: 'ok'
}
```

## Project - Section PATCH API
URL
```
PATCH /api/project/:projectId/section/:sectionId
```
Request
```
{
    title : '새로운 섹션 이름', 
}
```

Response
```
{
    message: 'ok'
}
```

## Project - Section DELETE API
URL
```
DELETE /api/project/:projectId/section/:sectionId
```
Response
```
{
    message: 'ok'
}
```

## Task API




## Task GET API
URL
```
GET /api/task/:taskId
```
Response
```
{
    id : 1,
    title: '작업1',
    labels: [{id: 1, title: 'FE'},],
    priority: {id: 1, title: '우선순위1'},
    alarm: { ... },
    dueDate: '2020-11-18',
    createdAt: '2020-11-18T07:12:41.000Z',
    updatedAt: '2020-11-18T07:12:41.000Z'
    childTasks: [{id: 2, title: ...},{}, ...],
}
```

## Task Post API

URL
```
POST /api/task
```
Request
```
{
    title : '할일',
    projectId: 1,
    labelIdList: [1,2,3],
    priorityId: 1,
    alarm: {...},
    dueDate: '2020-11-18',
    parentId: 3
}
```

Response
```
{
    id: 1,
    message: 'ok'
}
```

## Task Patch API
URL
```
PATCH /api/task/:taskId
```
Request
```
{
    title : '할일 변경' || undefined,
    dueDate: '2020-11-19' || undefined,
    projectId: 1 || undefined,
    labelIds: [1, 2, 3] || undefined,
    priority: 3 || undefined,
    parentId : 1 || undefined,
}
```

Response
```
{
    message: 'ok'
}
```


## Task Delete API
URL
```
DELETE /api/task/:taskId
```

Response
```
{
    message: 'ok'
}
```

## Task - Alarm Post API

URL
```
POST /api/task/:taskId/alarm
```
Request
```
```
Response
```
```

## Task - Alarm Put API
URL
```
PUT /api/task/:taskId/alarm
```
Request
```
```
Response
```
```
## Task - Alarm Delete API
URL
```
DELETE /api/task/:taskId/alarm
```
Response

## Task - Comment Get API
URL
```
GET /api/task/:taskId/comment
```
Response
```
{
    comments:
    [
        {
            id: 1,
            content: 'https://...'
        }
    ]
}
```
## Task - Comment Post API
URL
```
POST /api/task/:taskId/comment
```
Request
```
{
    content : '[내일 봐야할 것](https://www.naver.com) 공부하자!'
}
```
Response
```
{
    id: 1,
    message: 'ok'
}
```

## Task - Comment PUT API
URL
```
PUT /api/task/:taskId/comment/:commentId
```

Request
```
{
    'content': '코멘트 수정'
}
```
Response
```
{
    'message': 'ok'
}
```

## Task - Comment DELETE API
URL
```
DELETE /api/task/:taskId/comment/:commentId
```
Response
```
{
    'message': 'ok'
}
```

## Task - Bookmark Get API
URL
```
GET /api/task/:taskId/bookmark
```
Response
```
{
    bookmarks:
    {
        id: 1,
        url: 'https://....'
    }
}
```
## Task - Bookmark Post API
URL
```
POST /api/task/:taskId/bookmark
```
Request
```
{
    url : 'https://...'
}
```
Response
```
{
    id: 1,
    message: 'ok'
}
```

## Task - Bookmark PUT API
URL
```
PUT /api/task/:taskId/bookmark/:bookmarkId
```

Request
```
{
    url : 'https://another...'
}
```
Response
```
{
    'message': 'ok'
}
```

## Task - Bookmark DELETE API
URL
```
DELETE /api/task/:taskId/bookmark/:bookmarkId
```
Response
```
{
    'message': 'ok'
}
```


## Label

| Method | URL                                      | Description                       |
| ------ | ----------------------------------------- | ------------------------------- |
| GET    | api/label | label 전체 조회 |
| POST   | api/label | label 생성 | 
| PUT | api/label/:labelId | label 수정 |
| DELETE | api/label/:labelId | label 삭제 |

## Label Get API
URL
```
GET /api/label
```
Response
```
{
    labels:
    [
        {
            id: 1,
            title: '라벨 1',
            color: '#FFFFFF'
        }
    ]
}
```
## Label Post API
URL
```
POST /api/label
```
Request
```
{
    title : '라벨 1',
    color : '#FFFFFF',
}
```
Response
```
{
    id : 1,
    message : 'ok'
}
```
## Label Put API
URL
```
PUT /api/label/labelId
```
Request
```
{
    title : '라벨 1',
    color : '#FFFFFF',
}
```
Response
```
{
    id : 1,
    message : 'ok'
}
```
## Label Delete API
URL
```
DELETE /api/label/:labelId
```
Response
```
    {
        message:' ok'
    }
```

