var express = require('express');
var router  = express.Router();

/* GET home page. */
router.get('/', function(req, res, next) {
  var app = req.app
  var db = app.get('DB')
  
  db.getItemList((items)=>{
    res.render('index', { title: 'Rent For Camp', items: items })
  })
});

router.get('/article/show/:identifier', function(req, res, next) {
  var app = req.app
  var db = app.get('DB')
  
  const identifier = req.params.identifier
  
  db.getItem(identifier, (item)=>{
    res.render('detail', { title: item.title, item: item })
  })
});

module.exports = router;
