Toggle navigation
Toggle navigation
This project
Loading...
Sign in
송용우
/
oss-Jaksimsamil
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
송용우
2020-08-18 23:31:50 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bf311b6537f6c0cf754a47ed32f689108d69e9b8
bf311b65
1 parent
94eb5957
Update Challenge API
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
15 deletions
jaksimsamil-server/README.md
jaksimsamil-server/src/api/challenge/challege.ctrl.js
jaksimsamil-server/src/api/challenge/index.js
jaksimsamil-server/src/api/profile/profile.ctrl.js
jaksimsamil-server/README.md
View file @
bf311b6
...
...
@@ -26,17 +26,18 @@ POST http://facerain.dcom.club/profile/getprofile
## API Table
| group | description | method | URL | Detail | Auth |
| ------- | -------------------------------------- | ------ | ----------------------- | -------------------------------------- | --------- |
| profile | 유저가 푼 문제 조회(백준) | GET | api/profile/solvedBJ:id |
[
바로가기
](
/src/api/profile/README.md
)
| None |
| profile | 유저가 푼 문제 동기화(백준) | PATCH | api/profile/syncBJ |
[
바로가기
](
/src/api/profile/README.md
)
| None |
| profile | 유저 정보 수정 | POST | api/profile/setprofile |
[
바로가기
](
/src/api/profile/README.md
)
| JWT TOKEN |
| profile | 유저 정보 받아오기 | POST | api/profile/getprofile |
[
바로가기
](
/src/api/profile/README.md
)
| JWT |
| profile | 추천 문제 조회 | POST | api/profile/recommend |
[
바로가기
](
/src/api/profile/README.md
)
| None |
| profile | 친구 추가 | POST | /api/profile/addfriend |
[
바로가기
](
/src/api/profile/README.md
)
| JWT TOKEN |
| notify | 슬랙 메시지 전송 요청 (목표 성취 여부) | POST | api/notify/goal |
[
바로가기
](
/src/api/notify/README.md
)
| Jwt Token |
| notify | 슬랙 메시지 전송 요청 (문제 추천) | POST | api/notify/recommend |
[
바로가기
](
/src/api/notify/README.md
)
| None |
| auth | 로그인 | POST | api/auth/login |
[
바로가기
](
/src/api/auth/README.md
)
| None |
| auth | 로그아웃 | POST | api/auth/logout |
[
바로가기
](
/src/api/auth/README.md
)
| JWT Token |
| auth | 회원가입 | POST | api/auth/register |
[
바로가기
](
/src/api/auth/README.md
)
| None |
| auth | 로그인 확인 | GET | api/auth/check |
[
바로가기
](
/src/api/auth/README.md
)
| None |
| group | description | method | URL | Detail | Auth |
| --------- | -------------------------------------- | ------ | -------------------------- | -------------------------------------- | --------- |
| profile | 유저가 푼 문제 조회(백준) | GET | api/profile/solvedBJ:id |
[
바로가기
](
/src/api/profile/README.md
)
| None |
| profile | 유저가 푼 문제 동기화(백준) | PATCH | api/profile/syncBJ |
[
바로가기
](
/src/api/profile/README.md
)
| None |
| profile | 유저 정보 수정 | POST | api/profile/setprofile |
[
바로가기
](
/src/api/profile/README.md
)
| JWT TOKEN |
| profile | 유저 정보 받아오기 | POST | api/profile/getprofile |
[
바로가기
](
/src/api/profile/README.md
)
| JWT |
| profile | 추천 문제 조회 | POST | api/profile/recommend |
[
바로가기
](
/src/api/profile/README.md
)
| None |
| profile | 친구 추가 | POST | /api/profile/addfriend |
[
바로가기
](
/src/api/profile/README.md
)
| JWT TOKEN |
| notify | 슬랙 메시지 전송 요청 (목표 성취 여부) | POST | api/notify/goal |
[
바로가기
](
/src/api/notify/README.md
)
| Jwt Token |
| notify | 슬랙 메시지 전송 요청 (문제 추천) | POST | api/notify/recommend |
[
바로가기
](
/src/api/notify/README.md
)
| None |
| auth | 로그인 | POST | api/auth/login |
[
바로가기
](
/src/api/auth/README.md
)
| None |
| auth | 로그아웃 | POST | api/auth/logout |
[
바로가기
](
/src/api/auth/README.md
)
| JWT Token |
| auth | 회원가입 | POST | api/auth/register |
[
바로가기
](
/src/api/auth/README.md
)
| None |
| auth | 로그인 확인 | GET | api/auth/check |
[
바로가기
](
/src/api/auth/README.md
)
| None |
| challenge | 특정 챌린지 조회(이름) | POST | api/challenge/getChallenge |
[
바로가기
](
)
| None |
...
...
jaksimsamil-server/src/api/challenge/challege.ctrl.js
0 → 100644
View file @
bf311b6
const
Challenge
=
require
(
"../../models/challenge"
);
const
Joi
=
require
(
"joi"
);
/*POST /api/challenge/getChallenge
{
challengeName: "challengeName"
}
*/
exports
.
getChallenge
=
async
(
ctx
)
=>
{
try
{
const
{
challengeName
}
=
ctx
.
request
.
body
;
const
challenge
=
await
Challenge
.
findByChallengeName
(
challengeName
);
if
(
!
challenge
)
{
ctx
.
status
=
401
;
return
;
}
ctx
.
body
=
challenge
;
}
catch
(
e
)
{
ctx
.
throw
(
500
,
e
);
}
};
/*POST /api/challenge/addChallenge
{
challengeName: "challengeName",
startDate: Date Object,
endDate: Date Object,
durationPerSession: "2w", // '1d' means one day per session, '2w' means 2 weeks per session, '3m' means 3 months per session.
goalPerSession: 3,
groups: [{'name1', 'name2'}]
}
*/
exports
.
addChallenge
=
async
(
ctx
)
=>
{
const
schema
=
Joi
.
object
()
.
keys
({
challengeName
:
Joi
.
string
(),
startDate
:
Joi
.
date
(),
endDate
:
Joi
.
date
(),
durationPerSession
:
Joi
.
string
(),
goalPerSession
:
Joi
.
number
(),
groups
:
Joi
.
array
().
items
(
Joi
.
string
()),
})
.
unknown
();
const
result
=
Joi
.
validate
(
ctx
.
request
.
body
,
schema
);
if
(
result
.
error
)
{
ctx
.
status
=
400
;
ctx
.
body
=
result
.
error
;
return
;
}
const
{
challengeName
,
startDate
,
endDate
,
durationPerSession
,
goalPerSession
,
}
=
ctx
.
request
.
body
;
try
{
const
isChallengeExist
=
await
Challenge
.
findByChallengeName
(
challengeName
);
if
(
isChallengeExist
)
{
ctx
.
status
=
409
;
return
;
}
const
challenge
=
new
Challenge
({
challengeName
,
startDate
,
endDate
,
durationPerSession
,
goalPerSession
,
});
await
challenge
.
save
();
ctx
.
body
=
challenge
();
}
catch
(
e
)
{
ctx
.
throw
(
500
,
e
);
}
/*
TODO: How to handle group?
*/
};
jaksimsamil-server/src/api/challenge/index.js
0 → 100644
View file @
bf311b6
File mode changed
jaksimsamil-server/src/api/profile/profile.ctrl.js
View file @
bf311b6
...
...
@@ -50,7 +50,6 @@ exports.setProfile = async (ctx) => {
//freindList: Joi.array().items(Joi.string()),
})
.
unknown
();
console
.
log
(
ctx
.
request
.
body
);
const
result
=
Joi
.
validate
(
ctx
.
request
.
body
,
schema
);
if
(
result
.
error
)
{
ctx
.
status
=
400
;
...
...
Please
register
or
login
to post a comment