Showing
1 changed file
with
42 additions
and
0 deletions
app.js
0 → 100644
| 1 | +var express = require('express'); | ||
| 2 | +const bodyParser = require('body-parser'); | ||
| 3 | +var app = express(); | ||
| 4 | +const fs = require('fs'); | ||
| 5 | +const path = require('path'); | ||
| 6 | +const HTTPS = require('https'); | ||
| 7 | +const domain = "www.osstest78910.ml" | ||
| 8 | +const sslport = 23023; | ||
| 9 | + | ||
| 10 | +app.use(bodyParser.json()); | ||
| 11 | + | ||
| 12 | +app.post('/hook', function (request, response) { | ||
| 13 | + | ||
| 14 | + var eventObj = request.body.events[0]; | ||
| 15 | + var source = eventObj.source; | ||
| 16 | + var message = eventObj.message; | ||
| 17 | + | ||
| 18 | + // request log | ||
| 19 | + console.log('======================', new Date() ,'======================'); | ||
| 20 | + console.log('[request]', request.body); | ||
| 21 | + console.log('[request source] ', eventObj.source); | ||
| 22 | + console.log('[request message]', eventObj.message); | ||
| 23 | + | ||
| 24 | + response.sendStatus(200); | ||
| 25 | +}); | ||
| 26 | + | ||
| 27 | + | ||
| 28 | +try { | ||
| 29 | + const option = { | ||
| 30 | + ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | ||
| 31 | + key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(), | ||
| 32 | + cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(), | ||
| 33 | + }; | ||
| 34 | + | ||
| 35 | + HTTPS.createServer(option, app).listen(sslport, () => { | ||
| 36 | + console.log(`[HTTPS] Server is started on port ${sslport}`); | ||
| 37 | + }); | ||
| 38 | + } catch (error) { | ||
| 39 | + console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | ||
| 40 | + console.log(error); | ||
| 41 | + } | ||
| 42 | + |
-
Please register or login to post a comment