added mongo dependency. basic skel
This commit is contained in:
parent
95a2d5aa96
commit
da455b4964
|
@ -0,0 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
exports.render = function(req, res) {
|
||||||
|
res.render('index');
|
||||||
|
};
|
|
@ -0,0 +1,13 @@
|
||||||
|
extends layouts/default
|
||||||
|
|
||||||
|
block main
|
||||||
|
h1 Oops something went wrong
|
||||||
|
br
|
||||||
|
span 404
|
||||||
|
|
||||||
|
block content
|
||||||
|
#error-message-box
|
||||||
|
#error-stack-trace
|
||||||
|
pre
|
||||||
|
code!= error
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
extends layouts/default
|
||||||
|
|
||||||
|
block main
|
||||||
|
h1 Oops something went wrong
|
||||||
|
br
|
||||||
|
span 500
|
||||||
|
|
||||||
|
block content
|
||||||
|
#error-message-box
|
||||||
|
#error-stack-trace
|
||||||
|
pre
|
||||||
|
code!= error
|
|
@ -0,0 +1,12 @@
|
||||||
|
head
|
||||||
|
meta(charset='utf-8')
|
||||||
|
meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1')
|
||||||
|
meta(name='viewport', content='width=device-width,initial-scale=1')
|
||||||
|
|
||||||
|
title BitPay
|
||||||
|
meta(http-equiv='Content-type', content='text/html;charset=UTF-8')
|
||||||
|
meta(name="keywords", content="node.js, express, mongoose, mongodb, angularjs")
|
||||||
|
meta(name="description", content="Mystery")
|
||||||
|
|
||||||
|
link(href='/img/icons/favicon.ico', rel='shortcut icon', type='image/x-icon')
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
extends layouts/default
|
||||||
|
|
||||||
|
block content
|
||||||
|
h1 Hello BitPay!
|
|
@ -0,0 +1,8 @@
|
||||||
|
doctype html
|
||||||
|
html(lang='en', xmlns='http://www.w3.org/1999/xhtml')
|
||||||
|
include ../includes/head
|
||||||
|
body
|
||||||
|
section.content
|
||||||
|
section.container
|
||||||
|
block content
|
||||||
|
include ../includes/foot
|
|
@ -0,0 +1,9 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var _ = require('lodash');
|
||||||
|
|
||||||
|
// Load app configuration
|
||||||
|
|
||||||
|
module.exports = _.extend(
|
||||||
|
require(__dirname + '/../config/env/all.js'),
|
||||||
|
require(__dirname + '/../config/env/' + process.env.NODE_ENV + '.js') || {});
|
|
@ -0,0 +1,10 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var path = require('path'),
|
||||||
|
rootPath = path.normalize(__dirname + '/../..');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
root: rootPath,
|
||||||
|
port: process.env.PORT || 3000,
|
||||||
|
db: process.env.MONGOHQ_URL
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
db: "mongodb://localhost/mystery-dev",
|
||||||
|
app: {
|
||||||
|
name: "Mystery - Development"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
db: "mongodb://localhost/mystery",
|
||||||
|
app: {
|
||||||
|
name: "Mystery - Production"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
db: "mongodb://localhost/mystery-test",
|
||||||
|
port: 3001,
|
||||||
|
app: {
|
||||||
|
name: "Mystery - Test"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
var express = require('express'),
|
||||||
|
config = require('./config');
|
||||||
|
|
||||||
|
module.exports = function(app, passport, db) {
|
||||||
|
app.set('showStackError', true);
|
||||||
|
|
||||||
|
//Prettify HTML
|
||||||
|
app.locals.pretty = true;
|
||||||
|
|
||||||
|
//Should be placed before express.static
|
||||||
|
app.use(express.compress({
|
||||||
|
filter: function(req, res) {
|
||||||
|
return (/json|text|javascript|css/).test(res.getHeader('Content-Type'));
|
||||||
|
},
|
||||||
|
level: 9
|
||||||
|
}));
|
||||||
|
|
||||||
|
//Set views path, template engine and default layout
|
||||||
|
app.set('views', config.root + '/app/views');
|
||||||
|
app.set('view engine', 'jade');
|
||||||
|
|
||||||
|
//Enable jsonp
|
||||||
|
app.enable("jsonp callback");
|
||||||
|
|
||||||
|
app.configure(function() {
|
||||||
|
//cookieParser should be above session
|
||||||
|
app.use(express.cookieParser());
|
||||||
|
|
||||||
|
// request body parsing middleware should be above methodOverride
|
||||||
|
app.use(express.urlencoded());
|
||||||
|
app.use(express.json());
|
||||||
|
app.use(express.methodOverride());
|
||||||
|
|
||||||
|
//routes should be at the last
|
||||||
|
app.use(app.router);
|
||||||
|
|
||||||
|
//Setting the fav icon and static folder
|
||||||
|
app.use(express.favicon());
|
||||||
|
app.use(express.static(config.root + '/public'));
|
||||||
|
|
||||||
|
//Assume "not found" in the error msgs is a 404. this is somewhat silly, but valid, you can do whatever you like, set properties, use instanceof etc.
|
||||||
|
app.use(function(err, req, res, next) {
|
||||||
|
//Treat as 404
|
||||||
|
if (~err.message.indexOf('not found')) return next();
|
||||||
|
|
||||||
|
//Log it
|
||||||
|
console.error(err.stack);
|
||||||
|
|
||||||
|
//Error page
|
||||||
|
res.status(500).render('500', {
|
||||||
|
error: err.stack
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//Assume 404 since no middleware responded
|
||||||
|
app.use(function(req, res, next) {
|
||||||
|
res.status(404).render('404', {
|
||||||
|
url: req.originalUrl,
|
||||||
|
error: 'Not found'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,9 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = function(app) {
|
||||||
|
|
||||||
|
//Home route
|
||||||
|
var index = require('../app/controllers/index');
|
||||||
|
app.get('/', index.render);
|
||||||
|
|
||||||
|
};
|
|
@ -29,5 +29,11 @@
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "*"
|
"node": "*"
|
||||||
}
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"express": "~3.4.7",
|
||||||
|
"jade": "~1.0.2",
|
||||||
|
"mongoose": "~3.8.3",
|
||||||
|
"lodash": "~2.4.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
var express = require('express'),
|
||||||
|
fs = require('fs');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main application entry file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//Load configurations
|
||||||
|
//Set the node enviornment variable if not set before
|
||||||
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||||
|
|
||||||
|
//Initializing system variables
|
||||||
|
var config = require('./config/config'),
|
||||||
|
mongoose = require('mongoose');
|
||||||
|
|
||||||
|
//Bootstrap db connection
|
||||||
|
var db = mongoose.connect(config.db);
|
||||||
|
|
||||||
|
//Bootstrap models
|
||||||
|
var models_path = __dirname + '/app/models';
|
||||||
|
var walk = function(path) {
|
||||||
|
fs.readdirSync(path).forEach(function(file) {
|
||||||
|
var newPath = path + '/' + file;
|
||||||
|
var stat = fs.statSync(newPath);
|
||||||
|
if (stat.isFile()) {
|
||||||
|
if (/(.*)\.(js$|coffee$)/.test(file)) {
|
||||||
|
require(newPath);
|
||||||
|
}
|
||||||
|
} else if (stat.isDirectory()) {
|
||||||
|
walk(newPath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
walk(models_path);
|
||||||
|
|
||||||
|
var app = express();
|
||||||
|
|
||||||
|
//express settings
|
||||||
|
require('./config/express')(app, db);
|
||||||
|
|
||||||
|
//Bootstrap routes
|
||||||
|
require('./config/routes')(app);
|
||||||
|
|
||||||
|
//Start the app by listening on <port>
|
||||||
|
var port = process.env.PORT || config.port;
|
||||||
|
app.listen(port);
|
||||||
|
console.log('Express app started on port ' + port);
|
||||||
|
|
||||||
|
//expose app
|
||||||
|
exports = module.exports = app;
|
Loading…
Reference in New Issue