Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-2_open_source_sw_development_Han
/
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-12-09 20:33:11 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d1a1038e8cf65f7cb102e6ddc37042ab35a5fa42
d1a1038e
1 parent
ae758d3b
add README.md in line and drop unecessary module and code
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
43 deletions
jaksimsamil-server/index.js
jaksimsamil-server/src/api/auth/index.js
jaksimsamil-server/src/api/auth/kakaoAuth.js
jaksimsamil-server/src/api/line/README.md
jaksimsamil-server/src/api/line/line.ctrl.js
jaksimsamil-server/src/api/profile/index.js
jaksimsamil-server/index.js
View file @
d1a1038
...
...
@@ -50,6 +50,7 @@ app.listen(SERVER_PORT, () => {
console
.
log
(
"Server is running on port"
,
process
.
env
.
SERVER_PORT
);
});
//for Line Channel
try
{
const
option
=
{
ca
:
fs
.
readFileSync
(
'/etc/letsencrypt/live/'
+
DOMAIN
+
'/fullchain.pem'
),
...
...
jaksimsamil-server/src/api/auth/index.js
View file @
d1a1038
const
Router
=
require
(
"koa-router"
);
const
auth
=
new
Router
();
const
authCtrl
=
require
(
"./auth.ctrl"
);
const
kakaoAuth
=
require
(
"./kakaoAuth"
);
auth
.
post
(
"/login"
,
authCtrl
.
login
);
auth
.
post
(
"/logout"
,
authCtrl
.
logout
);
auth
.
post
(
"/register"
,
authCtrl
.
register
);
auth
.
get
(
"/check"
,
authCtrl
.
check
);
auth
.
post
(
"/kakaotoken"
,
kakaoAuth
.
kakaotoken
);
module
.
exports
=
auth
;
...
...
jaksimsamil-server/src/api/auth/kakaoAuth.js
deleted
100644 → 0
View file @
ae758d3
const
request
=
require
(
'request'
);
const
querystring
=
require
(
'querystring'
);
exports
.
kakaotoken
=
async
(
ctx
)
=>
{
const
token
=
ctx
.
request
.
body
;
'http://kapi.kakao.com/v2/api/talk/memo/default/send'
console
.
log
(
ctx
);
console
.
log
(
"token setted"
,
token
);
let
template_objectObj
=
{
object_type
:
"text"
,
text
:
"hi"
,
link
:
{
web_url
:
"https://developers.kakao.com"
,
}
};
let
template_objectStr
=
JSON
.
stringify
(
template_objectObj
);
console
.
log
(
template_objectStr
);
let
options
=
{
url
:
"http://kapi.kakao.com/v2/api/talk/memo/default/send"
,
method
:
"POST"
,
headers
:
{
"Authorization"
:
"Bearer "
.
concat
(
token
),
"Content-Type"
:
"application/x-www-form-urlencoded"
},
form
:
{
template_object
:
template_objectStr
}
};
request
.
post
(
options
,
(
err
,
res
,
body
)
=>
{
if
(
err
!=
null
)
{
console
.
log
(
err
);
}
});
};
\ No newline at end of file
jaksimsamil-server/src/api/line/README.md
0 → 100644
View file @
d1a1038
File mode changed
jaksimsamil-server/src/api/line/line.ctrl.js
View file @
d1a1038
...
...
@@ -8,8 +8,17 @@ const Profile = require("../../models/profile");
const
problem_set
=
require
(
"../../data/problem_set"
);
const
compareBJ
=
require
(
"../../util/compareBJ"
);
/*
username : default = ""
*/
let
username
=
""
;
/*
POST api/line/hook
{
for line reply : recommend and set
}
*/
exports
.
linestart
=
async
(
ctx
)
=>
{
var
eventObj
=
ctx
.
request
.
body
.
events
[
0
];
...
...
@@ -20,6 +29,7 @@ exports.linestart = async(ctx) => {
console
.
log
(
'[request message]'
,
eventObj
.
message
);
console
.
log
(
'[username]'
,
username
);
//first . set User
if
(
username
==
""
)
{
username
=
eventObj
.
message
.
text
;
...
...
@@ -38,7 +48,7 @@ exports.linestart = async(ctx) => {
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"작심삼일
혹은 백준
사이트의 ID값이 올바르지 않습니다. 다시 입력해주세요."
"text"
:
"작심삼일 사이트의 ID값이 올바르지 않습니다. 다시 입력해주세요."
}
]
}
...
...
@@ -67,7 +77,7 @@ exports.linestart = async(ctx) => {
}
};
//second. can reset username
if
(
eventObj
.
message
.
text
==
"reset ID"
)
{
username
=
""
;
request
.
post
(
...
...
@@ -81,7 +91,7 @@ exports.linestart = async(ctx) => {
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"작심삼일
혹은 백준
사이트의 ID가 초기화 되었습니다."
"text"
:
"작심삼일 사이트의 ID가 초기화 되었습니다."
}
]
}
...
...
@@ -90,7 +100,7 @@ exports.linestart = async(ctx) => {
});
}
//main : recommend Problem
if
(
eventObj
.
message
.
text
==
"문제"
)
{
console
.
log
(
"문제를 추천합니다."
);
let
recommendData
=
await
lineRecommend
(
username
);
...
...
@@ -101,6 +111,7 @@ exports.linestart = async(ctx) => {
}
//for recommend message
function
recommendBJ
(
replyToken
,
recommendData
)
{
var
recommendProblem
=
"오늘의 추천문제는 "
+
recommendData
.
problem_title
+
"입니다."
;
var
problemURL
=
"https://www.boj.kr/"
+
recommendData
.
problem_number
;
...
...
jaksimsamil-server/src/api/profile/index.js
View file @
d1a1038
const
Router
=
require
(
"koa-router"
);
const
profile
=
new
Router
();
const
profileCtrl
=
require
(
"./profile.ctrl"
);
profile
.
post
(
"/solved:id"
);
profile
.
get
(
"/solvednum:id"
);
profile
.
post
(
"/recommend"
,
profileCtrl
.
recommend
);
profile
.
patch
(
"/syncBJ"
,
profileCtrl
.
syncBJ
);
profile
.
post
(
"/setprofile"
,
profileCtrl
.
setProfile
);
profile
.
post
(
"/getprofile"
,
profileCtrl
.
getProfile
);
module
.
exports
=
profile
;
...
...
Please
register
or
login
to post a comment