Tip

helper.js๋ฅผ ์—ฐ๊ฒฐํ•œ๊ฑด app.js์—์„œ ์ผ์–ด๋‚œ ์ผ์ด๋‹ค.

app.use((req, res, next) => {
  res.locals.h = helpers;
  res.locals.flashes = req.flash();
  res.locals.user = req.user || null;
  res.locals.currentPath = req.path;
  next();
});

์ฒ˜์Œ์— router ์—ฐ์Šตํ•ด๋ณด๊ธฐ

router.get('/', (req, res) => {
  const wes = { name: 'wes', age: 100, cool: true};
  // res.send('Hey! It works!');
  // res.json(wes);
  // res.send(req.query.name);
  // app์˜ 26๋ฒˆ์งธ 27๋ฒˆ์งธ ์ค„๊ณผ ๊ด€๋ จ์žˆ๋‹ค.
  // res.json(req.query);

  // 1. it needs a name of a template to render out.
  // App์˜ 20๋ฒˆ์งธ 21๋ฒˆ์งธ ์ค„ ๋•Œ๋ฌธ์— ๊ฐ€๋Šฅํ•˜๋‹ค.
  res.render('hello', {
    name: 'wes',
    dog: req.query.dog,
    title: 'I love food',
  });
});

set cookie

mixin

views/editStore.pug

mixin/_storeForm.pug

Last updated

Was this helpful?