문성준

Rename variables

...@@ -3,39 +3,14 @@ const request = require('request'); ...@@ -3,39 +3,14 @@ const request = require('request');
3 var config = require('./config.json'); 3 var config = require('./config.json');
4 const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' 4 const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
5 const TOKEN = config.TOKEN; 5 const TOKEN = config.TOKEN;
6 -const KOFIC_URL = 'http://www.kobis.or.kr/kobisopenapi/webservice/rest/movie/searchMovieList.json' 6 +const KOFIC_URL_MovieList = 'http://www.kobis.or.kr/kobisopenapi/webservice/rest/movie/searchMovieList.json'
7 -const fs = require('fs');
8 -const path = require('path');
9 -const HTTPS = require('https');
10 -const domain = config.domain;
11 -const sslport = 23023;
12 const bodyParser = require('body-parser'); 7 const bodyParser = require('body-parser');
13 -var app = express();
14 -app.use(bodyParser.json());
15 8
16 -app.post('/hook', function (req, res) { 9 +exports.movielist = function (replyToken, message) {
17 -
18 - var eventObj = req.body.events[0];
19 - var source = eventObj.source;
20 - var message = eventObj.message;
21 -
22 - // request log
23 - console.log('======================', new Date() ,'======================');
24 - console.log('[request]', req.body);
25 - console.log('[request source] ', eventObj.source);
26 - console.log('[request message]', eventObj.message);
27 -
28 - movielist(eventObj.replyToken, eventObj.message.text);
29 -
30 - res.sendStatus(200);
31 -});
32 -
33 -
34 -function movielist(replyToken, message) {
35 var encodedMessage = encodeURI(message); 10 var encodedMessage = encodeURI(message);
36 request.get( 11 request.get(
37 { 12 {
38 - url: KOFIC_URL+`?key=${config.KOFIC_KEY}&movieNm=${encodedMessage}`, 13 + url: KOFIC_URL_MovieList+`?key=${config.KOFIC_KEY_MovieList}&movieNm=${encodedMessage}`,
39 json:true 14 json:true
40 },(error, response, body) => { 15 },(error, response, body) => {
41 if(!error && response.statusCode == 200) { 16 if(!error && response.statusCode == 200) {
...@@ -75,19 +50,3 @@ function movielist(replyToken, message) { ...@@ -75,19 +50,3 @@ function movielist(replyToken, message) {
75 }); 50 });
76 51
77 } 52 }
78 -
79 -try {
80 - const option = {
81 - ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
82 - key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(),
83 - cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(),
84 - };
85 -
86 - HTTPS.createServer(option, app).listen(sslport, () => {
87 - console.log(`[HTTPS] Server is started on port ${sslport}`);
88 - });
89 - } catch (error) {
90 - console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
91 - console.log(error);
92 - }
93 -
...\ No newline at end of file ...\ No newline at end of file
......