Skip to content

Commit

Permalink
Merge branch 'release/v1.8.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenPioneer committed Aug 2, 2017
2 parents 7e13a84 + 8e6f99d commit fdce98c
Show file tree
Hide file tree
Showing 51 changed files with 11,874 additions and 156 deletions.
50 changes: 50 additions & 0 deletions .snyk
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.7.0
ignore: {}
# patches apply the minimum changes required to fix a vulnerability
patch:
'npm:ms:20170412':
- compression > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- mongoose > ms:
patched: '2017-05-23T01:35:11.139Z'
- mongo-throttle > mongoose > ms:
patched: '2017-05-23T01:35:11.139Z'
- express-status-monitor > socket.io > engine.io > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- socket.io > socket.io-adapter > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- express-status-monitor > socket.io > socket.io-adapter > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- socket.io > socket.io-client > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- express-status-monitor > socket.io > socket.io-client > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- express-status-monitor > socket.io > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- express-status-monitor > socket.io > socket.io-client > engine.io-client > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- buildreq > mongoose > ms:
patched: '2017-05-23T01:35:11.139Z'
- morgan > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- buildreq > compression > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- buildreq > helmet > connect > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- buildreq > helmet > connect > finalhandler > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- mongoose > mquery > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- mongo-throttle > mongoose > mquery > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- buildreq > mongoose > mquery > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- express-status-monitor > socket.io > socket.io-parser > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- socket.io > socket.io-adapter > socket.io-parser > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- express-status-monitor > socket.io > socket.io-adapter > socket.io-parser > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
- express-status-monitor > socket.io > socket.io-client > socket.io-parser > debug > ms:
patched: '2017-05-23T01:35:11.139Z'
36 changes: 36 additions & 0 deletions client/modules/chat/chat.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
;(function () {
'use strict'

angular
.module('app.chat', [])
.controller('ChatController', ChatController)

ChatController.$inject = ['$http', '$stateParams', 'logger', '$location', 'UserFactory', 'MeanSocket']
/* @ngInject */
function ChatController ($http, $stateParams, logger, $location, UserFactory, MeanSocket) {
var vm = this
vm.title = 'chat'
vm.chat = {}
vm.UserFactory = UserFactory
activate()

vm.messages = []
MeanSocket.on('message', function (msg) {
var message = _.clone(msg)
message.date = Date.now()
vm.messages.unshift(message)
})
vm.chat = function () {
if (!vm.message) return
MeanSocket.emit('message', {
message: vm.message,
user: vm.UserFactory.user.profile.name || 'Unknown'
})
vm.message = ''
}

function activate () {
logger.info('Activated Chat View')
}
}
})()
4 changes: 4 additions & 0 deletions client/modules/chat/chat.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
;(function () {
'use strict'
angular.module('app.chat', ['app.core'])
})()
27 changes: 27 additions & 0 deletions client/modules/chat/chat.routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
;(function () {
'use strict'

angular
.module('app.chat')
.run(appRun)

appRun.$inject = ['routerHelper']
/* @ngInject */
function appRun (routerHelper) {
routerHelper.configureStates(getStates())
}

function getStates () {
return [
{
state: 'chat',
config: {
url: '/chat',
templateUrl: 'modules/chat/chat.view.html',
controller: 'ChatController',
controllerAs: 'vm'
}
}
]
}
})()
16 changes: 16 additions & 0 deletions client/modules/chat/chat.view.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="container" ng-init="vm.list()">
<div class="row">
<div class="col-sm-12 chat-header text-center">
<h1 class="chat-title">MeanStackJS Chatroom</h1>
</div>
</div>
<div class="row">
<div class="input-group">
<input ng-model="vm.message" ng-enter="vm.chat()" type="text" class="form-control" placeholder="Enter Message Here...">
<span class="input-group-btn">
<button ng-click="vm.chat()" class="btn btn-primary" type="button">Send</button>
</span>
</div>
<p ng-repeat="chat in vm.messages| limitTo:10">{{chat.message}} - by {{chat.user}} on {{chat.date|date:'medium'}}</p>
</div>
</div>
3 changes: 2 additions & 1 deletion client/modules/client.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'app.footer',
'app.user',
'app.blog',
'app.admin' // DONT REMOVE - APP GENERATOR
'app.admin',
'app.chat' // DONT REMOVE - APP GENERATOR
])
})()
35 changes: 35 additions & 0 deletions client/modules/core/storage.factory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;(function () {
'use strict'

angular
.module('app.core')
.factory('$localStorage', localStorage)

localStorage.$inject = ['$window']

function localStorage ($window) {
return {
set: function (key, value) {
$window.localStorage[key] = value
},
get: function (key, defaultValue) {
return $window.localStorage[key] || false
},
setObject: function (key, value) {
$window.localStorage[key] = JSON.stringify(value)
},
getObject: function (key) {
if ($window.localStorage[key] !== undefined) {
return JSON.parse($window.localStorage[key] || false)
}
return false
},
remove: function (key) {
$window.localStorage.removeItem(key)
},
clear: function () {
$window.localStorage.clear()
}
}
}
}())
2 changes: 1 addition & 1 deletion client/modules/header/header.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

$rootScope.$on('profileUpdated', function () {
// if you want to do anything extra
// vm.UserFactory = _.merge(vm.UserFactory, UserFactory)
// vm.UserFactory = _.assign(vm.UserFactory, UserFactory)
})
$rootScope.$on('loggedin', function () {
// if you want to do anything extra
Expand Down
4 changes: 2 additions & 2 deletions client/modules/header/header.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ describe('HEADER Testing', function () {
beforeEach(inject(function (_$httpBackend_, $controller, $rootScope, _UserFactory_) {
UserFactory = _UserFactory_
$httpBackend = _$httpBackend_
$httpBackend.whenGET(/\/api\/user\/logout\?noCache=\d+/)
$httpBackend.when('POST', /\/api\/user\/logout/)
.respond(200, '')
$httpBackend.whenGET(/\/api\/user\/authenticate\?noCache=\d+/)
$httpBackend.when('GET', /\/api\/user\/authenticate\?noCache=\d+/)
.respond(200, authResponse)
$httpBackend.when('GET', /\/api\/seo\/*/)
.respond(200, {})
Expand Down
2 changes: 2 additions & 0 deletions client/modules/header/header.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<li><a href="/blog/list">List Blog</a></li>
<li><a href="/blog/create">Create Blog</a></li>
<li role="separator" class="divider"></li>
<li><a href="/chat">Chat</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">More Coming Soon</a></li>
</ul>
</li>
Expand Down
22 changes: 8 additions & 14 deletions client/modules/user/user.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,12 @@
$location.url(data.redirect)
}
$rootScope.$emit('loggedin')
return ({
error: false
})
}

UserClass.prototype.onIdFail = function (error) {
logger.error(error.data.message, error, 'Login/Signup')
logger.error(error.data.message, error, 'User Management')
$rootScope.$emit('loginfailed')
$rootScope.$emit('registerfailed')
return ({
error: true
})
}

UserClass.prototype.updateProfile = function (data, response) {
Expand Down Expand Up @@ -154,12 +148,12 @@
$http.post('/api/user/reset/' + vm.resetToken, {
password: vm.resetCred.password,
confirmPassword: vm.resetCred.confirmPassword
}).then(self.onIdentity.bind(this), self.onIdFail.bind(this))
.then(function (response) {
if (!response.error) {
logger.success('Password successfully Reset', response)
}
})
}).then(function (success) {
self.onIdentity.bind(self)(success.data)
logger.success('Password reset successfully', success.data)
}, function (error) {
self.onIdFail.bind(self)(error)
})
}

UserClass.prototype.forgot = function (vm) {
Expand All @@ -174,7 +168,7 @@
}

UserClass.prototype.logout = function (vm) {
$http.get('/api/user/logout').then(function (data) {
$http.post('/api/user/logout').then(function (data) {
localStorage.removeItem('JWT')
$rootScope.$emit('logout')
// ANGULAR WAY
Expand Down
2 changes: 1 addition & 1 deletion client/modules/user/user.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('USER Testing', function () {
.respond(200, '')
$httpBackend.when('GET', /modules\/index\/[\d\w]+\.view\.html\?noCache=\d+/)
.respond(200, '')
$httpBackend.when('GET', /\/api\/user\/logout\?noCache=\d+/)
$httpBackend.when('POST', /\/api\/user\/logout/)
.respond(200, '')
// Constructor contains http.get
UserFactory = _UserFactory_
Expand Down
5 changes: 5 additions & 0 deletions commands/blank/server/socket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var <%= name %> = require('./<%= name %>.controller.js')

module.exports = function (io, socket) {
// Socket
}
1 change: 0 additions & 1 deletion commands/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@ function ask () {
break
case 'Exit':
process.exit()
break
}
})
}
Expand Down
9 changes: 8 additions & 1 deletion commands/template/server/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports.post<%= Name %> = post<%= Name %>
exports.put<%= Name %> = put<%= Name %>
exports.get<%= Name %>ById = get<%= Name %>ById
exports.param<%= Name %> = param<%= Name %>
exports.on<%= Name %> = on<%= Name %>

var auto = require('run-auto')
var mongoose = require('mongoose')
Expand Down Expand Up @@ -49,7 +50,7 @@ function post<%= Name %> (req, res, next) {
}

function put<%= Name %> (req, res, next) {
req.<%= name %> = _.merge(req.<%= name %>, req.body)
req.<%= name %> = _.assign(req.<%= name %>, req.body)
req.<%= name %>.save(function (error) {
if (error) return next(error)
return res.status(200).send(req.<%= name %>)
Expand Down Expand Up @@ -85,3 +86,9 @@ function param<%= Name %> (req, res, next, id) {
next()
})
}

function on<%= Name %> (io, socket) {
return function (msg) {
io.emit('<%= name %>', msg)
}
}
5 changes: 5 additions & 0 deletions commands/template/server/socket.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var <%= name %> = require('./<%= name %>.controller.js')

module.exports = function (io, socket) {
socket.on('<%= name %>', <%= name %>.on<%= Name %>(io, socket))
}
1 change: 1 addition & 0 deletions configs/environments/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
},
https: {
active: false,
redirect: true,
port: process.env.HTTPSPORT || 3043,
key: './configs/certificates/keyExample.pem',
cert: './configs/certificates/certExample.pem'
Expand Down
1 change: 1 addition & 0 deletions configs/environments/nightwatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
},
https: {
active: false,
redirect: true,
port: process.env.HTTPSPORT || 3043,
key: './configs/certificates/keyExample.pem',
cert: './configs/certificates/certExample.pem'
Expand Down
1 change: 1 addition & 0 deletions configs/environments/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
},
https: {
active: false,
redirect: true,
port: process.env.HTTPSPORT || 3043,
key: './configs/certificates/keyExample.pem',
cert: './configs/certificates/certExample.pem'
Expand Down
1 change: 1 addition & 0 deletions configs/environments/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
},
https: {
active: false,
redirect: true,
port: process.env.HTTPSPORT || 3043,
key: './configs/certificates/keyExample.pem',
cert: './configs/certificates/certExample.pem'
Expand Down
2 changes: 1 addition & 1 deletion configs/seo.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = {
tags: ['Add', 'Tags', 'To Blog', 'Mean Stack JS']
}
self.models.blog.findOne({_id: data.params.id}).populate('user').then(function (blog) {
data.blog = _.merge(data.blog, blog)
data.blog = _.assign(data.blog, blog)
cb(null, data)
}).catch(function (error) {
cb(error)
Expand Down
Loading

0 comments on commit fdce98c

Please sign in to comment.