diff options
| author | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-18 10:54:08 +0000 |
|---|---|---|
| committer | nanalelfe <nargiza.nosirova@mail.utoronto.ca> | 2016-07-18 10:54:08 +0000 |
| commit | a35da9f9ccc1124d9b6f4461c7216ffbb0285e2f (patch) | |
| tree | d5b4b8548caae36a20e1258a8341dab4b3d522d2 /app.js | |
| parent | 16bbc66ebafc6f1a55e47dbda3f3c0f658fe715c (diff) | |
| parent | c1ce89359a7b54ec97b54ce577e5534c180c5c4b (diff) | |
merged
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 |
