Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김대철
/
CafeRecommend
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
dckat
2021-05-17 15:22:49 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2f004d1dcc537b29fcdc2727c2e7b38f9e78179b
2f004d1d
1 parent
ce0803c6
카페 리스트 API 호출
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
29 deletions
app.js
package-lock.json
package.json
routes/index.js
sessions/ijdJ4QPR_1JVByHrbmm1kwP26Z_pHsur.json
views/map.ejs
app.js
View file @
2f004d1
var
createError
=
require
(
'http-errors'
);
var
express
=
require
(
'express'
);
var
path
=
require
(
'path'
);
var
cookieParser
=
require
(
'cookie-parser'
);
var
logger
=
require
(
'morgan'
);
var
createError
=
require
(
"http-errors"
);
var
express
=
require
(
"express"
);
var
path
=
require
(
"path"
);
var
cookieParser
=
require
(
"cookie-parser"
);
var
logger
=
require
(
"morgan"
);
var
indexRouter
=
require
(
'./routes/index'
);
var
usersRouter
=
require
(
'./routes/users'
);
var
indexRouter
=
require
(
"./routes/index"
);
var
usersRouter
=
require
(
"./routes/users"
);
var
app
=
express
();
// view engine setup
app
.
set
(
'views'
,
path
.
join
(
__dirname
,
'views'
));
app
.
set
(
'view engine'
,
'ejs'
);
app
.
set
(
"views"
,
path
.
join
(
__dirname
,
"views"
));
app
.
set
(
"view engine"
,
"ejs"
);
app
.
use
(
logger
(
'dev'
));
app
.
use
(
logger
(
"dev"
));
app
.
use
(
express
.
json
());
app
.
use
(
express
.
urlencoded
({
extended
:
false
}));
app
.
use
(
cookieParser
());
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'public'
)));
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
"public"
)));
app
.
use
(
'/'
,
indexRouter
);
app
.
use
(
'/users'
,
usersRouter
);
app
.
use
(
"/"
,
indexRouter
);
app
.
use
(
"/users"
,
usersRouter
);
// catch 404 and forward to error handler
app
.
use
(
function
(
req
,
res
,
next
)
{
app
.
use
(
function
(
req
,
res
,
next
)
{
next
(
createError
(
404
));
});
// error handler
app
.
use
(
function
(
err
,
req
,
res
,
next
)
{
app
.
use
(
function
(
err
,
req
,
res
,
next
)
{
// set locals, only providing error in development
res
.
locals
.
message
=
err
.
message
;
res
.
locals
.
error
=
req
.
app
.
get
(
'env'
)
===
'development'
?
err
:
{};
res
.
locals
.
error
=
req
.
app
.
get
(
"env"
)
===
"development"
?
err
:
{};
// render the error page
res
.
status
(
err
.
status
||
500
);
res
.
render
(
'error'
);
res
.
render
(
"error"
);
});
module
.
exports
=
app
;
...
...
package-lock.json
View file @
2f004d1
This diff is collapsed. Click to expand it.
package.json
View file @
2f004d1
...
...
@@ -15,6 +15,7 @@
"http-errors"
:
"~1.6.3"
,
"morgan"
:
"~1.9.1"
,
"nodemon"
:
"^2.0.7"
,
"request"
:
"^2.88.2"
,
"session-file-store"
:
"^1.5.0"
}
}
...
...
routes/index.js
View file @
2f004d1
var
express
=
require
(
"express"
);
var
router
=
express
.
Router
();
var
request
=
require
(
"request"
);
var
{
OAuth2Client
}
=
require
(
"google-auth-library"
);
var
querystring
=
require
(
"querystring"
);
var
CLIENT_ID
=
"94679084723-s5f0686p2porp9mkakrp1p89a48n24nj.apps.googleusercontent.com"
;
var
client
=
new
OAuth2Client
(
CLIENT_ID
);
...
...
@@ -55,6 +59,37 @@ router.post("/login", (req, res) => {
console
.
log
(
req
.
body
.
gender
);
return
res
.
render
(
"login"
,
{
user
:
req
.
session
.
user
});
});
router
.
get
(
"/cafe"
,
(
req
,
res
)
=>
{
let
code
=
"CE7"
;
let
encodedStr
=
querystring
.
escape
(
code
);
let
kakaoOptions
=
{
uri
:
`https://dapi.kakao.com/v2/local/search/category.json?category_group_code=
${
encodedStr
}
`
,
method
:
"GET"
,
headers
:
{
Authorization
:
"KakaoAK 2f3999076db5d32db975ab9862a64480"
,
},
encoding
:
"utf-8"
,
};
request
(
kakaoOptions
,
callback
);
function
callback
(
error
,
res
,
body
)
{
console
.
log
(
body
);
let
kakaoPlaces
=
JSON
.
parse
(
body
);
for
(
document
of
kakaoPlaces
.
documents
)
{
console
.
log
(
document
.
id
);
console
.
log
(
document
.
place_name
);
}
}
return
;
});
router
.
get
(
"/map"
,
(
req
,
res
)
=>
{
res
.
render
(
"map"
);
});
module
.
exports
=
router
;
function
checkAuthenticated
(
req
,
res
,
next
)
{
...
...
@@ -81,7 +116,3 @@ function checkAuthenticated(req, res, next) {
res
.
redirect
(
"/index"
);
});
}
router
.
get
(
"/map"
,
(
req
,
res
)
=>
{
res
.
render
(
"map"
);
});
...
...
sessions/ijdJ4QPR_1JVByHrbmm1kwP26Z_pHsur.json
0 → 100644
View file @
2f004d1
{
"cookie"
:{
"originalMaxAge"
:
null
,
"expires"
:
null
,
"httpOnly"
:
true
,
"path"
:
"/"
},
"__lastAccess"
:
1621216159014
}
\ No newline at end of file
views/map.ejs
View file @
2f004d1
...
...
@@ -30,20 +30,15 @@
var
locPosition
=
new
kakao
.
maps
.
LatLng
(
lat
,
lon
);
display
Marker
(
locPosition
);
display
CurrentPosition
(
locPosition
);
});
}
else
{
var
locPosition
=
new
kakao
.
maps
.
LatLng
(
36.2477502
,
127.078164
);
display
Marker
(
locPosition
);
display
CurrentPosition
(
locPosition
);
}
function
displayMarker
(
locPosition
)
{
var
marker
=
new
daum
.
maps
.
Marker
({
map
:
map
,
position
:
locPosition
,
});
function
displayCurrentPosition
(
locPosition
)
{
map
.
setCenter
(
locPosition
);
}
</script>
...
...
Please
register
or
login
to post a comment