Junhyuyk Seo

Optimize for deployment

%2FsBWti235XX%2Fg1%2FqBZfiNQ6A%2BJmF3WL%2FboaNqJH4v3eWic59SiHc6W5vgZKU7Hjocj%2BAntIqHfhXOpmE5CpAFw%3D%3D
\ No newline at end of file
2lFkvQJYgzOOhwUKiUt8aZVNpd1PpBOf%2FfMNW17cl25DE0GUEDddeR9iGnuSUpggjUoIUgamfhcvnKQ3eH1dAw%3D%3D
\ No newline at end of file
......@@ -14,4 +14,4 @@ RUN npm install
COPY ./ ./
#start application
CMD [ "node", "server.js" ]
\ No newline at end of file
CMD [ "npm", "start" ]
\ No newline at end of file
......
......@@ -24,5 +24,4 @@ const festivalSchema = new Schema({
versionKey: false
});
module.exports = mongoose.model('Festival',festivalSchema);
......
......@@ -2,9 +2,9 @@
"name": "REST-API",
"version": "1.0.0",
"description": "",
"main": "index.js",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"start": "node server"
},
"keywords": [],
"author": "",
......
......@@ -2,14 +2,12 @@ const mongoose = require('mongoose');
// const db = require('mongodb');
const Festival = require('./models/Festival');
const request = require('request-promise-native');
const fs = require('fs');
const url = 'mongodb://mongo:27017';
const ServiceKey = fs.readFileSync('./ServiceKey/festival.txt', 'utf-8');
const WeatherServiceKey = fs.readFileSync('./ServiceKey/weather.txt', 'utf-8');
const ServiceKey = '3zrQDvoNwUV9Se%2BHZv8DjCCNWRGJisQ7jjHP6LsbJqoRQ2cJpQKrHUGC4uslgXSVO9Dzb06BSC3kp9BunvIPSw%3D%3D';
const ServiceKey2 ='%2FGjtI8kwZeJTzJm%2BxUxz%2Bjh15wnmV3rwFuRvrq3oRSqyklfiZfbUaqmsG0McVPJMdXSUYetGaCXl0ZkbfMI0BQ%3D%3D'
const ServiceKey3 ='%2FsBWti235XX%2Fg1%2FqBZfiNQ6A%2BJmF3WL%2FboaNqJH4v3eWic59SiHc6W5vgZKU7Hjocj%2BAntIqHfhXOpmE5CpAFw%3D%3D'
const WeatherServiceKey = '2lFkvQJYgzOOhwUKiUt8aZVNpd1PpBOf%2FfMNW17cl25DE0GUEDddeR9iGnuSUpggjUoIUgamfhcvnKQ3eH1dAw%3D%3D';
const COORDINATES = require('./coordinates')['COORDINATES'];
const DISTRICT = [
"서울특별시", "부산광역시", "울산광역시", "대구광역시", "대전광역시",
......@@ -49,9 +47,18 @@ mongoose.connect(url,(err)=>{
if(err) {
console.log(err);
} else {
mongoose.connection.db.listCollections().toArray(async (err, collection) => {
if(!collection.includes('festivals')) {
await mongoose.connection.db.createCollection("festivals");
}
});
mongoose.connection.db.dropCollection('festivals',function(err, result) {
if(err) {
console.log(err + "Reset Failed!");
writeDB();
} else {
console.log(result + "Reset Success!");
......@@ -59,7 +66,7 @@ mongoose.connect(url,(err)=>{
let options = {
'method': 'GET',
'url' : 'http://api.visitkorea.or.kr/openapi/service/rest/KorService/areaBasedList'
+ '?ServiceKey=' + ServiceKey2
+ '?ServiceKey=' + ServiceKey
+ '&contentTypeId=15&areaCode=&sigunguCode=&cat1=&cat2=&cat3=&listYN=Y&MobileOS=ETC&MobileApp=TourAPI3.0_Guide&arrange=C&numOfRows=12'
+ '&pageNo='+ i
+ '&_type=json',
......@@ -79,7 +86,7 @@ mongoose.connect(url,(err)=>{
'public': {
'method': 'GET',
'url': 'http://api.visitkorea.or.kr/openapi/service/rest/KorService/detailCommon?'
+ 'ServiceKey=' + ServiceKey2
+ 'ServiceKey=' + ServiceKey
+ '&contentTypeId=' + '15'
+ '&contentId=' + item['contentid']
+ '&MobileOS=ETC&MobileApp=TourAPI3.0_Guide&defaultYN=Y&firstImageYN=Y&areacodeYN=Y&catcodeYN=Y&addrinfoYN=Y&mapinfoYN=Y&overviewYN=Y&transGuideYN=Y&_type=json',
......@@ -88,7 +95,7 @@ mongoose.connect(url,(err)=>{
'detail': {
'method': 'GET',
'url': 'http://api.visitkorea.or.kr/openapi/service/rest/KorService/detailIntro?'
+ 'ServiceKey=' + ServiceKey2
+ 'ServiceKey=' + ServiceKey
+ '&contentTypeId=' + '15'
+ '&contentId=' + item['contentid']
+ '&MobileOS=ETC&MobileApp=TourAPI3.0_Guide&introYN=Y&_type=json',
......
......@@ -12,3 +12,5 @@ services:
apihandler:
build: ./TFT_API/
volumes:
- ./ServiceKey:/app/ServiceKey
\ No newline at end of file
......