Created
December 5, 2022 12:15
-
-
Save kunxin-chor/112c277c86e4e47bcfa6db57b490edcc to your computer and use it in GitHub Desktop.
Boilerplate for Express Application with HBS and Wax on
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1. SETUP EXPRESS | |
const express = require('express'); | |
const hbs = require('hbs'); | |
const wax = require('wax-on'); | |
// 1a. create the app | |
const app = express(); | |
// 1b setup our view engine (aka template engine) | |
// tell Express that we are using hbs | |
app.set('view engine', 'hbs'); | |
// 1c setup wax-on | |
wax.on(hbs.handlebars); | |
// 1d tell wax-on where to find the layout files | |
wax.setLayoutPath("./views/layouts"); | |
// 1e use static files (i.e, images, css, js etc. -- that is, all content not generated | |
// by our routes) | |
app.use(express.static('public')); | |
// 2. CREATE ROUTES | |
app.get('/', function(req,res){ | |
res.send("Hello world"); | |
}) | |
// 3. START SERVER (No routers after you've started server) | |
app.listen(3000, function(){ | |
console.log("Server has started"); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment