Commit 2e9e6170 authored by Yoon, Daeki's avatar Yoon, Daeki 😅
Browse files

express helmet

parent 61a30671
......@@ -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);
......
......@@ -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
......@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment