EC2 Default User

dotenv

1 +node_modules
2 +.env
...\ No newline at end of file ...\ No newline at end of file
1 const Address = require('./Address.js'); 1 const Address = require('./Address.js');
2 const express = require('express'); 2 const express = require('express');
3 const request = require('request'); 3 const request = require('request');
4 +require("dotenv").config("/home/ec2-user/OSS/Experiments/messenger/chat/custom_modules/.env");
5 +// const KAKAO_KEY = process.env.KAKAO_KEY;
6 +const TOKEN = process.env.CHANNEL_ACCESS_TOKEN;
7 +
8 +
4 const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' 9 const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
5 -const TOKEN = 'YK56BfHFgpILrxRk1FZrdcouFguf5CBA5qxM3zfDH6N9jR/cfPxVdK1P9vZHAk69mZDSlSkXNLy25pzqJbXrn3y76hwmH0Kiuvx3OadFYcuidWSp7VYAj4SqJSljv/q5KoYAOE2il8jmQkf4bQKvXQdB04t89/1O/w1cDnyilFU=' 10 +
6 const fs = require('fs'); 11 const fs = require('fs');
7 const path = require('path'); 12 const path = require('path');
8 const HTTPS = require('https'); 13 const HTTPS = require('https');
9 -const domain = "2019102158.oss2022chatbot.tk" 14 +const domain = process.env.MY_DOMAIN;
10 const sslport = 23023; 15 const sslport = 23023;
11 const bodyParser = require('body-parser'); 16 const bodyParser = require('body-parser');
12 const app = express(); 17 const app = express();
......
1 const { response } = require('express'); 1 const { response } = require('express');
2 -const fetch = require('node-fetch') 2 +const fetch = () => import('node-fetch').then(({default: fetch}) => fetch());
3 - 3 +require("dotenv").config("/home/ec2-user/project/emergency_room_ChatBot/.env");
4 -globalThis.fetch = fetch.fetch; 4 +const KAKAO_KEY = process.env.KAKAO_KEY;
5 5
6 var AddressList = new Array(); 6 var AddressList = new Array();
7 7
...@@ -12,26 +12,18 @@ function getAddress(currQuery, cb = ()=> {}) { ...@@ -12,26 +12,18 @@ function getAddress(currQuery, cb = ()=> {}) {
12 query: currQuery 12 query: currQuery
13 }), { 13 }), {
14 method: "GET", 14 method: "GET",
15 - headers: { "Authorization": "KakaoAK c14234ba46c574c73715276c5644f397" } 15 + headers: { "Authorization": KAKAO_KEY }
16 }) 16 })
17 .then(response => response.json()) 17 .then(response => response.json())
18 .then(data => { 18 .then(data => {
19 //console.log(response) 19 //console.log(response)
20 - AddressList = data.documents.map(({ road_address }) => ({ road_address })); 20 + AddressList = data.documents.map(({ road_address }) => ({ road_address }));
21 - //console.log(AddressList)
22 cb(AddressList); 21 cb(AddressList);
23 }); 22 });
24 23
25 },100) 24 },100)
26 } 25 }
27 26
28 -/*
29 -getAddress('석수동길', function (address) {
30 - console.log(address[0].road_address.address_name);
31 -})
32 -*/
33 -
34 -
35 27
36 /* 28 /*
37 29
......
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
2 const request = require('request'); 2 const request = require('request');
3 // 요청을 위한 상수를 선언합니다: TOKEN은 자신의 것을 입력해주세요. 3 // 요청을 위한 상수를 선언합니다: TOKEN은 자신의 것을 입력해주세요.
4 const TARGET_URL = 'https://notify-api.line.me/api/notify'; 4 const TARGET_URL = 'https://notify-api.line.me/api/notify';
5 -const TOKEN = 'YK56BfHFgpILrxRk1FZrdcouFguf5CBA5qxM3zfDH6N9jR/cfPxVdK1P9vZHAk69mZDSlSkXNLy25pzqJbXrn3y76hwmH0Kiuvx3OadFYcuidWSp7VYAj4SqJSljv/q5KoYAOE2il8jmQkf4bQKvXQdB04t89/1O/w1cDnyilFU='; 5 +require("dotenv").config("/home/ec2-user/OSS/Experiments/messenger/chat/custom_modules/.env");
6 -// 요청합니다. 6 +// const KAKAO_KEY = process.env.KAKAO_KEY;
7 +const TOKEN = process.env.CHANNEL_ACCESS_TOKEN;
7 request.post( 8 request.post(
8 { 9 {
9 url: TARGET_URL, 10 url: TARGET_URL,
......