고혜연

Add reply webhook by line message

......@@ -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/notify'
const url = 'https://api.line.me/v2/bot/message/reply'
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');
......
......@@ -8,14 +8,14 @@ module.exports = {
URL: {
NOTIFY: 'https://notify-api.line.me/api/notify',
},
TOKEN: 'Cu3yosmWtXOPBhjccMCdJj2YH1g5KF8rhBv0zHZyqj3uYOrHSPYkixI+6SP7bfZOdC8J4xwhOriJahHtLxsQxUMnTaanncGyAyTFyD9+18gvzEcS39plUIadREyL38HoY/9o6O3a3guSOMxyiT+cJQdB04t89/1O/w1cDnyilFU=',
CHANNEL_TOKEN: 'RzDICmPPV/TJBYTazkASkptggoT58lCt+IS9ayXvYXZP2INsAkeiQfVNV2/5OULHzxXEzXQQRIwsyZ1uXVXROuM4GYLfPNOGqCFbt2pzgbWbp29X4b0ohfZAsA80PsP8CEfiSAiue9lOrxNm3AXS5QdB04t89/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
......
......@@ -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
......