Toggle navigation
Toggle navigation
This project
Loading...
Sign in
박정민
/
TFT
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Junhyuyk Seo
2021-12-01 19:59:28 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2f5d486b8e3614a7c2321d854d23f5a6aba347e0
2f5d486b
1 parent
2373ad9e
Optimize for deployment
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
13 deletions
ServiceKey/festival.txt
ServiceKey/weather.txt
TFT_API/Dockerfile
TFT_API/models/Festival.js
TFT_API/package.json
TFT_API/server.js
docker-compose.yml
ServiceKey/festival.txt
0 → 100644
View file @
2f5d486
%2FsBWti235XX%2Fg1%2FqBZfiNQ6A%2BJmF3WL%2FboaNqJH4v3eWic59SiHc6W5vgZKU7Hjocj%2BAntIqHfhXOpmE5CpAFw%3D%3D
\ No newline at end of file
ServiceKey/weather.txt
0 → 100644
View file @
2f5d486
2lFkvQJYgzOOhwUKiUt8aZVNpd1PpBOf%2FfMNW17cl25DE0GUEDddeR9iGnuSUpggjUoIUgamfhcvnKQ3eH1dAw%3D%3D
\ No newline at end of file
TFT_API/Dockerfile
View file @
2f5d486
...
...
@@ -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
...
...
TFT_API/models/Festival.js
View file @
2f5d486
...
...
@@ -24,5 +24,4 @@ const festivalSchema = new Schema({
versionKey
:
false
});
module
.
exports
=
mongoose
.
model
(
'Festival'
,
festivalSchema
);
...
...
TFT_API/package.json
View file @
2f5d486
...
...
@@ -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"
:
""
,
...
...
TFT_API/server.js
View file @
2f5d486
...
...
@@ -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='
+
ServiceKey
2
+
'?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='
+
ServiceKey
2
+
'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='
+
ServiceKey
2
+
'ServiceKey='
+
ServiceKey
+
'&contentTypeId='
+
'15'
+
'&contentId='
+
item
[
'contentid'
]
+
'&MobileOS=ETC&MobileApp=TourAPI3.0_Guide&introYN=Y&_type=json'
,
...
...
docker-compose.yml
View file @
2f5d486
...
...
@@ -11,4 +11,6 @@ services:
-
"
8484:8484"
apihandler
:
build
:
./TFT_API/
\ No newline at end of file
build
:
./TFT_API/
volumes
:
-
./ServiceKey:/app/ServiceKey
\ No newline at end of file
...
...
Please
register
or
login
to post a comment