Showing
7 changed files
with
575 additions
and
0 deletions
scripts/README.md
0 → 100644
1 | +# 즐겨찾는 팀을 기반으로 한 축구경기 추천 챗봇 | ||
2 | + | ||
3 | +<!--Table of Contents--> | ||
4 | +## Table of Contents | ||
5 | +1. About the Project | ||
6 | +2. Getting Started (Installation) | ||
7 | +3. Usage | ||
8 | +4. Roadmap | ||
9 | +5. Contributing | ||
10 | +6. License | ||
11 | +7. Contact | ||
12 | + | ||
13 | +<p align="right">(<a href="#top">back to top</a>)</p> | ||
14 | + | ||
15 | +<!--About The Project--> | ||
16 | +## About The Project | ||
17 | +- 본 프로젝트에서는 사용자가 응원하는 축구팀을 즐겨찾기로 추가하여 챗봇과의 대화를 통해 축구경기에 대한 정보를 얻을 수 있게 서비스를 제공합니다. | ||
18 | + | ||
19 | +### Built With | ||
20 | +- [Node.js](https://nodejs.org/ko/) | ||
21 | + | ||
22 | +<p align="right">(<a href="#top">back to top</a>)</p> | ||
23 | + | ||
24 | +<!--Getting Started (Installation)--> | ||
25 | +## Getting Started | ||
26 | + | ||
27 | +### Prerequisites | ||
28 | +- npm | ||
29 | +``` | ||
30 | +npm install | ||
31 | +``` | ||
32 | + | ||
33 | +### Installation | ||
34 | +- Messaging API | ||
35 | +1. Get a free API Key at <https://developers.line.biz/en/services/messaging-api/> | ||
36 | +2. Clone the repo | ||
37 | +``` | ||
38 | +git clone http://khuhub.khu.ac.kr/2018102191/enjoy_soccer.git | ||
39 | +``` | ||
40 | +3.Install NPM packages | ||
41 | +``` | ||
42 | +npm install | ||
43 | +``` | ||
44 | +<p align="right">(<a href="#top">back to top</a>)</p> | ||
45 | + | ||
46 | +<!--Usage--> | ||
47 | +## Usage | ||
48 | +<p align="right">(<a href="#top">back to top</a>)</p> | ||
49 | + | ||
50 | +<!--Roadmap--> | ||
51 | +## Roadmap | ||
52 | + | ||
53 | +<p align="right">(<a href="#top">back to top</a>)</p> | ||
54 | + | ||
55 | +<!--Contributing--> | ||
56 | +## Contributing | ||
57 | +1. Fork the Project | ||
58 | +2. Create your Feature Branch (git checkout -b feature/AmazingFeature) | ||
59 | +3. Commit your Changes (git commit -m 'Add some AmazingFeature') | ||
60 | +4. Push to the Branch (git push origin feature/AmazingFeature) | ||
61 | +5. Open a Pull Request | ||
62 | + | ||
63 | +<p align="right">(<a href="#top">back to top</a>)</p> | ||
64 | + | ||
65 | +<!--License--> | ||
66 | +## License | ||
67 | + | ||
68 | +<p align="right">(<a href="#top">back to top</a>)</p> | ||
69 | + | ||
70 | +<!--Contact--> | ||
71 | +## Contact | ||
72 | +- 박찬수 : suplife0@khu.ac.kr | ||
73 | +- 백지원 : wldnjsl2001@khu.ac.kr | ||
74 | +- 차가민 : gmcha0323@khu.ac.kr | ||
75 | +- Project Link : http://khuhub.khu.ac.kr/2018102191/enjoy_soccer | ||
76 | + | ||
77 | +<p align="right">(<a href="#top">back to top</a>)</p> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
scripts/package-lock.json
0 → 100644
This diff is collapsed. Click to expand it.
scripts/package.json
0 → 100644
1 | +{ | ||
2 | + "name": "reply", | ||
3 | + "version": "1.0.0", | ||
4 | + "description": "", | ||
5 | + "main": "app.js", | ||
6 | + "scripts": { | ||
7 | + "test": "echo \"Error: no test specified\" && exit 1" | ||
8 | + }, | ||
9 | + "author": "", | ||
10 | + "license": "ISC", | ||
11 | + "dependencies": { | ||
12 | + "body-parser": "^1.19.0", | ||
13 | + "express": "^4.17.1", | ||
14 | + "request": "^2.88.2" | ||
15 | + } | ||
16 | +} |
scripts/push.js
0 → 100644
1 | +const request = require('request'); | ||
2 | +const TARGET_URL = 'https://api.line.me/v2/bot/message/push' | ||
3 | +const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast' | ||
4 | +const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast' | ||
5 | +const TOKEN = 'XOyIf8jsoQKq3b1zqxE4wawAoFU2Hz433AO3w8/ye+i6+2KrXpyfFwY0Dk/xhHQLPgtgPTiEP/m4IRW+SlVhdtzfH6c0Lfdw6nJ95QOugHfNWfviAmn5Uojh8LQJeAy21bvaNMCy11f+qgLSRnXmCgdB04t89/1O/w1cDnyilFU=' | ||
6 | +const USER_ID = '사Uc4258407a7677769f74ba184ec036651' | ||
7 | + | ||
8 | +//Single User | ||
9 | +// request.post( | ||
10 | +// { | ||
11 | +// url: TARGET_URL, | ||
12 | +// headers: { | ||
13 | +// 'Authorization': `Bearer ${TOKEN}` | ||
14 | +// }, | ||
15 | +// json: { | ||
16 | +// "to": `${USER_ID}`, | ||
17 | +// "messages":[ | ||
18 | +// { | ||
19 | +// "type":"text", | ||
20 | +// "text":"Hello, user" | ||
21 | +// }, | ||
22 | +// { | ||
23 | +// "type":"text", | ||
24 | +// "text":"May I help you?" | ||
25 | +// } | ||
26 | +// ] | ||
27 | +// } | ||
28 | +// },(error, response, body) => { | ||
29 | +// console.log(body) | ||
30 | +// }); | ||
31 | + | ||
32 | + | ||
33 | +// Multicast User | ||
34 | +request.post( | ||
35 | + { | ||
36 | + url: MULTI_TARGET_URL, | ||
37 | + headers: { | ||
38 | + 'Authorization': `Bearer ${TOKEN}` | ||
39 | + }, | ||
40 | + json: { | ||
41 | + "to": [`${USER_ID}`], | ||
42 | + "messages":[ | ||
43 | + { | ||
44 | + "type":"text", | ||
45 | + "text":"Hello, user" | ||
46 | + }, | ||
47 | + { | ||
48 | + "type":"text", | ||
49 | + "text":"May I help you?" | ||
50 | + } | ||
51 | + ] | ||
52 | + } | ||
53 | + },(error, response, body) => { | ||
54 | + console.log(body) | ||
55 | + }); | ||
56 | + | ||
57 | + | ||
58 | +// Broadcast | ||
59 | + request.post( | ||
60 | + { | ||
61 | + url: BROAD_TARGET_URL, | ||
62 | + headers: { | ||
63 | + 'Authorization': `Bearer ${TOKEN}` | ||
64 | + }, | ||
65 | + json: { | ||
66 | + "messages":[ | ||
67 | + { | ||
68 | + "type":"text", | ||
69 | + "text":"Hello, user" | ||
70 | + }, | ||
71 | + { | ||
72 | + "type":"text", | ||
73 | + "text":"May I help you?" | ||
74 | + } | ||
75 | + ] | ||
76 | + } | ||
77 | + },(error, response, body) => { | ||
78 | + console.log(body) | ||
79 | + }); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
scripts/reply.js
0 → 100644
1 | +var express = require('express'); | ||
2 | +const request = require('request'); | ||
3 | +const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' // reply api | ||
4 | +const TOKEN = 'XOyIf8jsoQKq3b1zqxE4wawAoFU2Hz433AO3w8/ye+i6+2KrXpyfFwY0Dk/xhHQLPgtgPTiEP/m4IRW+SlVhdtzfH6c0Lfdw6nJ95QOugHfNWfviAmn5Uojh8LQJeAy21bvaNMCy11f+qgLSRnXmCgdB04t89/1O/w1cDnyilFU=' | ||
5 | +const fs = require('fs'); | ||
6 | +const path = require('path'); | ||
7 | +const HTTPS = require('https'); | ||
8 | +const domain = "2018102191.osschatbot2022.tk" | ||
9 | +const sslport = 23023; | ||
10 | + | ||
11 | +const bodyParser = require('body-parser'); | ||
12 | +var app = express(); | ||
13 | +app.use(bodyParser.json()); | ||
14 | +app.post('/hook', function (req, res) { | ||
15 | + | ||
16 | + var eventObj = req.body.events[0]; | ||
17 | + var source = eventObj.source; | ||
18 | + var message = eventObj.message; | ||
19 | + | ||
20 | + // request log | ||
21 | + console.log('======================', new Date() ,'======================'); | ||
22 | + console.log('[request]', req.body); | ||
23 | + console.log('[request source] ', eventObj.source); | ||
24 | + console.log('[request message]', eventObj.message); | ||
25 | + | ||
26 | + request.post( | ||
27 | + { | ||
28 | + url: TARGET_URL, | ||
29 | + headers: { | ||
30 | + 'Authorization': `Bearer ${TOKEN}` // 인증정보 : channel token 값을 통해 인증. | ||
31 | + }, | ||
32 | + json: { | ||
33 | + "replyToken":eventObj.replyToken, // reply token : 누구한테 보낼 것인지?를 판별하기 위해! | ||
34 | + "messages":[ | ||
35 | + { | ||
36 | + "type":"text", | ||
37 | + "text":"Hello, user" | ||
38 | + }, | ||
39 | + { | ||
40 | + "type":"text", | ||
41 | + "text":"May I help you?" | ||
42 | + } | ||
43 | + ] | ||
44 | + } | ||
45 | + },(error, response, body) => { | ||
46 | + console.log(body) | ||
47 | + }); | ||
48 | + | ||
49 | + | ||
50 | + res.sendStatus(200); | ||
51 | +}); | ||
52 | + | ||
53 | +try { | ||
54 | + const option = { | ||
55 | + ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | ||
56 | + key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(), | ||
57 | + cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(), | ||
58 | + }; | ||
59 | + | ||
60 | + HTTPS.createServer(option, app).listen(sslport, () => { | ||
61 | + console.log(`[HTTPS] Server is started on port ${sslport}`); | ||
62 | + }); | ||
63 | + } catch (error) { | ||
64 | + console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | ||
65 | + console.log(error); | ||
66 | + } | ||
67 | + |
scripts/script.js
0 → 100644
1 | +// const request = require('request'); | ||
2 | +// const TARGET_URL = 'https://api.line.me/v2/bot/message/push' | ||
3 | +// const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast' | ||
4 | +// const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast' | ||
5 | +// const TOKEN = 'XOyIf8jsoQKq3b1zqxE4wawAoFU2Hz433AO3w8/ye+i6+2KrXpyfFwY0Dk/xhHQLPgtgPTiEP/m4IRW+SlVhdtzfH6c0Lfdw6nJ95QOugHfNWfviAmn5Uojh8LQJeAy21bvaNMCy11f+qgLSRnXmCgdB04t89/1O/w1cDnyilFU=' | ||
6 | +// const USER_ID = '사Uc4258407a7677769f74ba184ec036651' | ||
7 | + | ||
8 | +// var express = require('express'); | ||
9 | +// const request = require('request'); | ||
10 | +// const fs = require('fs'); | ||
11 | +// const path = require('path'); | ||
12 | +// const HTTPS = require('https'); | ||
13 | +// const domain = "2018102191.osschatbot2022.tk" | ||
14 | +// const sslport = 23023; | ||
15 | + | ||
16 | +// // Reply Script | ||
17 | + | ||
18 | +// const bodyParser = require('body-parser'); | ||
19 | +// var app = express(); | ||
20 | +// app.use(bodyParser.json()); | ||
21 | +// app.post('/hook', function (req, res) { | ||
22 | + | ||
23 | +// var eventObj = req.body.events[0]; | ||
24 | +// var source = eventObj.source; | ||
25 | +// var message = eventObj.message; | ||
26 | + | ||
27 | +// // request log | ||
28 | +// console.log('======================', new Date() ,'======================'); | ||
29 | +// console.log('[request]', req.body); | ||
30 | +// console.log('[request source] ', eventObj.source); | ||
31 | +// console.log('[request message]', eventObj.message); | ||
32 | + | ||
33 | +// request.post( | ||
34 | +// { | ||
35 | +// url: TARGET_URL, | ||
36 | +// headers: { | ||
37 | +// 'Authorization': `Bearer ${TOKEN}` // 인증정보 : channel token 값을 통해 인증. | ||
38 | +// }, | ||
39 | +// json: { | ||
40 | +// "replyToken":eventObj.replyToken, // reply token : 누구한테 보낼 것인지?를 판별하기 위해! | ||
41 | +// "messages":[ | ||
42 | +// { | ||
43 | +// "type":"text", | ||
44 | +// "text":"Hello, user" | ||
45 | +// }, | ||
46 | +// { | ||
47 | +// "type":"text", | ||
48 | +// "text":"May I help you?" | ||
49 | +// } | ||
50 | +// ] | ||
51 | +// } | ||
52 | +// },(error, response, body) => { | ||
53 | +// console.log(body) | ||
54 | +// }); | ||
55 | + | ||
56 | + | ||
57 | +// res.sendStatus(200); | ||
58 | +// }); | ||
59 | + | ||
60 | +// try { | ||
61 | +// const option = { | ||
62 | +// ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | ||
63 | +// key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(), | ||
64 | +// cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(), | ||
65 | +// }; | ||
66 | + | ||
67 | +// HTTPS.createServer(option, app).listen(sslport, () => { | ||
68 | +// console.log(`[HTTPS] Server is started on port ${sslport}`); | ||
69 | +// }); | ||
70 | +// } catch (error) { | ||
71 | +// console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | ||
72 | +// console.log(error); | ||
73 | +// } | ||
74 | + | ||
75 | +// // Push Script | ||
76 | + | ||
77 | +// function SinglePush() | ||
78 | +// { | ||
79 | +// request.post( | ||
80 | +// { | ||
81 | +// url: TARGET_URL, | ||
82 | +// headers: { | ||
83 | +// 'Authorization': `Bearer ${TOKEN}` | ||
84 | +// }, | ||
85 | +// json: { | ||
86 | +// "to": `${USER_ID}`, | ||
87 | +// "messages":[ | ||
88 | +// { | ||
89 | +// "type":"text", | ||
90 | +// "text":"Hello, user" | ||
91 | +// }, | ||
92 | +// { | ||
93 | +// "type":"text", | ||
94 | +// "text":"May I help you?" | ||
95 | +// } | ||
96 | +// ] | ||
97 | +// } | ||
98 | +// },(error, response, body) => { | ||
99 | +// console.log(body) | ||
100 | +// }); | ||
101 | +// } | ||
102 | + | ||
103 | +// function MultiPush() | ||
104 | +// { | ||
105 | +// request.post( | ||
106 | +// { | ||
107 | +// url: MULTI_TARGET_URL, | ||
108 | +// headers: { | ||
109 | +// 'Authorization': `Bearer ${TOKEN}` | ||
110 | +// }, | ||
111 | +// json: { | ||
112 | +// "to": [`${USER_ID}`], | ||
113 | +// "messages":[ | ||
114 | +// { | ||
115 | +// "type":"text", | ||
116 | +// "text":"Hello, user" | ||
117 | +// }, | ||
118 | +// { | ||
119 | +// "type":"text", | ||
120 | +// "text":"May I help you?" | ||
121 | +// } | ||
122 | +// ] | ||
123 | +// } | ||
124 | +// },(error, response, body) => { | ||
125 | +// console.log(body) | ||
126 | +// }); | ||
127 | +// } | ||
128 | + | ||
129 | +// function BroadCast() | ||
130 | +// { | ||
131 | +// request.post( | ||
132 | +// { | ||
133 | +// url: BROAD_TARGET_URL, | ||
134 | +// headers: { | ||
135 | +// 'Authorization': `Bearer ${TOKEN}` | ||
136 | +// }, | ||
137 | +// json: { | ||
138 | +// "messages":[ | ||
139 | +// { | ||
140 | +// "type":"text", | ||
141 | +// "text":"Hello, user" | ||
142 | +// }, | ||
143 | +// { | ||
144 | +// "type":"text", | ||
145 | +// "text":"May I help you?" | ||
146 | +// } | ||
147 | +// ] | ||
148 | +// } | ||
149 | +// },(error, response, body) => { | ||
150 | +// console.log(body) | ||
151 | +// }); | ||
152 | +// } | ||
153 | + | ||
154 | +// // Single User | ||
155 | +// // request.post( | ||
156 | +// // { | ||
157 | +// // url: TARGET_URL, | ||
158 | +// // headers: { | ||
159 | +// // 'Authorization': `Bearer ${TOKEN}` | ||
160 | +// // }, | ||
161 | +// // json: { | ||
162 | +// // "to": `${USER_ID}`, | ||
163 | +// // "messages":[ | ||
164 | +// // { | ||
165 | +// // "type":"text", | ||
166 | +// // "text":"Hello, user" | ||
167 | +// // }, | ||
168 | +// // { | ||
169 | +// // "type":"text", | ||
170 | +// // "text":"May I help you?" | ||
171 | +// // } | ||
172 | +// // ] | ||
173 | +// // } | ||
174 | +// // },(error, response, body) => { | ||
175 | +// // console.log(body) | ||
176 | +// // }); | ||
177 | + | ||
178 | + | ||
179 | +// // Multicast User | ||
180 | +// // request.post( | ||
181 | +// // { | ||
182 | +// // url: MULTI_TARGET_URL, | ||
183 | +// // headers: { | ||
184 | +// // 'Authorization': `Bearer ${TOKEN}` | ||
185 | +// // }, | ||
186 | +// // json: { | ||
187 | +// // "to": [`${USER_ID}`], | ||
188 | +// // "messages":[ | ||
189 | +// // { | ||
190 | +// // "type":"text", | ||
191 | +// // "text":"Hello, user" | ||
192 | +// // }, | ||
193 | +// // { | ||
194 | +// // "type":"text", | ||
195 | +// // "text":"May I help you?" | ||
196 | +// // } | ||
197 | +// // ] | ||
198 | +// // } | ||
199 | +// // },(error, response, body) => { | ||
200 | +// // console.log(body) | ||
201 | +// // }); | ||
202 | + | ||
203 | + | ||
204 | +// // Broadcast | ||
205 | +// // request.post( | ||
206 | +// // { | ||
207 | +// // url: BROAD_TARGET_URL, | ||
208 | +// // headers: { | ||
209 | +// // 'Authorization': `Bearer ${TOKEN}` | ||
210 | +// // }, | ||
211 | +// // json: { | ||
212 | +// // "messages":[ | ||
213 | +// // { | ||
214 | +// // "type":"text", | ||
215 | +// // "text":"Hello, user" | ||
216 | +// // }, | ||
217 | +// // { | ||
218 | +// // "type":"text", | ||
219 | +// // "text":"May I help you?" | ||
220 | +// // } | ||
221 | +// // ] | ||
222 | +// // } | ||
223 | +// // },(error, response, body) => { | ||
224 | +// // console.log(body) | ||
225 | +// // }); |
scripts/translate.js
0 → 100644
1 | +var express = require('express'); | ||
2 | +const request = require('request'); | ||
3 | +const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' | ||
4 | +const TOKEN = 'XOyIf8jsoQKq3b1zqxE4wawAoFU2Hz433AO3w8/ye+i6+2KrXpyfFwY0Dk/xhHQLPgtgPTiEP/m4IRW+SlVhdtzfH6c0Lfdw6nJ95QOugHfNWfviAmn5Uojh8LQJeAy21bvaNMCy11f+qgLSRnXmCgdB04t89/1O/w1cDnyilFU=' | ||
5 | +const PAPAGO_URL = 'https://openapi.naver.com/v1/papago/n2mt' | ||
6 | +const PAPAGO_ID = 'UZMyxEhDtcZQ4JNNeohy' | ||
7 | +const PAPAGO_SECRET = 'J2yR82NwYK' | ||
8 | +const fs = require('fs'); | ||
9 | +const path = require('path'); | ||
10 | +const HTTPS = require('https'); | ||
11 | +const domain = "2018102191.osschatbot2022.tk" | ||
12 | +const sslport = 23023; | ||
13 | +const bodyParser = require('body-parser'); | ||
14 | + | ||
15 | +var language = "en"; | ||
16 | + | ||
17 | +var app = express(); | ||
18 | +app.use(bodyParser.json()); | ||
19 | +app.post('/hook', function (req, res) { | ||
20 | + | ||
21 | + var eventObj = req.body.events[0]; | ||
22 | + var source = eventObj.source; | ||
23 | + var message = eventObj.message; | ||
24 | + | ||
25 | + // request log | ||
26 | + console.log('======================', new Date() ,'======================'); | ||
27 | + console.log('[request]', req.body); | ||
28 | + console.log('[request source] ', eventObj.source); | ||
29 | + console.log('[request message]', eventObj.message); | ||
30 | + | ||
31 | + trans(eventObj.replyToken, eventObj.message.text); | ||
32 | + | ||
33 | + | ||
34 | + res.sendStatus(200); | ||
35 | +}); | ||
36 | + | ||
37 | +function trans(replyToken, message) { | ||
38 | + console.log(message); | ||
39 | + switch(message) | ||
40 | + { | ||
41 | + case "영어": | ||
42 | + language = "en"; | ||
43 | + console.log("영어로 변경"); | ||
44 | + return; | ||
45 | + break; | ||
46 | + case "일본어": | ||
47 | + language = "ja"; | ||
48 | + console.log("일본어로 변경"); | ||
49 | + return; | ||
50 | + break; | ||
51 | + case "프랑스어": | ||
52 | + language = "fr"; | ||
53 | + console.log("프랑스어로 변경"); | ||
54 | + return; | ||
55 | + break; | ||
56 | + default: | ||
57 | + break; | ||
58 | + } | ||
59 | + | ||
60 | + request.post( | ||
61 | + { | ||
62 | + url: PAPAGO_URL, | ||
63 | + headers: { | ||
64 | + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', | ||
65 | + 'X-Naver-Client-Id': `${PAPAGO_ID}`, | ||
66 | + 'X-Naver-Client-Secret': `${PAPAGO_SECRET}` | ||
67 | + }, | ||
68 | + body: 'source=ko&target=' + language + '&text=' + message, | ||
69 | + json:true | ||
70 | + },(error, response, body) => { | ||
71 | + if(!error && response.statusCode == 200) { | ||
72 | + console.log(body.message); | ||
73 | + var transMessage = body.message.result.translatedText; | ||
74 | + request.post( | ||
75 | + { | ||
76 | + url: TARGET_URL, | ||
77 | + headers: { | ||
78 | + 'Authorization': `Bearer ${TOKEN}` | ||
79 | + }, | ||
80 | + json: { | ||
81 | + "replyToken":replyToken, | ||
82 | + "messages":[ | ||
83 | + { | ||
84 | + "type":"text", | ||
85 | + "text":transMessage | ||
86 | + } | ||
87 | + ] | ||
88 | + } | ||
89 | + },(error, response, body) => { | ||
90 | + console.log(body) | ||
91 | + }); | ||
92 | + } | ||
93 | + }); | ||
94 | + | ||
95 | +} | ||
96 | + | ||
97 | +try { | ||
98 | + const option = { | ||
99 | + ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | ||
100 | + key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(), | ||
101 | + cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(), | ||
102 | + }; | ||
103 | + | ||
104 | + HTTPS.createServer(option, app).listen(sslport, () => { | ||
105 | + console.log(`[HTTPS] Server is started on port ${sslport}`); | ||
106 | + }); | ||
107 | + } catch (error) { | ||
108 | + console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | ||
109 | + console.log(error); | ||
110 | + } | ||
111 | + | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment