Toggle navigation
Toggle navigation
This project
Loading...
Sign in
고혜연
/
DessertChatbot
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
고혜연
2021-06-10 11:32:24 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
db71506b3dc8f627b01cba2a1f934e5c5ec6b929
db71506b
1 parent
2ac927a7
Add reply webhook by line message
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
17 deletions
https/app.js
https/constants.js
https/index.js
https/app.js
View file @
db71506
...
...
@@ -40,7 +40,7 @@ app.post('/webhook', (req, res) => {
console
.
log
(
'[request source] '
,
source
);
console
.
log
(
'[request message]'
,
message
);
const
url
=
'https://
notify-api.line.me/api/notif
y'
const
url
=
'https://
api.line.me/v2/bot/message/repl
y'
axios
.
post
(
url
,
{
replyToken
,
messages
:
[
...
...
@@ -54,7 +54,10 @@ app.post('/webhook', (req, res) => {
},
],
},
{
headers
:
`Bearer
${
constants
.
LINE
.
TOKEN
}
`
,
headers
:
{
authorization
:
`Bearer
${
constants
.
LINE
.
TOKEN
}
`
,
'Content-Type'
:
'application/json'
,
},
}).
then
(
notifyResponse
=>
{
res
.
status
(
200
);
res
.
send
(
'Success'
);
...
...
https/constants.js
View file @
db71506
...
...
@@ -8,14 +8,14 @@ module.exports = {
URL
:
{
NOTIFY
:
'https://notify-api.line.me/api/notify'
,
},
TOKEN
:
'Cu3yosmWtXOPBhjccMCdJj2YH1g5KF8rhBv0zHZyqj3uYOrHSPYkixI+6SP7bfZOdC8J4xwhOriJahHtLxsQxUMnTaanncGyAyTFyD9+18gvzEcS39plUIadREyL38HoY/9o6O3a3guSOMxyiT+cJ
QdB04t89/1O/w1cDnyilFU='
,
CHANNEL_TOKEN
:
'RzDICmPPV/TJBYTazkASkptggoT58lCt+IS9ayXvYXZP2INsAkeiQfVNV2/5OULHzxXEzXQQRIwsyZ1uXVXROuM4GYLfPNOGqCFbt2pzgbWbp29X4b0ohfZAsA80PsP8CEfiSAiue9lOrxNm3AXS5
QdB04t89/1O/w1cDnyilFU='
,
},
CONFIG
:
{
PORT
:
443
,
HTTPS_OPTIONS
:
{
//
ca: fs.readFileSync(`/etc/letsencrypt/live/${domain}/fullchain.pem`),
//
key: fs.readFileSync(path.resolve(process.cwd(), `/etc/letsencrypt/live/${domain}/privkey.pem`), 'utf8').toString(),
//
cert: fs.readFileSync(path.resolve(process.cwd(), `/etc/letsencrypt/live/${domain}/cert.pem`), 'utf8').toString(),
ca
:
fs
.
readFileSync
(
`/etc/letsencrypt/live/
${
domain
}
/fullchain.pem`
),
key
:
fs
.
readFileSync
(
path
.
resolve
(
process
.
cwd
(),
`/etc/letsencrypt/live/
${
domain
}
/privkey.pem`
),
'utf8'
).
toString
(),
cert
:
fs
.
readFileSync
(
path
.
resolve
(
process
.
cwd
(),
`/etc/letsencrypt/live/
${
domain
}
/cert.pem`
),
'utf8'
).
toString
(),
}
}
};
\ No newline at end of file
...
...
https/index.js
View file @
db71506
...
...
@@ -3,14 +3,12 @@ const https = require('https');
const
app
=
require
(
'./app'
);
const
constants
=
require
(
'./constants'
);
// try {
// const options = constants.CONFIG.HTTPS_OPTIONS;
// https.createServer(options, app).listen(constants.CONFIG.PORT, () => {
// console.log(`[SYSTEM] HTTPS server is running on port ${constants.CONFIG.PORT}`);
// })
// } catch (err) {
// console.log('[SYSTEM] Cannot start HTTPS server.');
// console.log(err);
// }
app
.
listen
(
3000
);
\ No newline at end of file
try
{
const
options
=
constants
.
CONFIG
.
HTTPS_OPTIONS
;
https
.
createServer
(
options
,
app
).
listen
(
constants
.
CONFIG
.
PORT
,
()
=>
{
console
.
log
(
`[SYSTEM] HTTPS server is running on port
${
constants
.
CONFIG
.
PORT
}
`
);
})
}
catch
(
err
)
{
console
.
log
(
'[SYSTEM] Cannot start HTTPS server.'
);
console
.
log
(
err
);
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment