Permalink
Browse files

Updates

  • Loading branch information...
dstroot committed Feb 19, 2014
1 parent 0ea5a30 commit 37106cea9dc9ef70cf7ae15dd4cc0d537de68c84
View
@@ -0,0 +1,83 @@
+{
+ "maxerr" : 50, // {int} Maximum error before stopping
+
+ // Enforcing
+ "bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
+ "camelcase" : false, // true: Identifiers must be in camelCase
+ "curly" : true, // true: Require {} for every new block or scope
+ "eqeqeq" : true, // true: Require triple equals (===) for comparison
+ "forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
+ "immed" : false, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
+ "indent" : 2, // {int} Number of spaces to use for indentation
+ "latedef" : false, // true: Require variables/functions to be defined before being used
+ "newcap" : false, // true: Require capitalization of all constructor functions e.g. `new F()`
+ "noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
+ "noempty" : true, // true: Prohibit use of empty blocks
+ "nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
+ "plusplus" : false, // true: Prohibit use of `++` & `--`
+ "quotmark" : false, // Quotation mark consistency:
+ // false : do nothing (default)
+ // true : ensure whatever is used is consistent
+ // "single" : require single quotes
+ // "double" : require double quotes
+ "undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
+ "unused" : "vars", // true: Require all defined variables be used
+ "strict" : true, // true: Requires all functions run in ES5 Strict Mode
+ "trailing" : false, // true: Prohibit trailing whitespaces
+ "maxparams" : false, // {int} Max number of formal params allowed per function
+ "maxdepth" : false, // {int} Max depth of nested blocks (within functions)
+ "maxstatements" : false, // {int} Max number statements per function
+ "maxcomplexity" : false, // {int} Max cyclomatic complexity per function
+ "maxlen" : false, // {int} Max number of characters per line
+
+ // Relaxing
+ "asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
+ "boss" : false, // true: Tolerate assignments where comparisons would be expected
+ "debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
+ "eqnull" : false, // true: Tolerate use of `== null`
+ "es5" : false, // true: Allow ES5 syntax (ex: getters and setters)
+ "esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
+ "moz" : false, // true: Allow Mozilla specific syntax (extends and overrides esnext features)
+ // (ex: `for each`, multiple try/catch, function expression…)
+ "evil" : false, // true: Tolerate use of `eval` and `new Function()`
+ "expr" : false, // true: Tolerate `ExpressionStatement` as Programs
+ "funcscope" : false, // true: Tolerate defining variables inside control statements"
+ "globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
+ "iterator" : false, // true: Tolerate using the `__iterator__` property
+ "lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
+ "laxbreak" : false, // true: Tolerate possibly unsafe line breakings
+ "laxcomma" : false, // true: Tolerate comma-first style coding
+ "loopfunc" : false, // true: Tolerate functions being defined in loops
+ "multistr" : false, // true: Tolerate multi-line strings
+ "proto" : false, // true: Tolerate using the `__proto__` property
+ "scripturl" : false, // true: Tolerate script-targeted URLs
+ "smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment
+ "shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
+ "sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
+ "supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
+ "validthis" : false, // true: Tolerate using this in a non-constructor function
+
+ // Environments
+ "browser" : false, // Web Browser (window, document, etc)
+ "couch" : false, // CouchDB
+ "devel" : true, // Development/debugging (alert, confirm, etc)
+ "dojo" : false, // Dojo Toolkit
+ "jquery" : false, // jQuery
+ "mootools" : false, // MooTools
+ "node" : true, // Node.js
+ "nonstandard" : true, // Widely adopted globals (escape, unescape, etc)
+ "prototypejs" : false, // Prototype and Scriptaculous
+ "rhino" : false, // Rhino
+ "worker" : false, // Web Workers
+ "wsh" : false, // Windows Scripting Host
+ "yui" : false, // Yahoo User Interface
+
+ // Legacy
+ "nomen" : false, // true: Prohibit dangling `_` in variables
+ "onevar" : false, // true: Allow only one `var` statement per function
+ "passfail" : false, // true: Stop on first error
+ "white" : false, // true: Check against strict whitespace and indentation rules
+
+ // Custom Globals
+ "predef" : [ ] // additional predefined global variables
+}
View
@@ -1,4 +1,4 @@
-Express Skeleton [![Dependency Status](https://david-dm.org/dstroot/express-skeleton.png?theme=shields.io)](https://david-dm.org/dstroot/express-skeleton)
+Skeleton [![Dependency Status](https://david-dm.org/dstroot/skeleton.png?theme=shields.io)](https://david-dm.org/dstroot/skeleton)
=================
A few notes on my coding style: I like braces and use them always, even for single-line if statements and the like. I like variable names that mean something, rather than trying to be short. I favor single quotes above double quotes. I prefer comments above lines, as opposed to on the right-hand side. I use a LOT of comments, because JS can always be minified so there's really no reason to worry about comments contributing to filesize. I use a decent amount of whitespace for the same reason. Oh, and I like my opening braces on the same line, not a new line.
@@ -79,6 +79,24 @@ Prerequisites
:exclamation: **Note**: If you are new to Node.js or Express framework,
I highly recommend watching [Node.js and Express 101](http://www.youtube.com/watch?v=BN0JlMZCtNU) screencast by Alex Ford that teaches Node and Express from scratch. Alternatively, here is another great tutorial for complete beginners - [Getting Started With Node.js, Express, MongoDB](http://cwbuecheler.com/web/tutorials/2013/node-express-mongo/).
+Gulp build system
+-------------------
+<p align="center">
+ <a href="http://gulpjs.com">
+ <img height="194" width="98" src="https://raw.github.com/gulpjs/artwork/master/gulp.png"/>
+ </a>
+</p>
+
+Many people use Express.js middleware to build assets, however I generally like a seperate build system like Grunt or Gulp.
+
+Our build system compiles and minifies all assets and starts the app app using nodemon. Nodemon will restart node every time a server .js file changes. We also start a livereload server that will trigger a reload of your page in the browser when any client .js, .css, .jade or images change.
+
+To take advantage of the livereload functionality install Google Chrome and then using the chrome web store install the "LiveReload" extension. Click on the center dot to turn on the livereload capability after you start up via `gulp`.
+
+Now every time you make a change to a client component things will be recompiled and your browser will reload. Cool!
+
+// TODO Complete section
+
Getting Started
---------------
@@ -93,6 +111,7 @@ cd my-project
# Install NPM dependencies
npm install
+bower install
node app.js
```
View
35 app.js
@@ -21,7 +21,7 @@ var semver = require('semver'); // https://npmjs.org/
var helmet = require('helmet'); // https://github.com/evilpacket/helmet
var pkg = require('./package.json'); // Get package.json
var config = require('./config/config'); // Get configuration
-var passportConf = require('./config/passport'); // Get passport.js setup
+// var passportConf = require('./config/passport'); // Get passport.js setup
/**
* Static Variables
@@ -30,15 +30,14 @@ var passportConf = require('./config/passport'); // Get passport.js se
var hour = 3600000;
var day = (hour * 24);
var week = (day * 7);
-var month = (day * 30);
/**
* Create Express Server and socket.io listener
*/
-var app = express()
- , server = require('http').createServer(app)
- , io = io.listen(server);
+var app = express(),
+ server = require('http').createServer(app),
+ io = io.listen(server);
/**
* Configure Logging
@@ -103,12 +102,6 @@ app.set('view engine', 'jade');
// Enable If behind nginx!
// app.enable('trust proxy');
-// Used to build css and js automagically
-app.use(require('connect-assets')({
- src: 'public',
- helperContext: app.locals
-}));
-
// Compress response data with gzip / deflate.
// This middleware should be placed "high" within
// the stack to ensure all responses are compressed.
@@ -210,7 +203,7 @@ app.use(function(req, res, next){
// Handle 403 Errors
app.use(function(err, req, res, next) {
- if (err.status == 403) {
+ if (err.status === 403) {
winston.error('403 Not Allowed. ' + err + '\n');
// Respond with HTML
if (req.accepts('html')) {
@@ -258,9 +251,9 @@ if ( app.get('env') === 'development') {
*/
fs.readdirSync('./controllers').forEach(function (file) {
- if(file.substr(-3) == '.js') {
- var route = require('./controllers/' + file);
- route.controller(app);
+ if(file.substr(-3) === '.js') {
+ var route = require('./controllers/' + file);
+ route.controller(app);
}
});
@@ -336,16 +329,16 @@ io.configure('production', function(){
io.set('log level', 1); // reduce logging
io.set("polling duration", 10); // increase polling frequency
io.set('transports', [ // Manage transports
- 'websocket'
- , 'htmlfile'
- , 'xhr-polling'
- , 'jsonp-polling'
+ 'websocket',
+ 'htmlfile',
+ 'xhr-polling',
+ 'jsonp-polling'
]);
io.set('authorization', function (handshakeData, callback) {
if (handshakeData.xdomain) {
- callback('Cross-domain connections are not allowed');
+ callback('Cross-domain connections are not allowed');
} else {
- callback(null, true);
+ callback(null, true);
}
});
});
View
@@ -1,3 +1,5 @@
+'use strict';
+
/**
* Module dependencies.
*/
View
@@ -2,11 +2,13 @@
/**
* Why like this?
+ *
* - all environmental vars documented in one place
* - If I use "." notation it's easy to cut/paste into code
* - Unlike JSON, js allows comments (what is this setting for?)
*/
+
/**
* Configuration File
*/
@@ -24,7 +26,7 @@ config.cryptoKey = process.env.CRYPTOKEY || '';
* Logging Configuration
*/
-config.logging = true;
+config.logging = false;
config.logfilename = 'skeleton.log';
/**
View
@@ -36,13 +36,15 @@ passport.deserializeUser(function(id, done) {
passport.use(new LocalStrategy({ usernameField: 'email' }, function(email, password, done) {
User.findOne({ email: email }, function(err, user) {
- if (!user) return done(null, false, { message: 'Email ' + email + ' not found'});
+ if (!user) {
+ return done(null, false, { message: 'Email ' + email + ' not found'});
+ }
user.comparePassword(password, function(err, isMatch) {
if (isMatch) {
// update the user's record with login timestamp
user.activity.last_logon = Date.now();
user.save(function(err) {
- done(err, user);
+ done(err, user);
});
return done(null, user);
} else {
@@ -79,12 +81,13 @@ passport.use(new FacebookStrategy(config.facebook, function(req, accessToken, re
});
} else {
User.findOne({ facebook: profile.id }, function(err, existingUser) {
- console.log(profile)
+ // TODO REMOVE
+ // console.log(profile);
if (existingUser) {
// update the user's record with login timestamp
existingUser.activity.last_logon = Date.now();
existingUser.save(function(err) {
- done(err, existingUser);
+ done(err, existingUser);
});
return done(null, existingUser);
}
@@ -134,7 +137,7 @@ passport.use(new GitHubStrategy(config.github, function(req, accessToken, refres
// update the user's record with login timestamp
existingUser.activity.last_logon = Date.now();
existingUser.save(function(err) {
- done(err, existingUser);
+ done(err, existingUser);
});
return done(null, existingUser);
}
@@ -183,7 +186,7 @@ passport.use(new TwitterStrategy(config.twitter, function(req, accessToken, toke
// update the user's record with login timestamp
existingUser.activity.last_logon = Date.now();
existingUser.save(function(err) {
- done(err, existingUser);
+ done(err, existingUser);
});
return done(null, existingUser);
}
@@ -234,7 +237,7 @@ passport.use(new GoogleStrategy(config.google, function(req, accessToken, refres
// update the user's record with login timestamp
existingUser.activity.last_logon = Date.now();
existingUser.save(function(err) {
- done(err, existingUser);
+ done(err, existingUser);
});
return done(null, existingUser);
}
@@ -304,7 +307,9 @@ passport.use('foursquare', new OAuth2Strategy({
*/
exports.isAuthenticated = function(req, res, next) {
- if (req.isAuthenticated()) return next();
+ if (req.isAuthenticated()) {
+ return next();
+ }
res.redirect('/login');
};
@@ -314,6 +319,9 @@ exports.isAuthenticated = function(req, res, next) {
exports.isAuthorized = function(req, res, next) {
var provider = req.path.split('/').slice(-1)[0];
- if (_.findWhere(req.user.tokens, { kind: provider })) next();
- else res.redirect('/auth/' + provider);
+ if (_.findWhere(req.user.tokens, { kind: provider })) {
+ next();
+ } else {
+ res.redirect('/auth/' + provider);
+ }
};
View
@@ -32,19 +32,19 @@ module.exports = {
*/
mongodb: {
- mongodb.url: process.env.MONGODB_URL || ''
+ mongodbUrl: process.env.MONGODB_URL || ''
},
/**
* Session Configuration
*/
session: {
- session.key: process.env.SESSION_KEY || '',
- session.secret: process.env.SESSION_SECRET || ''
+ sessionKey: process.env.SESSION_KEY || '',
+ sessionSecret: process.env.SESSION_SECRET || ''
},
-=====================================================================
+// =====================================================================
/**
* TODO: Throttle Login Attempts
*/
Oops, something went wrong.

0 comments on commit 37106ce

Please sign in to comment.