고혜연

Add reply webhook by line message

...@@ -40,7 +40,7 @@ app.post('/webhook', (req, res) => { ...@@ -40,7 +40,7 @@ app.post('/webhook', (req, res) => {
40 console.log('[request source] ', source); 40 console.log('[request source] ', source);
41 console.log('[request message]', message); 41 console.log('[request message]', message);
42 42
43 - const url = 'https://notify-api.line.me/api/notify' 43 + const url = 'https://api.line.me/v2/bot/message/reply'
44 axios.post(url, { 44 axios.post(url, {
45 replyToken, 45 replyToken,
46 messages: [ 46 messages: [
...@@ -54,7 +54,10 @@ app.post('/webhook', (req, res) => { ...@@ -54,7 +54,10 @@ app.post('/webhook', (req, res) => {
54 }, 54 },
55 ], 55 ],
56 }, { 56 }, {
57 - headers: `Bearer ${constants.LINE.TOKEN}`, 57 + headers: {
58 + authorization: `Bearer ${constants.LINE.TOKEN}`,
59 + 'Content-Type': 'application/json',
60 + },
58 }).then(notifyResponse => { 61 }).then(notifyResponse => {
59 res.status(200); 62 res.status(200);
60 res.send('Success'); 63 res.send('Success');
......
...@@ -8,14 +8,14 @@ module.exports = { ...@@ -8,14 +8,14 @@ module.exports = {
8 URL: { 8 URL: {
9 NOTIFY: 'https://notify-api.line.me/api/notify', 9 NOTIFY: 'https://notify-api.line.me/api/notify',
10 }, 10 },
11 - TOKEN: 'Cu3yosmWtXOPBhjccMCdJj2YH1g5KF8rhBv0zHZyqj3uYOrHSPYkixI+6SP7bfZOdC8J4xwhOriJahHtLxsQxUMnTaanncGyAyTFyD9+18gvzEcS39plUIadREyL38HoY/9o6O3a3guSOMxyiT+cJQdB04t89/1O/w1cDnyilFU=', 11 + CHANNEL_TOKEN: 'RzDICmPPV/TJBYTazkASkptggoT58lCt+IS9ayXvYXZP2INsAkeiQfVNV2/5OULHzxXEzXQQRIwsyZ1uXVXROuM4GYLfPNOGqCFbt2pzgbWbp29X4b0ohfZAsA80PsP8CEfiSAiue9lOrxNm3AXS5QdB04t89/1O/w1cDnyilFU=',
12 }, 12 },
13 CONFIG: { 13 CONFIG: {
14 PORT: 443, 14 PORT: 443,
15 HTTPS_OPTIONS: { 15 HTTPS_OPTIONS: {
16 - // ca: fs.readFileSync(`/etc/letsencrypt/live/${domain}/fullchain.pem`), 16 + ca: fs.readFileSync(`/etc/letsencrypt/live/${domain}/fullchain.pem`),
17 - // key: fs.readFileSync(path.resolve(process.cwd(), `/etc/letsencrypt/live/${domain}/privkey.pem`), 'utf8').toString(), 17 + key: fs.readFileSync(path.resolve(process.cwd(), `/etc/letsencrypt/live/${domain}/privkey.pem`), 'utf8').toString(),
18 - // cert: fs.readFileSync(path.resolve(process.cwd(), `/etc/letsencrypt/live/${domain}/cert.pem`), 'utf8').toString(), 18 + cert: fs.readFileSync(path.resolve(process.cwd(), `/etc/letsencrypt/live/${domain}/cert.pem`), 'utf8').toString(),
19 } 19 }
20 } 20 }
21 }; 21 };
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,14 +3,12 @@ const https = require('https'); ...@@ -3,14 +3,12 @@ const https = require('https');
3 const app = require('./app'); 3 const app = require('./app');
4 const constants = require('./constants'); 4 const constants = require('./constants');
5 5
6 -// try {
7 -// const options = constants.CONFIG.HTTPS_OPTIONS;
8 -// https.createServer(options, app).listen(constants.CONFIG.PORT, () => {
9 -// console.log(`[SYSTEM] HTTPS server is running on port ${constants.CONFIG.PORT}`);
10 -// })
11 -// } catch (err) {
12 -// console.log('[SYSTEM] Cannot start HTTPS server.');
13 -// console.log(err);
14 -// }
15 -
16 -app.listen(3000);
...\ No newline at end of file ...\ No newline at end of file
6 +try {
7 + const options = constants.CONFIG.HTTPS_OPTIONS;
8 + https.createServer(options, app).listen(constants.CONFIG.PORT, () => {
9 + console.log(`[SYSTEM] HTTPS server is running on port ${constants.CONFIG.PORT}`);
10 + })
11 +} catch (err) {
12 + console.log('[SYSTEM] Cannot start HTTPS server.');
13 + console.log(err);
14 +}
...\ No newline at end of file ...\ No newline at end of file
......