aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--app.js10
-rw-r--r--config/express.js5
-rw-r--r--models/pPost.js3
-rw-r--r--package.json3
4 files changed, 18 insertions, 3 deletions
diff --git a/app.js b/app.js
index a0f7ae1..d1911ee 100644
--- a/app.js
+++ b/app.js
@@ -2,19 +2,23 @@
/**
* Module dependencies.
*/
+
var express = require('express')
, fs = require('fs')
, passport = require('passport')
, mongoose = require('mongoose');
+
/**
* App configuration
*/
+
var port = process.env.PORT || 8000
, env = process.env.NODE_ENV || 'development'
, config = require('./config/config')[env]
, auth = require('./config/middlewares/authorization');
+
// Bootstrap db connection
mongoose.connect(config.db);
var db = mongoose.connection;
@@ -23,6 +27,7 @@ db.once('open', function callback(){
console.log('Connected to ' + config.db);
});
+
// Bootstrap models
// This gets all model files in ./models
var models_path = __dirname + '/models';
@@ -30,12 +35,15 @@ fs.readdirSync(models_path).forEach( function(file) {
require(models_path + '/' + file);
});
+
// Bootstrap passport config
require('./config/passport')(passport, config);
+
/**
* Express
*/
+
var app = express();
// express settings
require('./config/express')(app, config, passport);
@@ -44,12 +52,14 @@ require('./config/express')(app, config, passport);
/**
* Routes
*/
+
require('./routes')(app, passport, auth);
/**
* Server initiation
*/
+
app.listen(port, function() {
console.log("Express server listening on port " + port);
});
diff --git a/config/express.js b/config/express.js
index eb10b20..034eff5 100644
--- a/config/express.js
+++ b/config/express.js
@@ -3,7 +3,8 @@
* Module dependencies
*/
-var express = require('express');
+var express = require('express')
+ , expressValidator = require('express-validator');
/**
@@ -28,6 +29,8 @@ module.exports = function (app, config, passport) {
app.use(express.bodyParser()); //must be above methodOverride
+ app.use(expressValidator); // loads validation
+
app.use(express.methodOverride());
app.use(express.session({ secret: 'lsdrghoi4hgqio42nqf2uqi32f3bilu23fl23b' }));
diff --git a/models/pPost.js b/models/pPost.js
index c02f863..1ce50b2 100644
--- a/models/pPost.js
+++ b/models/pPost.js
@@ -17,7 +17,8 @@ var pPostSchema = new Schema({
file: { type: String, default: '', trim: true },
currency: { type: String, default: 'kr', trim: true },
created: { type: Date, default: Date.now },
- updated: { type: Date, default: Date.now }
+ updated: { type: Date, default: Date.now },
+ when: { type: Date, default: Date.now }
});
diff --git a/package.json b/package.json
index 4aabf64..962e059 100644
--- a/package.json
+++ b/package.json
@@ -23,7 +23,8 @@
, "passport-facebook": "latest"
, "passport-twitter": "latest"
, "nodemon": "latest"
- }
+ , "express-validator": "latest"
+ }
, "devDependencies": {
"mocha": "latest"
}