diff options
| author | HumairAK <humair88@hotmail.com> | 2016-07-18 10:49:16 +0000 |
|---|---|---|
| committer | HumairAK <humair88@hotmail.com> | 2016-07-18 10:49:16 +0000 |
| commit | c1ce89359a7b54ec97b54ce577e5534c180c5c4b (patch) | |
| tree | 39f8333533131fc0b0efba99a0517e11a63706ce /app.js | |
| parent | 0a47900db45ce82d10ad09a6aee85e1ba68a9063 (diff) | |
Various fixes, see changelog for details.
Diffstat (limited to 'app.js')
| -rw-r--r-- | app.js | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -0,0 +1,34 @@ +var fs = require("fs"); +var express = require('express'); +var path = require('path'); +var cookieParser = require('cookie-parser'); +var bodyParser = require('body-parser'); +var hbs = require('express-handlebars'); + +var routes = require('./routes/index'); +var app = express(); + +// Templating engine, we are using handlebars +// This will allow us to create html pages dynamically before serving them. +app.engine('.hbs', hbs({extname: '.hbs', defaultLayout: 'layout', + layoutsDir: __dirname + '/views/layouts/', // Set directory for base layout + partialsDir: __dirname + '/views/partials'})); // Set directory for partials + + +app.set('views', path.join(__dirname, 'views')); // Our view path +app.set('view engine', '.hbs'); + +// Middleware initialization, make sure everything is initialized in proper order +app.use(bodyParser.json()); +app.use(bodyParser.urlencoded({extended: true})); +app.use(cookieParser()); + +/*LOADS ALL STATIC FILES FROM THE DIRECTORY __dirname*/ +app.use(express.static(__dirname)); + +// Allows us to customize express routing +// in a separate file. +app.use('/', routes); + + +module.exports = app;
\ No newline at end of file |
