조현아

seperated config

node_modules/
var express = require('express');
var app = express();
const line = require('@line/bot-sdk');
const config = require('./config');
//papago api
......@@ -12,19 +13,10 @@ var translate_api_url = 'https://openapi.naver.com/v1/papago/n2mt';
//언어감지 api_url
var languagedetect_api_url = 'https://openapi.naver.com/v1/papago/detectLangs'
// Naver Auth Key
//새로 발급받은 naver papago api id, pw 입력
var client_id = 'xZMx34y7uru1v8lywZ2d';
var client_secret = 'p6L7M7WsH9';
const config = {
channelAccessToken: 'mnny0MJSezgBXzR9C3Ddcc1Csdb7Y9jkvy2nqV5saOmvR2YOJ1/kj/2M0CNsLA+57B2qDpdUQ7WbCTtIKx/LAJ6Kwfop4tX3up7EM8H9EZK1td6GMbhhCb6wvUFVdb1PcTO4joCv8mspd3ubo8a+gAdB04t89/1O/w1cDnyilFU=',
channelSecret: 'bde77633a16fc5bfbd532d5990c6170e',
};
// create LINE SDK client
const client = new line.Client(config);
const client = new line.Client(config.line_config);
// create Express app
// about Express itself: https://expressjs.com/
......@@ -52,7 +44,7 @@ function handleEvent(event) {
var detect_options = {
url : languagedetect_api_url,
form : {'query': event.message.text},
headers: {'X-Naver-Client-Id': client_id, 'X-Naver-Client-Secret': client_secret}
headers: config.naver_header
};
//papago 언어 감지
......@@ -77,7 +69,7 @@ function handleEvent(event) {
url: translate_api_url,
// 한국어(source : ko), 영어(target: en), 카톡에서 받는 메시지(text)
form: {'source':source, 'target':target, 'text':event.message.text},
headers: {'X-Naver-Client-Id': client_id, 'X-Naver-Client-Secret': client_secret}
headers: config.naver_header
};
// Naver Post API
......
// Naver Auth Key
export const naver_header = {
'X-Naver-Client-Id': '',
'X-Naver-Client-Secret': ''
}
// Line config
export const line_config = {
channelAccessToken: '',
channelSecret: '',
};