플래시카드 서비스의 백엔드 레포지토리입니다.
폴리 레포 프로젝트이고 프론트엔드 레포지토리는 따로 구성했습니다.
- runtime: Deno
- Deploy: Deno Deploy
- Database: mongoDB Atlas
아래는 API 주소입니다.
https://flash-card-backend.deno.dev/
참고. deno deploy는 무료 플랜을 활용 중입니다. 유료전환하면 위 url은 삭제할 것입니다. 클라이언트는 url은 환경변수로 접근하기 바랍니다.
요청
- URL:
api/auth/signup
- Method:
POST
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
- email:
string
- password:
string
- email:
{
"email": "username@email.com",
"password": "12345678"
}
응답 예시
- Status:
201
- Body: (없음)
// body 없음
요청
- URL:
api/auth/signin
- Method:
POST
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
- email:
string
- password:
string
- email:
{
"email": "username@email.com",
"password": "12345678"
}
응답 예시
- Status:
201
- Body:
- success:
boolean
- access_token:
access_token
- refresh_token:
access_token
- success:
{
"success": true,
"access_token": "asdf1234",
"refresh_token": "qwer6789"
}
auth와 관련이 없은 요청을 보낼 때는 위 토큰을 header에 Authorization: Bearer (access_token)
형식으로 설정하고 요청을 보내주세요.
요청
- URL:
/api/auth/refresh
- Method:
POST
- Headers:
- Content-Type:
application/json
- Authorization:
Bearer (refresh_token)
- Content-Type:
- Body: (없음)
// 없음
응답 예시
- Status:
200
- Body:
- success:
boolean
- access_token:
access_token
- success:
{
"success": true,
"access_token": "zxcv9876"
}
요청
- URL:
/api/auth/delete
- Method:
DELETE
- Headers:
- Content-Type:
application/json
- Authorization:
Bearer (access_token)
- Content-Type:
- Body: (없음)
// 없음
응답 예시
- Status:
204
- Body: (없음)
// body 없음
요청
- URL:
/api/auth/check-email
- Method:
POST
- Headers:
- Content-Type:
application/json
- Content-Type:
- Body:
- email:
string
- email:
{
"email": "username@email.com"
}
응답 예시
- Status:
204
- Body: (없음)
// body 없음
- Status:
409
- Body:
- success:
boolean
- msg:
string
- success:
{
"success": false,
"msg": "Error: email Conflict"
}
Card Record
{
"_id": "1234asdf",
"question": "CPU의 본딧말",
"answer": "Central Processing Unit",
"submitDate": "Wed May 17 2023 21:11:26 GMT+0900 (한국 표준시)",
"stackCount": "0",
"userId": "1"
}
요청
- URL:
api/card
- Method:
POST
- Headers:
- Content-Type:
application/json
- Authorization:
Bearer (access_token)
- Content-Type:
- Body:
- question:
string
- answer:
string
- submitDate:
Date
- stackCount:
number
- question:
{
"question": "CPU의 본딧말",
"answer": "Central Processing Unit",
"submitDate": "Wed May 17 2023 21:11:26 GMT+0900 (한국 표준시)",
"stackCount": "0"
}
응답 예시
- Status:
201
- Body:
- insertedId:
string
- insertedId:
{
"insertedId": "1234asdf"
}
요청
- URL:
api/card
- Method:
GET
- Headers:
- Content-Type:
application/json
- Authorization:
Bearer (access_token)
- Content-Type:
- Body: (없음)
// body 없음
응답 예시
- Status:
200
- Body:
- documents:
- question:
string
- answer:
string
- submitDate:
Date
- stackCount:
number
- question:
- documents:
{
"documents": [
{
"_id": "1234asdf",
"question": "도큐사우르스 짱짱맨",
"answer": "킹정",
"submitDate": "Wed May 17 2023 21:11:26 GMT+0900 (한국 표준시)",
"stackCount": "0",
"userId": "1234asdf"
},
{
"_id": "1234asdf",
"question": "블로그를 더 간지나게 만드는 방법",
"answer": "github pages로 DIY로 만든다.",
"submitDate": "Wed May 17 2023 21:11:26 GMT+0900 (한국 표준시)",
"stackCount": "0",
"userId": "1234asdf"
}
]
}
요청
- URL:
api/card/:id
- Method:
PATCH
- Headers:
- Content-Type:
application/json
- Authorization:
Bearer (access_token)
- Content-Type:
- Body:
- question:
string
- answer:
string
- submitDate:
Date
- stackCount:
number
- question:
{
"question": "CPU의 본딧말",
"answer": "Central Processing Unit",
"submitDate": "Wed May 19 2023 21:11:26 GMT+0900 (한국 표준시)",
"stackCount": "1"
}
응답 예시
- Status:
200
- Body:
- matchedCount:
number
- modifiedCount:
number
- matchedCount:
{
"matchedCount": 1,
"modifiedCount": 1
}
요청
- URL:
api/card/:id
- Method:
DELETE
- Headers:
- Content-Type:
application/json
- Authorization:
Bearer (access_token)
- Content-Type:
- Body: (없음)
// body 없음
응답 예시
- Status:
204
- Body: (없음)
// body 없음
deno run main.ts
deno task dev
deno test --allow-read
deno bench