Skip to content

API ๋ช…์„ธ

June1010 edited this page Dec 8, 2022 · 22 revisions

API ๋ช…์„ธ

  • json: ์นด๋ฉœ์ผ€์ด์Šค ์‚ฌ์šฉ

๋กœ๊ทธ์ธ API

POST /auth/login

req

  • ๋กœ๊ทธ์ธ ์š”์ฒญ
{
    "userId": "myid",
    "password": "p@ssw0rd"
}

res

  • ๋กœ๊ทธ์ธ ์„ฑ๊ณต
{
    "statusCode": 200,
    "data": {
        "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
        "userId": "abcd1234",
    }
}
  • ๋กœ๊ทธ์ธ ์‹คํŒจ
{
    "statusCode": 401,
    "error": "Unauthorized",
    "message": "๋กœ๊ทธ์ธ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค"
}

๋กœ๊ทธ์•„์›ƒ API

GET /auth/logout

req


res

  • ๋กœ๊ทธ์•„์›ƒ ์„ฑ๊ณต
{
    "status": 200
}
  • ๋กœ๊ทธ์•„์›ƒ ์‹คํŒจ
{
    "status": 404
}

ํšŒ์›๊ฐ€์ž… API

POST /user

req

  • ํšŒ์›๊ฐ€์ž… ์š”์ฒญ
{
    "userId": "userId",
    "password": "randowPW",
    "pace": 390,
    "hCode": "11000000",
    "email": "[email protected]",
    "receiveMail": true,
}

res

  • ํšŒ์›๊ฐ€์ž… ์„ฑ๊ณต์‹œ
{
    "statusCode": 201
}
  • ํšŒ์›๊ฐ€์ž… ์‹คํŒจ์‹œ
{
    "statusCode": 400,
    "error": "Bad Request",
    "message": "ํšŒ์›๊ฐ€์ž…์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค"
}

ID ์ค‘๋ณต ๊ฒ€์‚ฌ API

GET /user/:id

req


res

  • ์ค‘๋ณต ๊ฒ€์‚ฌ ์‘๋‹ต
{
    "statusCode": 200,
    "data": {
        "isExisting": true/false,
    }
}

ํ† ํฐ ๊ฐฑ์‹  API

GET /auth/refresh

req

  • ๊ฐฑ์‹  ์š”์ฒญ์‹œ
    • HEADER
      • Authorization: Bearer

res

  • ๊ฐฑ์‹  ์„ฑ๊ณต์‹œ
{
    "statusCode": 201,
    "data": {
        "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
        "userId": "abcd1234",
    }
}
  • ๊ฐฑ์‹  ์‹คํŒจ์‹œ
{
    "statusCode": 401,
    "error": "Unauthorized",
    "message": "Invalid refresh token"
}

๋ชจ์ง‘ ๋ชฉ๋ก ์กฐํšŒ/๊ฒ€์ƒ‰/ํ•„ํ„ฐ API

req

GET /recruit?query=์ œ๋ชฉ์ž…๋‹ˆ๋‹ค&hour=3&dist=5&maxLen=3000&minLen=1000&page=1&pageSize=10&title=true&author=true

res

{
    "statusCode": 200,
    "data": [
        {
            "id": 1,
            "title": "Happy Tears",
            "startTime": "2022-01-08T18:28:50.000Z",
            "maxPpl": 4,
            "currentPpl": 3,
            "userId": "June1010",
            "pace": 300,
            "createdAt": "2022-11-21T08:55:33.171Z",
            "course": {
                "id": 3,
                "title": "The Vengeance of Fu Manchu",
                "path": [{lat: 0, lng: 0}, {lat: 1, lng: 1}],
                "pathLength": 708,
                "userId": "June1010",
                "hDong": {
                    "name": "์ž ์‹ค๋™",
                },
                "createdAt": "2022-11-21T08:55:33.171Z",
            }
        }, ...
    ]
}

// ๋ชจ์ง‘๊ธ€์˜ ์ฝ”์Šค ์ •๋ณด์˜ ์ง€์—ญ์œผ๋กœ ๋ชจ์ง‘๊ธ€ ์ง€์—ญ์„ ๋Œ€์ฒดํ•˜๋Š” ๋Š๋‚Œ // ๋ชจ์ง‘๊ธ€ ์ „์ฒด ๋ชฉ๋ก ํ•„๋“œ์— ์š”์ฒญํ•œ ์œ ์ €์˜ ID๊ฐ€ ์ฐธ์—ฌ์ค‘์ธ ๋ชจ์ง‘๊ธ€์ด๋ฉด "isParticipating" ์ถ”๊ฐ€ ๊ณ ๋ คํ•ด๋ณด๊ธฐ

์ฝ”์Šค ๋ชฉ๋ก ์กฐํšŒ/๊ฒ€์ƒ‰/ํ•„ํ„ฐ API

req

`GET /course?query=์ œ๋ชฉ์ž…๋‹ˆ๋‹ค&dist=5&maxLen=3000&minLen=1000&page=1&pageSize=10&title=true&author=true`

res

{
    "statusCode": 200,
    "data": [
        {
            "id": 3,
            "title": "The Vengeance of Fu Manchu",
            "path": [{"lat": 0, "lng": 0}, {"lat": 1, "lng": 1}],
            "pathLength": 708,
            "userId": "June1010",
            "hDong": {
                "name": "์ž ์‹ค๋™",
            },
            "createdAt": "2022-11-21T08:55:33.171Z"
        }, ...
    ]
}

๋ชจ์ง‘ ์ƒ์„ธ ํŽ˜์ด์ง€ API

GET /recruit/:id

req


res

{
    "statusCode": 200,
    "data": {
        "title": "๋‹ฌ๋ ค~๋‹ฌ๋ ค~",
        "startTime": "2022-11-21T08:55:33.171Z",
        "maxPpl": 5,
        "currentPpl": 3,
        "path": [{lat:123, lng: 123}, ... ],
        "pathLength": 33,
        "pace": 20,
        "hDong": {
            "name": "์ž ์‹ค๋™"
        },
        "userId": "pushedrumex",
        "isParticipating": true/false,
        "isAuthor": true/false,
    }
}

์ฝ”์Šค ์ƒ์„ธ ํŽ˜์ด์ง€ API

GET /course/:id

req


res

{
    "statusCode": 200,
    "data": {
        "id": 3,
        "title": "The Vengeance of Fu Manchu",
        "path": [{"lat": 0, "lng": 0}, {"lat": 1, "lng": 1}],
        "pathLength": 708,
        "userId": "June1010",
        "hDong": {
            "name": "์ž ์‹ค๋™",
        },
        "createdAt": "2022-11-21T08:55:33.171Z"
    }
}

๋ชจ์ง‘ ์ฐธ์—ฌ API (์ฐธ์—ฌ ๋ฒ„ํŠผ ๋ˆ„๋ฅด๋ฉด API)

POST /recruit/join HEADER : Authorization: Bearer

req

{
    "recruitId": 1,
}                

res

  • ์ฐธ๊ฐ€ ์š”์ฒญ ์„ฑ๊ณต์‹œ
{
    "statusCode": 201,
}
  • ์ฐธ๊ฐ€ ์š”์ฒญ ์‹คํŒจ์‹œ (์ฐธ๊ฐ€์‹ ์ฒญ์ธ์› ๊ฝ‰์ฐฌ๊ฒฝ์šฐ & ๊ธ€์ด ๊ฐ‘์ž๊ธฐ ์‚ญ์ œ๋œ ๊ฒฝ์šฐ)
{
    "status": 404(์กด์žฌํ•˜์ง€ ์•Š๋Š” ๊ธ€์— ์‹ ์ฒญ) / 423(๋‚ด๊ฐ€ ๋‚ด๊บผ ์‹ ์ฒญ, ์ด๋ฏธ ์‹ ์ฒญ, ๋งˆ๊ฐ),
    "error": "Not Found" / "Locked",
    "message": "์กด์žฌํ•˜์ง€ ์•Š๋Š” ๋ชจ์ง‘๊ธ€์ž…๋‹ˆ๋‹ค" / "์ž์‹ ์˜ ๋ชจ์ง‘์— ๋“ฑ๋กํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค" / "๋ชจ์ง‘ ์ƒํ•œ์— ๋„๋‹ฌํ–ˆ์Šต๋‹ˆ๋‹ค" / "์ด๋ฏธ ์ฐธ์—ฌ์ค‘์ธ ๋ชจ์ง‘๊ธ€์ž…๋‹ˆ๋‹ค"
    }
}

๋ชจ์ง‘ ๋“ฑ๋ก API

POST /recruit HEADER : Authorization: Bearer

req

{
    "title": "์ œ๋ชฉ์ž…๋‹ˆ๋‹ค",
    "startTime": "2022-11-15T09:00",
    "maxPpl": 3,
    "pace": 365,
    "courseId": 40,
}

res

  • ๋ชจ์ง‘ ๋“ฑ๋ก ์„ฑ๊ณต์‹œ
{
    "statusCode": 201,
    "data": {
        "recruitId": 210
    }
}
  • ๋ชจ์ง‘ ๋“ฑ๋ก ์‹คํŒจ์‹œ
// interceptor๋กœ ๊ฐ€๋กœ์ฑ„์„œ ๋ณ€ํ™˜
{
    "statusCode": 500,
    "error": "Internal server error"
    "message": "์š”์ฒญ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”"
}

์ฝ”์Šค ๋“ฑ๋ก API

POST /course HEADER : content-type application/json, Authorization: Bearer

req

{
    "title": "์ œ๋ชฉ",
    "path": [{lat: 33, lng: 126},{lat: 33, lng: 126},{lat: 33, lng: 126},{lat: 33, lng: 126}],
    "pathLength": 3800,
    "hCode": "1100000000"
}

res

  • ์ฝ”์Šค ๋“ฑ๋ก ์š”์ฒญ ์„ฑ๊ณต์‹œ
{
    "statusCode": 201,
    "data": {
        "courseId": 234
    }
}
  • ์ฝ”์Šค ๋“ฑ๋ก ์š”์ฒญ ์‹คํŒจ์‹œ
// interceptor๋กœ ๊ฐ€๋กœ์ฑ„์„œ ๋ณ€ํ™˜
{
    "statusCode": 500,
    "error": "Internal server error"
    "message": "์š”์ฒญ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”"
}

๋‚ด ์ •๋ณด ์กฐํšŒ API

GET /user/me
Header : Authorization: Bearer

req


res

  • ๋‚ด ์ •๋ณด ์กฐํšŒ ์š”์ฒญ ์„ฑ๊ณต์‹œ
{
    "statusCode": 200,
    "data": {
        "userId": "June1010"
        "hDong": {
            "name": "์„œ์šธํŠน๋ณ„์‹œ",
        },
        "pace": 380,
    }
}
  • ๋‚ด ์ •๋ณด ์กฐํšŒ ์š”์ฒญ ์‹คํŒจ์‹œ
// interceptor๋กœ ๊ฐ€๋กœ์ฑ„์„œ ๋ณ€ํ™˜ // 401์€ ๋ฌด์กฐ๊ฑด ๋กœ๊ทธ์ธ ํŽ˜์ด์ง€๋กœ ๋ณ€ํ™˜
{
    "statusCode": 401,
    "error": "Unauthorized"
    "message": "๋กœ๊ทธ์ธ์ด ํ•„์š”ํ•œ ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค"
}

๋‚ด ์ •๋ณด ์ˆ˜์ • API

PATCH /user/me Header : Authorization: Bearer

req

{
    "pace"?: 365,
    "hCode"?: "1100000000"
}

res

  • ๋‚ด ์ •๋ณด ์ˆ˜์ • ์š”์ฒญ ์„ฑ๊ณต์‹œ
{
    "statusCode": 201
}
  • ๋‚ด ์ •๋ณด ์ˆ˜์ • ์š”์ฒญ ์‹คํŒจ์‹œ
{
    "status": 401,
    "error": "UnAuthorized",
    "message": "๋กœ๊ทธ์ธ์ด ํ•„์š”ํ•œ ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค" 
}

๋‚ด ์ฐธ์—ฌ ๋ชฉ๋ก API

GET /user/me/recruit Header : Authorization: Bearer

req


res

  • ๋‚ด ์ฐธ์—ฌ ๋ชจ์ง‘๋ชฉ๋ก ์š”์ฒญ ์„ฑ๊ณต์‹œ
{
    "statusCode": 200,
    "data": [
        {
            "id": 1,
            "title": "Happy Tears",
            "startTime": "2022-01-08T18:28:50.000Z",
            "maxPpl": 4,
            "currentPpl": 3,
            "userId": "๋ชจ์ง‘๊ธ€์ž‘์„ฑ์ž",
            "pace": 300,
            "createdAt": "2022-11-21T08:55:33.171Z",
            "course": {
                "id": 3,
                "title": "The Vengeance of Fu Manchu",
                "path": [{lat: 0, lng: 0}, {lat: 1, lng: 1}],
                "pathLength": 708,
                "userId": "์ฝ”์Šค์ž‘์„ฑ์ž",
                "hDong": {
                    "name": "์ž ์‹ค๋™",
                },
                "createdAt": "2022-11-21T08:55:33.171Z",
            }
        }, ...
    ]
}
  • ๋‚ด ์ฐธ์—ฌ ๋ชจ์ง‘๋ชฉ๋ก ์š”์ฒญ ์‹คํŒจ์‹œ
{
    "status": 401,
    "error": "UnAuthorized",
    "message": "๋กœ๊ทธ์ธ์ด ํ•„์š”ํ•œ ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค" 
}

๋‚ด ์ฝ”์Šค ๋ชฉ๋ก API

GET /user/me/course Header : Authorization: Bearer

req


res

  • ๋‚ด ์ฝ”์Šค ๋ชฉ๋ก ์š”์ฒญ ์„ฑ๊ณต์‹œ
{
    "statusCode": 200,
    "data": [
        {
            "id": 3,
            "title": "The Vengeance of Fu Manchu",
            "path": [{lat: 0, lng: 0}, {lat: 1, lng: 1}],
            "pathLength": 708,
            "userId": "์ฝ”์Šค ์ž‘์„ฑ์ž",
            "hDong": {
                "name": "์ž ์‹ค๋™",
            },
            "createdAt": "2022-11-21T08:55:33.171Z"
        }, ...
    ]
}
  • ๋‚ด ์ฝ”์Šค ๋ชฉ๋ก ์š”์ฒญ ์‹คํŒจ์‹œ
{
    "status": 401,
    "error": "UnAuthorized",
    "message": "๋กœ๊ทธ์ธ์ด ํ•„์š”ํ•œ ์„œ๋น„์Šค์ž…๋‹ˆ๋‹ค" 
}

๋ชจ์ง‘ ์ทจ์†Œ API

DELETE /recuit/:id HEADER : content-type application/json, Authorization: Bearer

req


res

  • ๋ชจ์ง‘ ์ทจ์†Œ ์š”์ฒญ ์„ฑ๊ณต ์‹œ
{
    "statusCode": 200,
}
  • ๋ชจ์ง‘ ์ทจ์†Œ ์š”์ฒญ ์‹คํŒจ ์‹œ
{
    "statusCode": 500,
    "error": "Internal server error"
    "message": "์š”์ฒญ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”"
}

์ฐธ์—ฌ ์ทจ์†Œ API

DELETE /recuit/:id/join HEADER : content-type application/json, Authorization: Bearer

req


res

  • ์ฐธ์—ฌ ์ทจ์†Œ ์š”์ฒญ ์„ฑ๊ณต ์‹œ
{
    "statusCode": 200,
}
  • ์ฐธ์—ฌ ์ทจ์†Œ ์š”์ฒญ ์‹คํŒจ ์‹œ
{
    "statusCode": 500,
    "error": "Internal server error",
    "message": "์š”์ฒญ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๋‹ค์‹œ ์‹œ๋„ํ•ด์ฃผ์„ธ์š”"
}

๐Ÿ  Home

๐ŸŽจ Proposal

๐Ÿ‘จโ€๐Ÿ’ป Manual

๐Ÿง‘โ€โš–๏ธ Rules

๐Ÿงญ Plan

โ˜€๏ธ Meet up

Daily Scrum
Weekly Review
Weekly Plan

๐ŸŽฅ Presentation

โš™๏ธ Sharing Skills

๐Ÿ“‘ Document

๐Ÿ“‘ FrontEnd - Trial and Errors

๐Ÿ“‘ Backend - Trial and Errors

๐Ÿ“‘ DevOps - Trial and Errors

๐Ÿง‘โ€๐Ÿซ Mentoring

Clone this wiki locally