Skip to content

Node.js based forum software built for the modern web

Merge branch 'master' of github.com:psychobunny/node-forum

Julian Lam71e410d571bb
diff --cc src/webserver.js
index d3fff55b45,0fea8d29cf..c401993229
--- a/src/webserver.js
+++ b/src/webserver.js
@@@ -7,34 -7,7 +7,33 @@@ var express = require('express')
(function(app) {
var templates = global.templates;
+ function refreshTemplates() {
+ //need a better solution than copying this code on every call. is there an "onconnect" event?
+ if (DEVELOPMENT === true) {
+ // refreshing templates
+ modules.templates.init();
+ }
+ }
+
+ function checkAuth(req, res, next) {
+ if (!req.session || !req.session.uid) {
+ res.send(403, 'You are not authorized to view this page');
+ } else {
+ next();
+ }
+ }
+
+ // Middlewares
+ app.use(express.favicon()); // 2 args: string path and object options (i.e. expire time etc)
+ app.use(express.bodyParser()); // Puts POST vars in request.body
+ app.use(express.cookieParser()); // If you want to parse cookies (res.cookies)
+ app.use(express.session({secret: 'nodebb-julian', key: 'express.sid'}));
+ // Dunno wtf this does
+ // app.use(express.logger({ format: '\x1b[1m:method\x1b[0m \x1b[33m:url\x1b[0m :response-time ms' }));
+ // Useful if you want to use app.put and app.delete (instead of app.post all the time)
+ // app.use(express.methodOverride());
+
app.get('/', function(req, res) {
- refreshTemplates();
res.send(templates['header'] + templates['home'] + templates['footer']);
});