mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-02-09 16:07:00 +01:00
Properly run JSHint
This commit is contained in:
10
.jshintrc
10
.jshintrc
@@ -1,7 +1,6 @@
|
||||
{
|
||||
"node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
|
||||
"browser": true, // Standard browser globals e.g. `window`, `document`.
|
||||
"es5": true, // Allow EcmaScript 5 syntax.
|
||||
"esnext": true, // Allow ES.next specific features such as `const` and `let`.
|
||||
"bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.).
|
||||
"camelcase": false, // Permit only camelcase for `var` and `object indexes`.
|
||||
@@ -15,7 +14,7 @@
|
||||
"regexp": true, // Prohibit `.` and `[^...]` in regular expressions.
|
||||
"undef": true, // Require all non-global variables be declared before they are used.
|
||||
"unused": true, // Warn unused variables.
|
||||
"strict": false, // Require `use strict` pragma in every file.
|
||||
"strict": true, // Require `use strict` pragma in every file.
|
||||
"trailing": true, // Prohibit trailing whitespaces.
|
||||
"smarttabs": false, // Suppresses warnings about mixed tabs and spaces
|
||||
"globals": { // Globals variables.
|
||||
@@ -31,10 +30,11 @@
|
||||
"beforeEach",
|
||||
"after",
|
||||
"afterEach",
|
||||
"it"
|
||||
"it",
|
||||
"inject",
|
||||
"expect"
|
||||
],
|
||||
"indent": 4, // Specify indentation spacing
|
||||
"maxlen": 120, // Max line lenght
|
||||
"devel": false, // Allow development statements e.g. `console.log();`.
|
||||
"devel": true, // Allow development statements e.g. `console.log();`.
|
||||
"noempty": true // Prohibit use of empty blocks.
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
@@ -46,7 +48,14 @@ exports.update = function(req, res) {
|
||||
article = _.extend(article, req.body);
|
||||
|
||||
article.save(function(err) {
|
||||
res.jsonp(article);
|
||||
if (err) {
|
||||
return res.send('users/signup', {
|
||||
errors: err.errors,
|
||||
article: article
|
||||
});
|
||||
} else {
|
||||
res.jsonp(article);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -58,8 +67,9 @@ exports.destroy = function(req, res) {
|
||||
|
||||
article.remove(function(err) {
|
||||
if (err) {
|
||||
res.render('error', {
|
||||
status: 500
|
||||
return res.send('users/signup', {
|
||||
errors: err.errors,
|
||||
article: article
|
||||
});
|
||||
} else {
|
||||
res.jsonp(article);
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
'use strict';
|
||||
|
||||
exports.render = function(req, res) {
|
||||
res.render('index', {
|
||||
user: req.user ? JSON.stringify(req.user) : "null"
|
||||
user: req.user ? JSON.stringify(req.user) : 'null'
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
@@ -7,7 +9,7 @@ var mongoose = require('mongoose'),
|
||||
/**
|
||||
* Auth callback
|
||||
*/
|
||||
exports.authCallback = function(req, res, next) {
|
||||
exports.authCallback = function(req, res) {
|
||||
res.redirect('/');
|
||||
};
|
||||
|
||||
@@ -49,19 +51,19 @@ exports.session = function(req, res) {
|
||||
/**
|
||||
* Create user
|
||||
*/
|
||||
exports.create = function(req, res) {
|
||||
exports.create = function(req, res, next) {
|
||||
var user = new User(req.body);
|
||||
var message = null;
|
||||
|
||||
user.provider = 'local';
|
||||
user.save(function(err) {
|
||||
if (err) {
|
||||
switch(err.code){
|
||||
switch (err.code) {
|
||||
case 11000:
|
||||
case 11001:
|
||||
message = 'Username already exists';
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
message = 'Please fill all the required fields';
|
||||
}
|
||||
|
||||
@@ -98,4 +100,4 @@ exports.user = function(req, res, next, id) {
|
||||
req.profile = user;
|
||||
next();
|
||||
});
|
||||
};
|
||||
};
|
||||
@@ -1,8 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
var mongoose = require('mongoose'),
|
||||
config = require('../../config/config'),
|
||||
Schema = mongoose.Schema;
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
@@ -104,7 +106,7 @@ UserSchema.methods = {
|
||||
* @api public
|
||||
*/
|
||||
makeSalt: function() {
|
||||
return crypto.randomBytes(16).toString('base64');
|
||||
return crypto.randomBytes(16).toString('base64');
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -116,9 +118,9 @@ UserSchema.methods = {
|
||||
*/
|
||||
encryptPassword: function(password) {
|
||||
if (!password || !this.salt) return '';
|
||||
salt = new Buffer(this.salt, 'base64');
|
||||
var salt = new Buffer(this.salt, 'base64');
|
||||
return crypto.pbkdf2Sync(password, salt, 10000, 64).toString('base64');
|
||||
}
|
||||
};
|
||||
|
||||
mongoose.model('User', UserSchema);
|
||||
mongoose.model('User', UserSchema);
|
||||
@@ -27,4 +27,4 @@ script(type='text/javascript', src='/js/init.js')
|
||||
|
||||
if (process.env.NODE_ENV == 'development')
|
||||
//Livereload script rendered
|
||||
script(type='text/javascript', src='http://localhost:35729/livereload.js')
|
||||
script(type='text/javascript', src='http://' + req.host + ':35729/livereload.js')
|
||||
|
||||
29
bower.json
29
bower.json
@@ -1,17 +1,14 @@
|
||||
{
|
||||
"name": "mean",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"angular": "latest",
|
||||
"angular-resource": "latest",
|
||||
"angular-cookies": "latest",
|
||||
"angular-mocks": "latest",
|
||||
"angular-route": "latest",
|
||||
"bootstrap": "2.3.2",
|
||||
"angular-bootstrap": "0.7.0",
|
||||
"angular-ui-utils": "0.0.4"
|
||||
},
|
||||
"resolutions": {
|
||||
"angular": "1.2.6"
|
||||
}
|
||||
}
|
||||
"name": "mean",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"angular": "latest",
|
||||
"angular-resource": "latest",
|
||||
"angular-cookies": "latest",
|
||||
"angular-mocks": "latest",
|
||||
"angular-route": "latest",
|
||||
"bootstrap": "2.3.2",
|
||||
"angular-bootstrap": "0.7.0",
|
||||
"angular-ui-utils": "0.0.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('lodash');
|
||||
|
||||
// Load app configuration
|
||||
|
||||
2
config/env/all.js
vendored
2
config/env/all.js
vendored
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path'),
|
||||
rootPath = path.normalize(__dirname + '/../..');
|
||||
|
||||
|
||||
2
config/env/development.js
vendored
2
config/env/development.js
vendored
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
db: "mongodb://localhost/mean-dev",
|
||||
app: {
|
||||
|
||||
2
config/env/production.js
vendored
2
config/env/production.js
vendored
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
db: "mongodb://localhost/mean",
|
||||
app: {
|
||||
|
||||
2
config/env/test.js
vendored
2
config/env/test.js
vendored
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
db: "mongodb://localhost/mean-test",
|
||||
port: 3001,
|
||||
|
||||
27
config/env/travis.json
vendored
27
config/env/travis.json
vendored
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"db": "mongodb://localhost/mean-travis",
|
||||
"port": 3001,
|
||||
"app": {
|
||||
"name": "MEAN - A Modern Stack - Test on travis"
|
||||
},
|
||||
"facebook": {
|
||||
"clientID": "APP_ID",
|
||||
"clientSecret": "APP_SECRET",
|
||||
"callbackURL": "http://localhost:3000/auth/facebook/callback"
|
||||
},
|
||||
"twitter": {
|
||||
"clientID": "CONSUMER_KEY",
|
||||
"clientSecret": "CONSUMER_SECRET",
|
||||
"callbackURL": "http://localhost:3000/auth/twitter/callback"
|
||||
},
|
||||
"github": {
|
||||
"clientID": "APP_ID",
|
||||
"clientSecret": "APP_SECRET",
|
||||
"callbackURL": "http://localhost:3000/auth/github/callback"
|
||||
},
|
||||
"google": {
|
||||
"clientID": "APP_ID",
|
||||
"clientSecret": "APP_SECRET",
|
||||
"callbackURL": "http://localhost:3000/auth/google/callback"
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Generic require login routing middleware
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var mongoose = require('mongoose'),
|
||||
LocalStrategy = require('passport-local').Strategy,
|
||||
TwitterStrategy = require('passport-twitter').Strategy,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function(app, passport, auth) {
|
||||
//User Routes
|
||||
var users = require('../app/controllers/users');
|
||||
|
||||
14
gruntfile.js
14
gruntfile.js
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function(grunt) {
|
||||
// Project Configuration
|
||||
grunt.initConfig({
|
||||
@@ -10,7 +12,7 @@ module.exports = function(grunt) {
|
||||
},
|
||||
},
|
||||
js: {
|
||||
files: ['public/js/**', 'app/**/*.js'],
|
||||
files: ['gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**', 'test/**/*.js'],
|
||||
tasks: ['jshint'],
|
||||
options: {
|
||||
livereload: true,
|
||||
@@ -31,7 +33,10 @@ module.exports = function(grunt) {
|
||||
},
|
||||
jshint: {
|
||||
all: {
|
||||
src: ['gruntfile.js', 'public/js/**/*.js', 'test/mocha/**/*.js', 'test/karma/**/*.js', 'app/**/*.js']
|
||||
src: ['gruntfile.js', 'server.js', 'app/**/*.js', 'public/js/**', 'test/**/*.js'],
|
||||
options: {
|
||||
jshintrc: true
|
||||
}
|
||||
}
|
||||
},
|
||||
nodemon: {
|
||||
@@ -39,9 +44,8 @@ module.exports = function(grunt) {
|
||||
options: {
|
||||
file: 'server.js',
|
||||
args: [],
|
||||
ignoredFiles: ['README.md', 'node_modules/**', '.DS_Store'],
|
||||
ignoredFiles: ['public/**'],
|
||||
watchedExtensions: ['js'],
|
||||
watchedFolders: ['app', 'config'],
|
||||
debug: true,
|
||||
delayTime: 1,
|
||||
env: {
|
||||
@@ -92,4 +96,4 @@ module.exports = function(grunt) {
|
||||
|
||||
//Test task.
|
||||
grunt.registerTask('test', ['env:test', 'mochaTest', 'karma:unit']);
|
||||
};
|
||||
};
|
||||
@@ -10,7 +10,7 @@
|
||||
},
|
||||
"engines": {
|
||||
"node": "0.10.x",
|
||||
"npm": "1.2.x"
|
||||
"npm": "1.3.x"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node node_modules/grunt-cli/bin/grunt",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('mean', ['ngCookies', 'ngResource', 'ngRoute', 'ui.bootstrap', 'ui.route', 'mean.system', 'mean.articles']);
|
||||
|
||||
angular.module('mean.system', []);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
//Setting up route
|
||||
angular.module('mean').config(['$routeProvider',
|
||||
function($routeProvider) {
|
||||
@@ -26,6 +28,6 @@ angular.module('mean').config(['$routeProvider',
|
||||
//Setting HTML5 Location Mode
|
||||
angular.module('mean').config(['$locationProvider',
|
||||
function($locationProvider) {
|
||||
$locationProvider.hashPrefix("!");
|
||||
$locationProvider.hashPrefix('!');
|
||||
}
|
||||
]);
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('mean.articles').controller('ArticlesController', ['$scope', '$routeParams', '$location', 'Global', 'Articles', function ($scope, $routeParams, $location, Global, Articles) {
|
||||
$scope.global = Global;
|
||||
|
||||
@@ -7,19 +9,19 @@ angular.module('mean.articles').controller('ArticlesController', ['$scope', '$ro
|
||||
content: this.content
|
||||
});
|
||||
article.$save(function(response) {
|
||||
$location.path("articles/" + response._id);
|
||||
$location.path('articles/' + response._id);
|
||||
});
|
||||
|
||||
this.title = "";
|
||||
this.content = "";
|
||||
this.title = '';
|
||||
this.content = '';
|
||||
};
|
||||
|
||||
$scope.remove = function(article) {
|
||||
if (article) {
|
||||
article.$remove();
|
||||
article.$remove();
|
||||
|
||||
for (var i in $scope.articles) {
|
||||
if ($scope.articles[i] == article) {
|
||||
if ($scope.articles[i] === article) {
|
||||
$scope.articles.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('mean.system').controller('HeaderController', ['$scope', 'Global', function ($scope, Global) {
|
||||
$scope.global = Global;
|
||||
|
||||
$scope.menu = [{
|
||||
"title": "Articles",
|
||||
"link": "articles"
|
||||
'title': 'Articles',
|
||||
'link': 'articles'
|
||||
}, {
|
||||
"title": "Create New Article",
|
||||
"link": "articles/create"
|
||||
'title': 'Create New Article',
|
||||
'link': 'articles/create'
|
||||
}];
|
||||
|
||||
$scope.isCollapsed = false;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('mean.system').controller('IndexController', ['$scope', 'Global', function ($scope, Global) {
|
||||
$scope.global = Global;
|
||||
}]);
|
||||
@@ -0,0 +1 @@
|
||||
'use strict';
|
||||
@@ -0,0 +1 @@
|
||||
'use strict';
|
||||
@@ -1,6 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
angular.element(document).ready(function() {
|
||||
//Fixing facebook bug with redirect
|
||||
if (window.location.hash == "#_=_") window.location.hash = "#!";
|
||||
if (window.location.hash === '#_=_') window.location.hash = '#!';
|
||||
|
||||
//Then init the app
|
||||
angular.bootstrap(document, ['mean']);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
//Articles service used for articles REST endpoint
|
||||
angular.module('mean.articles').factory("Articles", ['$resource', function($resource) {
|
||||
angular.module('mean.articles').factory('Articles', ['$resource', function($resource) {
|
||||
return $resource('articles/:articleId', {
|
||||
articleId: '@_id'
|
||||
}, {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
//Global service for global variables
|
||||
angular.module('mean.system').factory("Global", [
|
||||
angular.module('mean.system').factory('Global', [
|
||||
function() {
|
||||
var _this = this;
|
||||
_this._data = {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
// Karma configuration
|
||||
// Generated on Sat Oct 05 2013 22:00:14 GMT+0700 (ICT)
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
'use strict';
|
||||
|
||||
(function() {
|
||||
// Articles Controller Spec
|
||||
describe('MEAN controllers', function() {
|
||||
|
||||
describe('ArticlesController', function() {
|
||||
|
||||
// The $resource service augments the response object with methods for updating and deleting the resource.
|
||||
// If we were to use the standard toEqual matcher, our tests would fail because the test values would not match
|
||||
// the responses exactly. To solve the problem, we use a newly-defined toEqualData Jasmine matcher.
|
||||
@@ -195,8 +193,6 @@
|
||||
expect(scope.articles.length).toBe(0);
|
||||
|
||||
}));
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}());
|
||||
@@ -1,15 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
describe('MEAN controllers', function() {
|
||||
|
||||
describe('HeaderController', function() {
|
||||
|
||||
// Load the controllers module
|
||||
beforeEach(module('mean'));
|
||||
|
||||
var scope,
|
||||
HeaderController;
|
||||
var scope, HeaderController;
|
||||
|
||||
beforeEach(inject(function($controller, $rootScope) {
|
||||
scope = $rootScope.$new();
|
||||
@@ -24,9 +21,6 @@
|
||||
expect(scope.global).toBeTruthy();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
@@ -1,15 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
describe('MEAN controllers', function() {
|
||||
|
||||
describe('IndexController', function() {
|
||||
|
||||
// Load the controllers module
|
||||
beforeEach(module('mean'));
|
||||
|
||||
var scope,
|
||||
IndexController;
|
||||
var scope, IndexController;
|
||||
|
||||
beforeEach(inject(function($controller, $rootScope) {
|
||||
scope = $rootScope.$new();
|
||||
@@ -24,9 +21,6 @@
|
||||
expect(scope.global).toBeTruthy();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
})();
|
||||
@@ -1,8 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
var should = require('should'),
|
||||
app = require('../../../server'),
|
||||
mongoose = require('mongoose'),
|
||||
User = mongoose.model('User'),
|
||||
Article = mongoose.model('Article');
|
||||
@@ -22,7 +23,7 @@ describe('<Unit Test>', function() {
|
||||
password: 'password'
|
||||
});
|
||||
|
||||
user.save(function(err) {
|
||||
user.save(function() {
|
||||
article = new Article({
|
||||
title: 'Article Title',
|
||||
content: 'Article Content',
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
var should = require('should'),
|
||||
app = require('../../../server'),
|
||||
mongoose = require('mongoose'),
|
||||
User = mongoose.model('User');
|
||||
|
||||
//Globals
|
||||
var user;
|
||||
var user, user2;
|
||||
|
||||
//The tests
|
||||
describe('<Unit Test>', function() {
|
||||
|
||||
Reference in New Issue
Block a user