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

express helmet

parent 61a30671
...@@ -16,10 +16,11 @@ const app = express() ...@@ -16,10 +16,11 @@ const app = express()
app.use(bodyParser.json()) app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true })) app.use(bodyParser.urlencoded({ extended: true }))
app.use(helmet()) // app.use(helmet())
app.use(cors()) 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('/', indexRouter);
app.use('/users', usersRouter, reservesRouter); app.use('/users', usersRouter, reservesRouter);
......
...@@ -4,8 +4,9 @@ const User = require('../models/user'); ...@@ -4,8 +4,9 @@ const User = require('../models/user');
const router = express.Router(); const router = express.Router();
/* GET home page. */ /* GET home page. */
// router.get('/', function(req, res, next) { router.get('/', function(req, res, next) {
// res.render('index', { title: 'Express' }); console.log('index router');
// }); res.send("hello")
});
module.exports = router; module.exports = router;
\ No newline at end of file
...@@ -82,20 +82,17 @@ router.get('/room/:room', function (req, res, next) { ...@@ -82,20 +82,17 @@ router.get('/room/:room', function (req, res, next) {
router.get('/:_id', verifyToken, function (req, res, next) { router.get('/:_id', verifyToken, function (req, res, next) {
console.log('/reserves get req.params', req.params) console.log('/reserves get req.params', req.params)
Reserve.find({ user: req.params._id }, function (err, reserve) { Reserve.find({ user: req.params._id }).sort({date: 0})
if (err) return res.status(500).json({ error: err }); .then((reserve) => {
// console.log(reserve, Date.now())
const reserves = reserve.map(item => ( const reserves = reserve.map(item => (
new Date(item.end) >= Date.now() ? item : "" new Date(item.end) >= Date.now() ? item : ""
)); ));
if (!reserves) {
console.log("no신청")
res.status(404).json({ error: "신청내역이 없습니다." })
}
console.log("reserves", reserves) console.log("reserves", reserves)
res.status(201).json(reserves); res.status(201).json(reserves);
}) })
.catch((err) => {
res.status(500).json({ error: err });
})
}); });
router.get('/admin/:_id', verifyToken, function (req, res, next) { 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