Generic express app with a single route: /
Renders "Hello!" when viewed in a browser.
Uses express-es6-template-engine
to show page with "Hello, template!"
Adds the express.static()
middleware for serving static content.
(helmet
is disabled for local development. On my machine, it tried to pull up the static assets using https
, which is only for a live site.)
The header and footer can be "sprinkled" into the res.render()
:
const layout = {
partials: {
header: '/partials/header',
footer: '/partials/footer'
}
};
app.get('/', (req, res) => {
res.render('home', {
...layout,
locals: {
message: "Hello, template with static assets!",
imageUrl: '/images/oakley.jpg'
}
})
});
Shows a list of products.
Each product links to a product details page.
Reorganizes code so that it's not all in the index.js
Moves routing to a separate file.
Adds model, controller, and route for viewing 25 products at a time.
Displays page links for navigating from page to page.
Updates detail.html to go back in the browser history (instead of navigating to /products/
).
Adds employee list at route /employees
Adds employee detail at route /employees/:id
Shows 3-part flow for handling forms:
app.get()
: show a formapp.post()
: process a formres.rediret()
to another page