Showing
4 changed files
with
51 additions
and
4 deletions
https/app.js
0 → 100644
https/constants.js
0 → 100644
1 | +const fs = require('fs'); | ||
2 | +const path = require('path'); | ||
3 | + | ||
4 | +const domain = '2020105640.oss-2021.tk'; | ||
5 | + | ||
6 | +module.exports = { | ||
7 | + LINE: { | ||
8 | + URL: { | ||
9 | + NOTIFY: 'https://notify-api.line.me/api/notify', | ||
10 | + }, | ||
11 | + TOKEN: 'Cu3yosmWtXOPBhjccMCdJj2YH1g5KF8rhBv0zHZyqj3uYOrHSPYkixI+6SP7bfZOdC8J4xwhOriJahHtLxsQxUMnTaanncGyAyTFyD9+18gvzEcS39plUIadREyL38HoY/9o6O3a3guSOMxyiT+cJQdB04t89/1O/w1cDnyilFU=', | ||
12 | + }, | ||
13 | + CONFIG: { | ||
14 | + PORT: 443, | ||
15 | + HTTPS_OPTIONS: { | ||
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(), | ||
18 | + cert: fs.readFileSync(path.resolve(process.cwd(), `/etc/letsencrypt/live/${domain}/cert.pem`), 'utf8').toString(), | ||
19 | + } | ||
20 | + } | ||
21 | +}; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
https/index.js
0 → 100644
1 | +const https = require('https'); | ||
2 | + | ||
3 | +const app = require('./app'); | ||
4 | +const constants = require('./constants'); | ||
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 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -2,11 +2,11 @@ | ... | @@ -2,11 +2,11 @@ |
2 | "name": "sweetday-dessert-chatbot", | 2 | "name": "sweetday-dessert-chatbot", |
3 | "version": "1.0.0", | 3 | "version": "1.0.0", |
4 | "description": "Chatbot based on Express.js, Line API", | 4 | "description": "Chatbot based on Express.js, Line API", |
5 | - "main": "app.js", | 5 | + "main": "index.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | - "start": "node app.js", | 7 | + "start": "node https/index.js", |
8 | - "start:dev": "nodemon app.js", | 8 | + "start:dev": "nodemon --watch https/ https/index.js", |
9 | - "start:prod": "pm2 app.js", | 9 | + "start:prod": "pm2 https/index.js", |
10 | "test": "echo \"Error: no test specified\" && exit 1" | 10 | "test": "echo \"Error: no test specified\" && exit 1" |
11 | }, | 11 | }, |
12 | "repository": { | 12 | "repository": { |
... | @@ -23,5 +23,8 @@ | ... | @@ -23,5 +23,8 @@ |
23 | "license": "MIT", | 23 | "license": "MIT", |
24 | "dependencies": { | 24 | "dependencies": { |
25 | "express": "^4.17.1" | 25 | "express": "^4.17.1" |
26 | + }, | ||
27 | + "devDependencies":{ | ||
28 | + "nodemon": "^2.0.7" | ||
26 | } | 29 | } |
27 | } | 30 | } | ... | ... |
-
Please register or login to post a comment