Toggle navigation
Toggle navigation
This project
Loading...
Sign in
정혜인
/
OSS
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Authored by
Seongwook Jin
2020-05-26 08:51:02 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7a4e7f2f23ab9593b2b67758b2ec2c0c0a20438d
7a4e7f2f
1 parent
b1b737d2
ssl support
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
20 deletions
Experiments/.gitignore
Experiments/messenger/reply/app.js
Experiments/messenger/trans/app.js
Experiments/messenger/webhook/app.js
Experiments/.gitignore
0 → 100644
View file @
7a4e7f2
node_modules
Experiments/messenger/reply/app.js
View file @
7a4e7f2
var
express
=
require
(
'express'
);
const
request
=
require
(
'request'
);
const
TARGET_URL
=
'https://api.line.me/v2/bot/message/reply'
const
TOKEN
=
'채널 토큰으로 교체 해야 함'
const
TOKEN
=
'채널 토큰으로 변경'
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
HTTPS
=
require
(
'https'
);
const
domain
=
"도메인 변경"
const
sslport
=
23023
;
const
bodyParser
=
require
(
'body-parser'
);
var
app
=
express
();
...
...
@@ -45,8 +50,18 @@ app.post('/hook', function (req, res) {
res
.
sendStatus
(
200
);
});
var
server
=
app
.
listen
(
23023
,
function
()
{
var
host
=
server
.
address
().
address
var
port
=
server
.
address
().
port
console
.
log
(
"Example app listening at http://%s:%s"
,
host
,
port
)
})
try
{
const
option
=
{
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
(),
};
HTTPS
.
createServer
(
option
,
app
).
listen
(
sslport
,
()
=>
{
console
.
log
(
`[HTTPS] Server is started on port
${
sslport
}
`
);
});
}
catch
(
error
)
{
console
.
log
(
'[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'
);
console
.
log
(
error
);
}
...
...
Experiments/messenger/trans/app.js
View file @
7a4e7f2
var
express
=
require
(
'express'
);
const
request
=
require
(
'request'
);
const
TARGET_URL
=
'https://api.line.me/v2/bot/message/reply'
const
TOKEN
=
'채널 토큰
으로 교체
'
const
TOKEN
=
'채널 토큰'
const
PAPAGO_URL
=
'https://openapi.naver.com/v1/papago/n2mt'
const
PAPAGO_ID
=
'네이버 클라이언트 ID'
const
PAPAGO_SECRET
=
'네이버 클라이언트 Secret'
const
PAPAGO_ID
=
'파파고 ID'
const
PAPAGO_SECRET
=
'파파고 Client Secret'
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
HTTPS
=
require
(
'https'
);
const
domain
=
"도메인 명"
const
sslport
=
23023
;
const
bodyParser
=
require
(
'body-parser'
);
var
app
=
express
();
app
.
use
(
bodyParser
.
json
());
...
...
@@ -66,8 +70,18 @@ function trans(replyToken, message) {
}
var
server
=
app
.
listen
(
23023
,
function
()
{
var
host
=
server
.
address
().
address
var
port
=
server
.
address
().
port
console
.
log
(
"Example app listening at http://%s:%s"
,
host
,
port
)
})
try
{
const
option
=
{
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
(),
};
HTTPS
.
createServer
(
option
,
app
).
listen
(
sslport
,
()
=>
{
console
.
log
(
`[HTTPS] Server is started on port
${
sslport
}
`
);
});
}
catch
(
error
)
{
console
.
log
(
'[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'
);
console
.
log
(
error
);
}
\ No newline at end of file
...
...
Experiments/messenger/webhook/app.js
View file @
7a4e7f2
var
express
=
require
(
'express'
);
const
bodyParser
=
require
(
'body-parser'
);
var
app
=
express
();
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
HTTPS
=
require
(
'https'
);
const
domain
=
"도메인 변경 처리"
const
sslport
=
23023
;
app
.
use
(
bodyParser
.
json
());
app
.
post
(
'/hook'
,
function
(
request
,
response
)
{
...
...
@@ -18,8 +24,19 @@ app.post('/hook', function (request, response) {
response
.
sendStatus
(
200
);
});
var
server
=
app
.
listen
(
23023
,
function
()
{
var
host
=
server
.
address
().
address
var
port
=
server
.
address
().
port
console
.
log
(
"Example app listening at http://%s:%s"
,
host
,
port
)
})
try
{
const
option
=
{
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
(),
};
HTTPS
.
createServer
(
option
,
app
).
listen
(
sslport
,
()
=>
{
console
.
log
(
`[HTTPS] Server is started on port
${
sslport
}
`
);
});
}
catch
(
error
)
{
console
.
log
(
'[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'
);
console
.
log
(
error
);
}
...
...
Please
register
or
login
to post a comment