Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
reservation-service
Commits
2e9e6170
Commit
2e9e6170
authored
Nov 06, 2020
by
Yoon, Daeki
😅
Browse files
express helmet
parent
61a30671
Changes
3
Hide whitespace changes
Inline
Side-by-side
server/express.js
View file @
2e9e6170
...
...
@@ -16,10 +16,11 @@ const app = express()
app
.
use
(
bodyParser
.
json
())
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}))
app
.
use
(
helmet
())
//
app.use(helmet())
app
.
use
(
cors
())
app
.
use
(
'
/dist
'
,
express
.
static
(
path
.
join
(
CURRENT_WORKING_DIR
,
'
dist
'
)))
console
.
log
(
'
path=
'
,
path
.
join
(
CURRENT_WORKING_DIR
,
'
client
'
,
'
build
'
))
app
.
use
(
'
/
'
,
express
.
static
(
path
.
join
(
CURRENT_WORKING_DIR
,
'
client
'
,
'
build
'
)))
app
.
use
(
'
/
'
,
indexRouter
);
app
.
use
(
'
/users
'
,
usersRouter
,
reservesRouter
);
...
...
server/routes/index.js
View file @
2e9e6170
...
...
@@ -4,8 +4,9 @@ const User = require('../models/user');
const
router
=
express
.
Router
();
/* GET home page. */
// router.get('/', function(req, res, next) {
// res.render('index', { title: 'Express' });
// });
router
.
get
(
'
/
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
index router
'
);
res
.
send
(
"
hello
"
)
});
module
.
exports
=
router
;
\ No newline at end of file
server/routes/reserves.js
View file @
2e9e6170
...
...
@@ -82,20 +82,17 @@ router.get('/room/:room', function (req, res, next) {
router
.
get
(
'
/:_id
'
,
verifyToken
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/reserves get req.params
'
,
req
.
params
)
Reserve
.
find
({
user
:
req
.
params
.
_id
},
function
(
err
,
reserve
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
// console.log(reserve, Date.now())
const
reserves
=
reserve
.
map
(
item
=>
(
new
Date
(
item
.
end
)
>=
Date
.
now
()
?
item
:
""
));
if
(
!
reserves
)
{
console
.
log
(
"
no신청
"
)
res
.
status
(
404
).
json
({
error
:
"
신청내역이 없습니다.
"
})
}
console
.
log
(
"
reserves
"
,
reserves
)
res
.
status
(
201
).
json
(
reserves
);
})
Reserve
.
find
({
user
:
req
.
params
.
_id
}).
sort
({
date
:
0
})
.
then
((
reserve
)
=>
{
const
reserves
=
reserve
.
map
(
item
=>
(
new
Date
(
item
.
end
)
>=
Date
.
now
()
?
item
:
""
));
console
.
log
(
"
reserves
"
,
reserves
)
res
.
status
(
201
).
json
(
reserves
);
})
.
catch
((
err
)
=>
{
res
.
status
(
500
).
json
({
error
:
err
});
})
});
router
.
get
(
'
/admin/:_id
'
,
verifyToken
,
function
(
req
,
res
,
next
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment