Created
October 25, 2017 18:47
-
-
Save gingerwilliams/2791d8c75f78ff0491fe08bdbe9559e9 to your computer and use it in GitHub Desktop.
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
const express = require('express'); | |
const https = require('https'); | |
const fs = require('fs'); | |
const exphbs = require('express-handlebars'); | |
const path = require('path'); | |
const options = { | |
key: fs.readFileSync( './localhost.key' ), | |
cert: fs.readFileSync( './localhost.cert' ), | |
requestCert: false, | |
rejectUnauthorized: false | |
}; | |
const api = require('./kss'); | |
const routes = require('./routes/routes'); | |
const app = express(); | |
//Handlebars | |
app.engine('hbs', exphbs({ | |
extname: 'hbs', | |
defaultLayout: 'layout', | |
layoutsDir: __dirname + "/builder/views/layouts", | |
partialsDir: __dirname + "/builder/views/partials/" | |
})); | |
app.set('views', path.join(__dirname + "/builder", 'views')); | |
app.set('view engine', 'hbs'); | |
//CSS + JS Assets //Clean Up | |
app.use('/css', express.static(path.join(__dirname, 'output/css'))); | |
app.use('/scripts', express.static(path.join(__dirname, 'output/scripts'))); | |
app.use('/assets', express.static(path.join(__dirname, 'output/assets'))); | |
//JSON | |
app.locals.dataFile = require('./builder/data.json'); | |
//server | |
// app.set('port', 3000); | |
// const server = https.createServer(app).listen(app.get('port'), function () { | |
// console.log('Server running at ' + app.get('port')); | |
// }); | |
//views | |
app.use('/', routes); | |
//Server listener -- below scripts | |
// app.listen(app.get('port'), function () { | |
// console.log('Server running at ' + app.get('port')); | |
// }); | |
const port = process.env.PORT || 3000; | |
const server = https.createServer( options, app ); | |
server.listen( port, function () { | |
console.log( 'Express server listening on port ' + server.address().port ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment