> For the complete documentation index, see [llms.txt](https://bsjp9400.gitbook.io/teamproject/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bsjp9400.gitbook.io/teamproject/master.md).

# REST API\_Lonelyonemeal

## Login

<mark style="color:green;">`POST`</mark> `https://onemeal.site/users/login`

Client 로그인 요청.

#### Request Body

| Name     | Type   | Description         |
| -------- | ------ | ------------------- |
| email    | string | User email value    |
| password | string | User password value |

{% tabs %}
{% tab title="200 Login Success" %}

```
{ "message" "Login successfully" }
```

{% endtab %}

{% tab title="400 " %}

```
{ message: "hashPwd exists" }
```

{% endtab %}

{% tab title="401 User Not Found" %}

```
{ "message": "Not authorized" }
```

{% endtab %}
{% endtabs %}

## Logout

<mark style="color:green;">`POST`</mark> `https://onemeal.site/users/logout`

Client 로그아웃 요청.

#### Headers

| Name            | Type   | Description      |
| --------------- | ------ | ---------------- |
| Content-Type    | string | application/json |
| withCredentials | string | true             |

{% tabs %}
{% tab title="205 Logout Success." %}

```
{ "message": "Logout successfully" }
```

{% endtab %}
{% endtabs %}

## SignUp

<mark style="color:green;">`POST`</mark> `https://onemeal.site/users/signup`

Client 유저 회원 가입 요청.

#### Request Body

| Name     | Type   | Description         |
| -------- | ------ | ------------------- |
| username | string | User username value |
| email    | string | User email value    |
| password | string | User password value |

{% tabs %}
{% tab title="201 SignUp Success." %}

```
{ "message": "Sign successfully" }
```

{% endtab %}

{% tab title="409 Duplicate email" %}

```
{ "message": "email exists" }
```

{% endtab %}

{% tab title="422 Insufficient parameters" %}

```
{ "message": "insufficient parameters supplied" }
```

{% endtab %}
{% endtabs %}

## UserInfo

<mark style="color:blue;">`GET`</mark> `https://onemeal.site/users/userinfo`

Client 로그인 후 생성  Session.userId로 유저 정보 요청.

#### Headers

| Name            | Type   | Description |
| --------------- | ------ | ----------- |
| withCredentials | string | true        |

{% tabs %}
{% tab title="200 Vaild AccessToken" %}

```
{ 
   "data": { 
            id: "1", 
            userImg: "34058023858.jpg",
            email: "test@test.com",
            username: "홍길"
           },
   "log": [
            {
              id: "4"
              foodName: "스팸마요덮밥",
              foodImg: "https://i.imgur.com/U89ed7j.jpg",
              link: "https://www.youtube.com/watch?v=TkElH6dFhW8",
              createdAt: "2020-12-30 12:50:26",
              updatedAt: "2020-12-30 12:50:26"
            },
            {
              id: "7"
              foodName: "고추장불고기",
              foodImg: "https://i.imgur.com/oVmADMs.jpg",
              link: "https://www.youtube.com/watch?v=bQDQXAQxO6A",
              createdAt: "2020-12-30 12:50:26",
              updatedAt: "2020-12-30 12:50:26"
            },
          ]    
}
```

{% endtab %}

{% tab title="400 Invaild AccessToken" %}

```
{ "message": "AccessToken not authorized" }
```

{% endtab %}
{% endtabs %}

## UserInfoUp

<mark style="color:orange;">`PUT`</mark> `https://onemeal.site/users/userinfoup`

Client username, Password 변경 후 응답.

#### Headers

| Name           | Type   | Description |
| -------------- | ------ | ----------- |
| session.userId | string |             |

#### Request Body

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| username | string |             |
| password | string |             |

{% tabs %}
{% tab title="302 " %}

```
{ "data": "홍길" }
```

{% endtab %}

{% tab title="404 " %}

```
{ "message": "user not found" }
```

{% endtab %}
{% endtabs %}

## UserImgUp

<mark style="color:orange;">`PUT`</mark> `https://onemeal.site/users/userImgUp`

Client 유저 Img 업데이트 후 응답.

#### Path Parameters

| Name    | Type   | Description |
| ------- | ------ | ----------- |
| userImg | string |             |

{% tabs %}
{% tab title="200 " %}

```
{ data : { 
            id: "1", 
            userImg: "34058023858.jpg",
            email: "test@test.com",
            username: "홍길"
           }
}
```

{% endtab %}

{% tab title="401 " %}

```
{ message : 'Unauthorized' }
```

{% endtab %}
{% endtabs %}

## GithubAuthorize

<mark style="color:blue;">`GET`</mark> `https://github.com/login/oauth/authorize?client_id=`

Client의 state에 "<https://github.com/login/oauth/authorize?client\\_id=>" 로 사용자 인증하면 설정해논 EndPoint로 리다이렉션 되면서 Athorization code를 받아오게 됩니다.&#x20;

#### Path Parameters

| Name       | Type   | Description                         |
| ---------- | ------ | ----------------------------------- |
| client\_id | string | Developer settings Github Client ID |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

## GithubLogin

<mark style="color:green;">`POST`</mark> `/socials/githublogin`

Client Oauth인증이 완료된 후 얻은 authorization code(url.searchParams.get('code'))를 Server에 전달 후 AccessToken을 받기위한 Endpoint

#### Request Body

| Name              | Type   | Description       |
| ----------------- | ------ | ----------------- |
| authorizationCode | string | authorizationCode |

{% tabs %}
{% tab title="200 " %}

```
{ accessToken: github.data.access_token }
```

{% endtab %}
{% endtabs %}

## GithubUserInfo

<mark style="color:blue;">`GET`</mark> `https://api.github.com/user`

&#x20;Server로 부터 받은 AccessToken으로 Github 유저 정보 요청.

#### Headers

| Name          | Type   | Description                         |
| ------------- | ------ | ----------------------------------- |
| authorization | string | \`token ${this.props.accessToken}\` |

{% tabs %}
{% tab title="200 " %}

```
{ result: result.data }
```

{% endtab %}
{% endtabs %}

## GoogleAuthorize

<mark style="color:blue;">`GET`</mark> `https://accounts.google.com/o/oauth2/v2/auth/client_id?=`

Client의 state에 "<https://accounts.google.com/o/oauth2/v2/auth?client\\_id="로> 사용자 인증을 하면 설정해놓은 EndPoint로 리다이렉션 되면서 Athorization code를 받아오게 됩니다.

#### Path Parameters

| Name       | Type   | Description                    |
| ---------- | ------ | ------------------------------ |
| client\_id | string | Google API Developer Client ID |

{% tabs %}
{% tab title="200 " %}

```
https://oauth2.example.com/auth?code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7
```

{% endtab %}
{% endtabs %}

## GoogleLogin

<mark style="color:green;">`POST`</mark> `/socials/googleLogin`

Client Ouath인증 완료 후 얻은 authorization code(url.serchParams.get('code'))를 Server에 전달 후 AccessToken을 받기

#### Path Parameters

| Name              | Type   | Description       |
| ----------------- | ------ | ----------------- |
| authorizationCode | string | authorizationCode |

{% tabs %}
{% tab title="200 " %}

```
{ accessToken: google.data.access_token }
```

{% endtab %}
{% endtabs %}

## GoogleUserInfo

<mark style="color:blue;">`GET`</mark> `https://www.googleapis.com/drive/v2/files`

Server로 부터 받은 AccessToken으로 Google에 유저 정보 요청

#### Headers

| Name          | Type   | Description                        |
| ------------- | ------ | ---------------------------------- |
| Authorization | string | \`Bearer ${this.props.accessToken} |

{% tabs %}
{% tab title="200 " %}

```
{ result: result.data }
```

{% endtab %}
{% endtabs %}

## ResultRecipe

<mark style="color:blue;">`GET`</mark> `https://onemeal.site/users/resultrecipe`

Client 메인 페이지에서 유저가 선택한 재료에 따라 레시피 결과 응답.

#### Request Body

| Name          | Type   | Description                     |
| ------------- | ------ | ------------------------------- |
| FoodParameter | string | Main page Select Food Parameter |

{% tabs %}
{% tab title="200 " %}

```
{
    "data": [
             {
               "id": 11,
               "foodimg": "https://i.imgur.com/tgpIWMa.jpg",
               "foodname": "김치전",
               "link": "https://www.youtube.com/watch?v=V2TBTOf5hBM&list=PL88CEP-8JWFDCQ0pyvepo0JexIGlyTNEf&index=58",
               "createdAt": "2020-12-30 12:50:26",
               "updatedAt": "2020-12-30 12:50:26"
             }
             ]
}
```

{% endtab %}
{% endtabs %}

## SaveRecipe

<mark style="color:green;">`POST`</mark> `https://onemeal.site/users/saverecipe`

Client 메인 페이지에서 유저가 마이페이지에 레시피를 저장하는 버튼 클릭시.

#### Request Body

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| id       | string |             |
| foodImg  | string |             |
| foodName | string |             |
| link     | string |             |

{% tabs %}
{% tab title="201 " %}

```
{ message: "Save successfully" }
```

{% endtab %}

{% tab title="422 " %}

```
{ message: "insufficient parameters supplied" }
```

{% endtab %}
{% endtabs %}

## DeleteRecipe

<mark style="color:green;">`POST`</mark> `https://onemeal.site/users/deleterecipe`

#### Headers

| Name               | Type   | Description |
| ------------------ | ------ | ----------- |
| req.session.userId | string |             |

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
| id   | string |             |

{% tabs %}
{% tab title="201 " %}

```
{ message: "Completed recipeLog delete" }
```

{% endtab %}
{% endtabs %}
