윤성아

apply https

const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Hello world!');
});
module.exports = app;
\ No newline at end of file
const fs = require('fs');
const path = require('path');
const domain = '2020105640.oss-2021.tk';
module.exports = {
LINE: {
URL: {
NOTIFY: 'https://notify-api.line.me/api/notify',
},
TOKEN: 'Cu3yosmWtXOPBhjccMCdJj2YH1g5KF8rhBv0zHZyqj3uYOrHSPYkixI+6SP7bfZOdC8J4xwhOriJahHtLxsQxUMnTaanncGyAyTFyD9+18gvzEcS39plUIadREyL38HoY/9o6O3a3guSOMxyiT+cJQdB04t89/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(),
}
}
};
\ No newline at end of file
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);
}
\ No newline at end of file
......@@ -2,11 +2,11 @@
"name": "sweetday-dessert-chatbot",
"version": "1.0.0",
"description": "Chatbot based on Express.js, Line API",
"main": "app.js",
"main": "index.js",
"scripts": {
"start": "node app.js",
"start:dev": "nodemon app.js",
"start:prod": "pm2 app.js",
"start": "node https/index.js",
"start:dev": "nodemon --watch https/ https/index.js",
"start:prod": "pm2 https/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
......@@ -23,5 +23,8 @@
"license": "MIT",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies":{
"nodemon": "^2.0.7"
}
}
......