From 8f47e2d29a2a0b50102eef7ccf0d261e205333e5 Mon Sep 17 00:00:00 2001 From: Jack Hu Date: Fri, 14 Jul 2017 18:07:22 +0800 Subject: [PATCH] fix mongodb connect --- coverage/index.html | 276 +++---- coverage/index.js.html | 88 +-- .../api/article/article.controller.js.html | 744 +++++++++--------- coverage/server/api/article/index.html | 40 +- coverage/server/api/article/index.js.html | 40 +- .../api/comment/comment.controller.js.html | 236 +++--- coverage/server/api/comment/index.html | 40 +- coverage/server/api/comment/index.js.html | 20 +- coverage/server/api/logs/index.html | 40 +- coverage/server/api/logs/index.js.html | 12 +- .../server/api/logs/logs.controller.js.html | 70 +- coverage/server/api/mobile/index.html | 36 +- coverage/server/api/mobile/index.js.html | 10 +- .../api/mobile/mobile.controller.js.html | 38 +- coverage/server/api/tags/index.html | 40 +- coverage/server/api/tags/index.js.html | 28 +- .../server/api/tags/tags.controller.js.html | 364 ++++----- coverage/server/api/users/index.html | 40 +- coverage/server/api/users/index.js.html | 28 +- .../server/api/users/user.controller.js.html | 468 +++++------ coverage/server/app.js.html | 64 +- coverage/server/auth/auth.service.js.html | 104 +-- coverage/server/auth/github/index.html | 2 +- coverage/server/auth/github/index.js.html | 16 +- coverage/server/auth/github/passport.js.html | 14 +- coverage/server/auth/index.html | 38 +- coverage/server/auth/index.js.html | 32 +- coverage/server/auth/local/index.html | 60 +- coverage/server/auth/local/index.js.html | 80 +- coverage/server/auth/local/passport.js.html | 92 +-- coverage/server/auth/qq/index.html | 2 +- coverage/server/auth/qq/index.js.html | 16 +- coverage/server/auth/qq/passport.js.html | 14 +- coverage/server/auth/weibo/index.html | 2 +- coverage/server/auth/weibo/index.js.html | 16 +- coverage/server/auth/weibo/passport.js.html | 14 +- coverage/server/config/env/index.html | 10 +- coverage/server/config/env/index.js.html | 26 +- coverage/server/config/env/test.js.html | 6 +- coverage/server/config/index.html | 2 +- coverage/server/config/koa.js.html | 42 +- coverage/server/connect.js.html | 24 +- coverage/server/index.html | 38 +- coverage/server/model/article.model.js.html | 32 +- coverage/server/model/comment.model.js.html | 12 +- coverage/server/model/index.html | 54 +- coverage/server/model/logs.model.js.html | 12 +- .../server/model/tag.category.model.js.html | 12 +- coverage/server/model/tag.model.js.html | 12 +- coverage/server/model/user.model.js.html | 128 +-- coverage/server/routes.js.html | 38 +- coverage/server/util/debug/index.html | 2 +- coverage/server/util/debug/index.js.html | 8 +- coverage/server/util/error/index.html | 40 +- coverage/server/util/error/index.js.html | 70 +- coverage/server/util/logs/index.html | 2 +- coverage/server/util/logs/index.js.html | 12 +- coverage/server/util/qiniu/index.html | 40 +- coverage/server/util/qiniu/index.js.html | 178 ++--- coverage/server/util/redis/index.html | 2 +- coverage/server/util/redis/index.js.html | 16 +- coverage/server/util/tools/index.html | 40 +- coverage/server/util/tools/index.js.html | 94 +-- logs/production-error.log.0 | 0 logs/test-error.log.0 | 12 +- logs/test-error.log.1 | 20 +- logs/test-error.log.2 | 36 +- logs/test-error.log.3 | 60 +- logs/test-error.log.4 | 44 +- logs/test-error.log.5 | 28 +- logs/test-error.log.6 | 20 + package-lock.json | 2 +- package.json | 2 +- server/config/env/development.js | 2 +- server/config/env/production.js | 2 +- server/config/env/test.js | 2 +- server/connect.js | 1 - 77 files changed, 2205 insertions(+), 2202 deletions(-) create mode 100644 logs/production-error.log.0 diff --git a/coverage/index.html b/coverage/index.html index 58f502e..1d862a7 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -20,28 +20,28 @@

- 84.42% + 36.83% Statements - 894/1059 + 390/1059
- 67.46% + 13.1% Branches - 255/378 + 49/374
- 89.44% + 41.61% Functions - 144/161 + 67/161
- 85.25% + 36.84% Lines - 884/1037 + 382/1037
-
+
@@ -60,106 +60,106 @@

- - - + + + + + - - - - - + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - + + + + + + - - - - + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + @@ -176,16 +176,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -232,8 +232,8 @@

- - + + @@ -254,16 +254,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -280,16 +280,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -306,16 +306,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -332,16 +332,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -350,7 +350,7 @@

diff --git a/coverage/index.js.html b/coverage/index.js.html index 3c8407b..ee59f6d 100644 --- a/coverage/index.js.html +++ b/coverage/index.js.html @@ -20,28 +20,28 @@

- 100% + 15.79% Statements - 19/19 + 3/19
- 80% + 0% Branches - 8/10 + 0/10
- 100% + 0% Functions - 3/3 + 0/3
- 100% + 15.79% Lines - 19/19 + 3/19
-
+
server
92%46/50
86%43/5037.5%3/8 50%4/883.33%5/692%46/503/686%43/50
server/api/article
94.5%206/21885%51/60100%28/2894.5%206/218server/api/article
20.18%44/2180%0/6046.43%13/2820.18%44/218
server/api/comment
89.19%66/74100%14/1490%9/1089.19%66/74server/api/comment
25.68%19/740%0/1450%5/1025.68%19/74
server/api/logs
100%19/19100%8/8100%2/2100%19/19server/api/logs
42.11%8/190%0/850%1/242.11%8/19
server/api/mobile
90%9/10server/api/mobile
60%6/100%0/2 50% 1/2100%2/290%9/1060%6/10
server/api/tags
93.52%101/10890%18/20100%18/1893.52%101/108server/api/tags
24.07%26/1080%0/2050%9/1824.07%26/108
server/api/users
92.7%127/13789.04%65/7394.44%17/1892.7%127/137server/api/users
19.71%27/1370%0/7350%9/1819.71%27/137
server/auth
83.64%46/5543.75%7/1692.86%13/1487.5%42/48server/auth
63.64%35/556.25%1/1657.14%8/1464.58%31/48
server/auth/local
78.43%40/5153.85%14/26100%10/1079.17%38/48server/auth/local
27.45%14/510%0/2650%5/1027.08%13/48
100% 9/993.75%45/4893.18%41/44 100% 0/0 100%
server/model
90.63%58/6466.67%8/1275%9/1293.44%57/61server/model
60.94%39/640%0/120%0/1263.93%39/61
server/util/error
100%14/1475%6/8100%4/4100%14/14server/util/error
28.57%4/140%0/850%2/428.57%4/14
server/util/qiniu
100%51/51100%2/2100%13/13100%51/51server/util/qiniu
58.82%30/510%0/20%0/1358.82%30/51
server/util/tools
100%19/1980%8/10100%3/3100%19/19server/util/tools
15.79%3/190%0/100%0/315.79%3/19
1 2 @@ -78,60 +78,60 @@

1x   1x -2x -2x -2x -2x -2x -18x +  +  +  +  +  +    -2x +      1x -2x -2x -2x -1x -1x -1x +  +  +  +  +  +    -1x -1x +  +        -2x +     

"use strict"
  
 const _ = require('lodash')
 //生成随机字符串
-exports.randomString = function (len) {
-	len = len || 12
-	const $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'    /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
-	const maxPos = $chars.length
-	let pwd = ''
-  for (let i = 0; i < len; i++) {
-    pwd += $chars.charAt(Math.floor(Math.random() * maxPos))
+exports.randomString = function (len) {
+	len = len || 12
+	const $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'    /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
+	const maxPos = $chars.length
+	let pwd = ''
+  for (let i = 0; i < len; i++) {
+    pwd += $chars.charAt(Math.floor(Math.random() * maxPos))
   }
- return pwd
+ return pwd
 }
 //从markdown中提取图片
-exports.extractImage = function (content) {
-  let results = []
-	const images = content.match(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g)
-	if(_.isArray(images) && images.length > 0){
-		for(let i = 0,j = images.length;i<j;i++){
-			var url = images[i].replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/,function ($1,m1,m2,m3,m4) {
-				return m4 || ''
+exports.extractImage = function (content) {
+  let results = []
+	const images = content.match(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g)
+	if(_.isArray(images) && images.length > 0){
+		for(let i = 0,j = images.length;i<j;i++){
+			var url = images[i].replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/,function ($1,m1,m2,m3,m4) {
+				return m4 || ''
 			})
-			Eif(url !== ''){
-				results.push({url:url})
+			if(url !== ''){
+				results.push({url:url})
 			}
 		}
 	}
-	return results
+	return results
 }
  
@@ -139,7 +139,7 @@

diff --git a/coverage/server/api/article/article.controller.js.html b/coverage/server/api/article/article.controller.js.html index 3a5f7e3..9fcf419 100644 --- a/coverage/server/api/article/article.controller.js.html +++ b/coverage/server/api/article/article.controller.js.html @@ -20,28 +20,28 @@

- 93.97% + 12.56% Statements - 187/199 + 25/199
- 85% + 0% Branches - 51/60 + 0/60
- 100% + 46.43% Functions - 28/28 + 13/28
- 93.97% + 12.56% Lines - 187/199 + 25/199
-
+
1 2 @@ -365,122 +365,121 @@

320 321

    -8x -8x -8x -8x -8x -8x -8x -8x -8x -8x -8x -8x -  -  -28x -4x -4x -  -4x -1x -3x -1x -  -4x 2x 2x -  -  2x 2x 2x -1x -1x -  -1x -  -  -  -26x 2x 2x 2x -  2x 2x 2x -1x -  -2x 2x     +6x +  +  +  +  +  +  +    +  +  +    -2x -2x -2x     +  +  +  +    +        -26x -2x -2x -2x -1x -1x -1x +6x +  +  +    -1x +  +  +  +    +  +      -27x -3x -3x -1x   -3x -3x   -3x -1x -2x -1x +  +  +  +  +  +  +  +  +  +6x +  +  +  +  +  +  +  +  +    -3x -2x -2x   +6x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +    -1x -1x -1x -1x   -1x -1x -1x -1x +  +  +  +      +  +  +    +      -25x -1x -1x -1x -1x -1x   +6x +  +  +  +      +        @@ -489,20 +488,20 @@

      -26x -2x -2x -1x -1x   -1x -1x -1x -1x -1x +6x +  +  +  +      +  +  +  +    +        @@ -512,174 +511,175 @@

      -26x -2x -1x -1x   -1x +6x +  +  +    -1x -1x -1x +      +  +    -1x -1x -1x -1x -1x +      +  +  +  +    +      -26x -2x -2x   -1x -1x +6x +  +    -2x -2x -2x -2x +  +      +  +  +    +      -26x -2x -2x -2x -2x -2x -2x -2x   -1x -1x +6x +  +  +  +  +  +  +  +  +  +    -2x -2x +  +            -2x -2x +  +              -25x -1x -1x +6x +  +        -1x -1x -1x -1x -1x -1x -1x +  +  +  +  +  +  +            -26x -2x -2x +6x +  +    -2x -2x -2x +  +  +    -1x -1x -1x +  +  +      -2x -2x +  +    -2x -1x -1x +  +  +    -1x -1x +  +    -2x -2x -2x -2x -2x -2x +  +  +  +  +  +            -26x +6x   -2x -2x -1x -1x -1x -1x -1x -1x -5x +  +  +  +  +  +  +  +  +            -1x +    -1x -1x -1x -1x +  +  +  +        -26x -2x -2x -2x +6x +  +  +      -2x -1x +  +      -2x -1x -1x -1x +  +  +  +    -1x -1x -1x +  +  +      -2x -2x -2x -2x -2x +  +  +  +  +        @@ -699,105 +699,105 @@

const redis = require('../../util/redis')   //添加博客 -exports.addArticle = async (ctx,next) => { - const content = ctx.request.body.content - const title = ctx.request.body.title +exports.addArticle = async (ctx,next) => { + const content = ctx.request.body.content + const title = ctx.request.body.title let error_msg - if(!title){ - error_msg = '标题不能为空.' - }else if(!content){ - error_msg = '内容不能为空.' + if(!title){ + error_msg = '标题不能为空.' + }else if(!content){ + error_msg = '内容不能为空.' } - if(error_msg){ - ctx.status = 422 - return ctx.body = {error_msg:error_msg} + if(error_msg){ + ctx.status = 422 + return ctx.body = {error_msg:error_msg} } //将图片提取存入images,缩略图调用 - ctx.request.body.images = tools.extractImage(content) - try{ - const result = await Article.create(ctx.request.body) - ctx.status = 200 - ctx.body = {success: true,article_id:result._id} + ctx.request.body.images = tools.extractImage(content) + try{ + const result = await Article.create(ctx.request.body) + ctx.status = 200 + ctx.body = {success: true,article_id:result._id} }catch(err){ - ctx.throw(err) + ctx.throw(err) } } //后台获取博客列表 -exports.getArticleList = async (ctx,next)=>{ - let currentPage = (parseInt(ctx.query.currentPage) > 0)?parseInt(ctx.query.currentPage):1 - let itemsPerPage = (parseInt(ctx.query.itemsPerPage) > 0)?parseInt(ctx.query.itemsPerPage):10 - let startRow = (currentPage - 1) * itemsPerPage +exports.getArticleList = async (ctx,next)=>{ + let currentPage = (parseInt(ctx.query.currentPage) > 0)?parseInt(ctx.query.currentPage):1 + let itemsPerPage = (parseInt(ctx.query.itemsPerPage) > 0)?parseInt(ctx.query.itemsPerPage):10 + let startRow = (currentPage - 1) * itemsPerPage   - let sortName = String(ctx.query.sortName) || 'publish_time' - let sortOrder = ctx.query.sortOrder - if(sortOrder === 'false'){ - sortName = '-' + sortName + let sortName = String(ctx.query.sortName) || 'publish_time' + let sortOrder = ctx.query.sortOrder + if(sortOrder === 'false'){ + sortName = '-' + sortName } - try{ - const ArticleList = await Article.find() + try{ + const ArticleList = await Article.find() .skip(startRow) .limit(itemsPerPage) .sort(sortName) .exec() - const count = await Article.count() - ctx.status = 200 - ctx.body = { data: ArticleList, count:count } + const count = await Article.count() + ctx.status = 200 + ctx.body = { data: ArticleList, count:count } }catch(err){ ctx.throw(err) } }   //删除博客(连同这篇文章的评论一起删除.) -exports.destroy = async (ctx,next)=>{ - const id = ctx.params.id - try{ - await Article.findByIdAndRemove(id) - await Comment.remove({aid:id}) - ctx.status = 200 - ctx.body = {success: true} +exports.destroy = async (ctx,next)=>{ + const id = ctx.params.id + try{ + await Article.findByIdAndRemove(id) + await Comment.remove({aid:id}) + ctx.status = 200 + ctx.body = {success: true} }catch(err){ - ctx.throw(err) + ctx.throw(err) } } //更新博客 -exports.updateArticle = async (ctx,next)=>{ - const id = ctx.params.id - if(ctx.request.body._id){ - delete ctx.request.body._id +exports.updateArticle = async (ctx,next)=>{ + const id = ctx.params.id + if(ctx.request.body._id){ + delete ctx.request.body._id } - const content = ctx.request.body.content - const title = ctx.request.body.title + const content = ctx.request.body.content + const title = ctx.request.body.title let error_msg - if(!title){ - error_msg = '标题不能为空.' - }else if(!content){ - error_msg = '内容不能为空.' + if(!title){ + error_msg = '标题不能为空.' + }else if(!content){ + error_msg = '内容不能为空.' } - if(error_msg){ - ctx.status = 422 - return ctx.body = {error_msg:error_msg} + if(error_msg){ + ctx.status = 422 + return ctx.body = {error_msg:error_msg} } //将图片提取存入images,缩略图调用 - ctx.request.body.images = tools.extractImage(content) - ctx.request.body.updated = new Date() - Eif(ctx.request.body.isRePub){ - ctx.request.body.publish_time = new Date() + ctx.request.body.images = tools.extractImage(content) + ctx.request.body.updated = new Date() + if(ctx.request.body.isRePub){ + ctx.request.body.publish_time = new Date() } - try{ - const article = await Article.findByIdAndUpdate(id,ctx.request.body,{new:true}) - ctx.status = 200 - ctx.body = {success:true,article_id:article._id} + try{ + const article = await Article.findByIdAndUpdate(id,ctx.request.body,{new:true}) + ctx.status = 200 + ctx.body = {success:true,article_id:article._id} }catch(err){ ctx.throw(err) } } //获取单篇博客 -exports.getArticle = async (ctx,next)=>{ - const id = ctx.params.id - try{ - const article = await Article.findOne({_id:id}).populate('tags').exec() - ctx.status = 200 - ctx.body = {data:article} +exports.getArticle = async (ctx,next)=>{ + const id = ctx.params.id + try{ + const article = await Article.findOne({_id:id}).populate('tags').exec() + ctx.status = 200 + ctx.body = {data:article} }catch(err){ ctx.throw(err) } @@ -809,17 +809,17 @@

files: ctx.req.files } */ -exports.uploadImage = async (ctx,next)=>{ - let file = ctx.req.file - if(!file){ - ctx.status = 422 - return ctx.body = {error_msg:'缺少文件参数.'} +exports.uploadImage = async (ctx,next)=>{ + let file = ctx.req.file + if(!file){ + ctx.status = 422 + return ctx.body = {error_msg:'缺少文件参数.'} } - const fileName = new Date().getTime() + file.originalname - try{ - const result = await qiniuHelper.upload(file.path,'blog/article/' + fileName) - ctx.status = 200 - ctx.body = {success:true,img_url:result.url} + const fileName = new Date().getTime() + file.originalname + try{ + const result = await qiniuHelper.upload(file.path,'blog/article/' + fileName) + ctx.status = 200 + ctx.body = {success:true,img_url:result.url} }catch(err){ ctx.throw(err) } @@ -832,174 +832,174 @@

* key: 'blog/article/1439948192797e48eb2b310f91bda45273dbbfc1a8e6e.png' * url: 'http://upload.jackhu.top/blog/article/1439948192797e48eb2b310f91bda45273dbbfc1a8e6e.png' */ -exports.fetchImage = async (ctx,next)=>{ - if(!ctx.request.body.url){ - ctx.status = 422 - return ctx.body = {error_msg:'url地址不能为空.'} +exports.fetchImage = async (ctx,next)=>{ + if(!ctx.request.body.url){ + ctx.status = 422 + return ctx.body = {error_msg:'url地址不能为空.'} } - let urlLink = URL.parse(ctx.request.body.url) + let urlLink = URL.parse(ctx.request.body.url) let fileName - Eif(urlLink.pathname.indexOf('/') !== -1){ - let links = urlLink.pathname.split('/') - fileName = links[links.length - 1] + if(urlLink.pathname.indexOf('/') !== -1){ + let links = urlLink.pathname.split('/') + fileName = links[links.length - 1] }else{ fileName = urlLink.pathname } - fileName = new Date().getTime() + fileName - try{ - const result = await qiniuHelper.fetch(ctx.request.body.url,'blog/article/' + fileName) - ctx.status = 200 - ctx.body = {success:true,img_url:result.url} + fileName = new Date().getTime() + fileName + try{ + const result = await qiniuHelper.fetch(ctx.request.body.url,'blog/article/' + fileName) + ctx.status = 200 + ctx.body = {success:true,img_url:result.url} }catch(err){ ctx.throw(err) } } //前台获取博客数量 -exports.getFrontArticleCount = async (ctx,next)=>{ - let condition = {status:{$gt:0}} - if(ctx.query.tagId){ +exports.getFrontArticleCount = async (ctx,next)=>{ + let condition = {status:{$gt:0}} + if(ctx.query.tagId){ //tagId = new mongoose.Types.ObjectId(tagId) - const tagId = String(ctx.query.tagId) - condition = _.defaults(condition,{ tags: { $elemMatch: { $eq:tagId } } }) + const tagId = String(ctx.query.tagId) + condition = _.defaults(condition,{ tags: { $elemMatch: { $eq:tagId } } }) } - try{ - const count = await Article.count(condition) - ctx.status = 200 - ctx.body = {success:true,count:count} + try{ + const count = await Article.count(condition) + ctx.status = 200 + ctx.body = {success:true,count:count} }catch(err){ ctx.throw(err) } } //前台获取博客列表 -exports.getFrontArticleList = async (ctx,next)=>{ - let currentPage = (parseInt(ctx.query.currentPage) > 0)?parseInt(ctx.query.currentPage):1 - let itemsPerPage = (parseInt(ctx.query.itemsPerPage) > 0)?parseInt(ctx.query.itemsPerPage):10 - let startRow = (currentPage - 1) * itemsPerPage - let sort = String(ctx.query.sortName) || 'publish_time' - sort = '-' + sort - let condition = {status:{$gt:0}} - if(ctx.query.tagId){ +exports.getFrontArticleList = async (ctx,next)=>{ + let currentPage = (parseInt(ctx.query.currentPage) > 0)?parseInt(ctx.query.currentPage):1 + let itemsPerPage = (parseInt(ctx.query.itemsPerPage) > 0)?parseInt(ctx.query.itemsPerPage):10 + let startRow = (currentPage - 1) * itemsPerPage + let sort = String(ctx.query.sortName) || 'publish_time' + sort = '-' + sort + let condition = {status:{$gt:0}} + if(ctx.query.tagId){ //tagId = new mongoose.Types.ObjectId(tagId) - const tagId = String(ctx.query.tagId) - condition = _.defaults(condition,{ tags: { $elemMatch: { $eq:tagId } } }) + const tagId = String(ctx.query.tagId) + condition = _.defaults(condition,{ tags: { $elemMatch: { $eq:tagId } } }) } - try{ - const list = await Article.find(condition) + try{ + const list = await Article.find(condition) .select('title images visit_count comment_count like_count publish_time') .skip(startRow) .limit(itemsPerPage) .sort(sort) .exec() - ctx.status = 200 - ctx.body = {data:list} + ctx.status = 200 + ctx.body = {data:list} }catch(err){ ctx.throw(err) } }   //前台获取文章 -exports.getFrontArticle = async (ctx,next)=>{ - const id = ctx.params.id - const md = new MarkdownIt({ +exports.getFrontArticle = async (ctx,next)=>{ + const id = ctx.params.id + const md = new MarkdownIt({ html:true //启用html标记转换 }) //每次获取之后,将阅读数加1 - try{ - let result = await Article.findById(id,'-images') - result.content = md.render(result.content) - result.visit_count++ - await Article.findByIdAndUpdate(id,{$inc:{visit_count:1}}) - ctx.status = 200 - ctx.body = {data:result.info} + try{ + let result = await Article.findById(id,'-images') + result.content = md.render(result.content) + result.visit_count++ + await Article.findByIdAndUpdate(id,{$inc:{visit_count:1}}) + ctx.status = 200 + ctx.body = {data:result.info} }catch(err){ ctx.throw(err) } } //前台获取上一篇和下一篇 -exports.getPrenext = async (ctx,next)=>{ - const id = ctx.params.id - const sort = String(ctx.query.sortName) || 'publish_time' +exports.getPrenext = async (ctx,next)=>{ + const id = ctx.params.id + const sort = String(ctx.query.sortName) || 'publish_time' let preCondition,nextCondition - preCondition = {status:{$gt:0}} - nextCondition = {status:{$gt:0}} - if(ctx.query.tagId){ + preCondition = {status:{$gt:0}} + nextCondition = {status:{$gt:0}} + if(ctx.query.tagId){ //tagId = new mongoose.Types.ObjectId(tagId) - const tagId = String(ctx.query.tagId) - preCondition = _.defaults(preCondition,{ tags: { $elemMatch: { $eq:tagId } } }) - nextCondition = _.defaults(nextCondition,{ tags: { $elemMatch: { $eq:tagId } } }) + const tagId = String(ctx.query.tagId) + preCondition = _.defaults(preCondition,{ tags: { $elemMatch: { $eq:tagId } } }) + nextCondition = _.defaults(nextCondition,{ tags: { $elemMatch: { $eq:tagId } } }) }   - try{ - const article = await Article.findById(id) + try{ + const article = await Article.findById(id) //先获取文章, - if(sort === 'visit_count'){ - preCondition = _.defaults(preCondition,{'_id':{$ne:id},'visit_count':{'$lte':article.visit_count}}) - nextCondition = _.defaults(nextCondition,{'_id':{$ne:id},'visit_count':{'$gte':article.visit_count}}) + if(sort === 'visit_count'){ + preCondition = _.defaults(preCondition,{'_id':{$ne:id},'visit_count':{'$lte':article.visit_count}}) + nextCondition = _.defaults(nextCondition,{'_id':{$ne:id},'visit_count':{'$gte':article.visit_count}}) }else{ - preCondition = _.defaults(preCondition,{'_id':{$ne:id},'publish_time':{'$lte':article.publish_time}}) - nextCondition = _.defaults(nextCondition,{'_id':{$ne:id},'publish_time':{'$gte':article.publish_time}}) + preCondition = _.defaults(preCondition,{'_id':{$ne:id},'publish_time':{'$lte':article.publish_time}}) + nextCondition = _.defaults(nextCondition,{'_id':{$ne:id},'publish_time':{'$gte':article.publish_time}}) } - const preResult = await Article.find(preCondition).select('title').limit(1).sort('-' + sort) - const nextResult = await Article.find(nextCondition).select('title').limit(1).sort(sort) - const prev = preResult[0] || {} - const next = nextResult[0] || {} - ctx.status = 200 - ctx.body = {data:{'next':next,'prev':prev}} + const preResult = await Article.find(preCondition).select('title').limit(1).sort('-' + sort) + const nextResult = await Article.find(nextCondition).select('title').limit(1).sort(sort) + const prev = preResult[0] || {} + const next = nextResult[0] || {} + ctx.status = 200 + ctx.body = {data:{'next':next,'prev':prev}} }catch(err){ ctx.throw(err) } } //获取首页图片 -exports.getIndexImage = async (ctx,next)=>{ +exports.getIndexImage = async (ctx,next)=>{ //从redis中获取 - const imagesCount = await redis.llen('indexImages') - if(!imagesCount || imagesCount < 1){ - ctx.status = 200 - ctx.body = {success:true,img:config.defaultIndexImage} - try{ - Eif(config.qiniu.app_key !== '' && config.qiniu.app_secret !== ''){ - const result = await qiniuHelper.list('blog/index','',30) - result.items.map(function (item) { - redis.lpush('indexImages',config.qiniu.domain + item.key + '-600x1500q80') + const imagesCount = await redis.llen('indexImages') + if(!imagesCount || imagesCount < 1){ + ctx.status = 200 + ctx.body = {success:true,img:config.defaultIndexImage} + try{ + if(config.qiniu.app_key !== '' && config.qiniu.app_secret !== ''){ + const result = await qiniuHelper.list('blog/index','',30) + result.items.map(function (item) { + redis.lpush('indexImages',config.qiniu.domain + item.key + '-600x1500q80') }) } }catch(err){ redis.del('indexImages') } - return + return }else{ - const images = await redis.lrange('indexImages', 0, 30) - const index = _.random(images.length - 1) - ctx.status = 200 - return ctx.body = {success:true,img:images[index]} + const images = await redis.lrange('indexImages', 0, 30) + const index = _.random(images.length - 1) + ctx.status = 200 + return ctx.body = {success:true,img:images[index]} } } //用户喜欢 -exports.toggleLike = async (ctx,next)=>{ - const _ctx = ctx - const aid = new mongoose.Types.ObjectId(_ctx.params.id) - const userId = _ctx.req.user._id +exports.toggleLike = async (ctx,next)=>{ + const _ctx = ctx + const aid = new mongoose.Types.ObjectId(_ctx.params.id) + const userId = _ctx.req.user._id //如果已经喜欢过了,则从喜欢列表里,去掉文章ID,并减少文章喜欢数.否则添加到喜欢列表,并增加文章喜欢数. //var isLink = _.indexOf(req.user.likeList.toString(), req.params.id) - const isLike = _.findIndex(_ctx.req.user.likeList, function(item) { - return item.toString() == _ctx.params.id + const isLike = _.findIndex(_ctx.req.user.likeList, function(item) { + return item.toString() == _ctx.params.id }) let conditionOne,conditionTwo,liked - if(isLike !== -1){ - conditionOne = {'$pull':{'likeList':aid}} - conditionTwo = {'$inc':{'like_count':-1}} - liked = false + if(isLike !== -1){ + conditionOne = {'$pull':{'likeList':aid}} + conditionTwo = {'$inc':{'like_count':-1}} + liked = false }else{ - conditionOne = {'$addToSet':{'likeList':aid}} - conditionTwo = {'$inc':{'like_count':1}} - liked = true + conditionOne = {'$addToSet':{'likeList':aid}} + conditionTwo = {'$inc':{'like_count':1}} + liked = true }   - try{ - const user = await User.findByIdAndUpdate(userId,conditionOne) - const article = await Article.findByIdAndUpdate(aid,conditionTwo,{new:true}) - _ctx.status = 200 - _ctx.body = {success:true,'count':article.like_count,'isLike':liked} + try{ + const user = await User.findByIdAndUpdate(userId,conditionOne) + const article = await Article.findByIdAndUpdate(aid,conditionTwo,{new:true}) + _ctx.status = 200 + _ctx.body = {success:true,'count':article.like_count,'isLike':liked} }catch(err){ _ctx.throw(err) } @@ -1009,7 +1009,7 @@

diff --git a/coverage/server/api/article/index.html b/coverage/server/api/article/index.html index 03cdbcb..dd5463d 100644 --- a/coverage/server/api/article/index.html +++ b/coverage/server/api/article/index.html @@ -20,28 +20,28 @@

- 94.5% + 20.18% Statements - 206/218 + 44/218
- 85% + 0% Branches - 51/60 + 0/60
- 100% + 46.43% Functions - 28/28 + 13/28
- 94.5% + 20.18% Lines - 206/218 + 44/218
-
+
@@ -59,16 +59,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -90,7 +90,7 @@

diff --git a/coverage/server/api/article/index.js.html b/coverage/server/api/article/index.js.html index dcd48fb..a2a4c45 100644 --- a/coverage/server/api/article/index.js.html +++ b/coverage/server/api/article/index.js.html @@ -72,32 +72,32 @@

27 28

article.controller.js
93.97%187/19985%51/60100%28/2893.97%187/199article.controller.js
12.56%25/1990%0/6046.43%13/2812.56%25/199
    -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x     -8x -8x -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x +2x +2x     -8x -8x -8x +2x +2x +2x   -8x +2x   -8x +2x   -8x -8x
'use strict'
+2x
+2x
'use strict'
  
 const router = require('koa-router')()
 const controller = require('./article.controller')
@@ -130,7 +130,7 @@ 

diff --git a/coverage/server/api/comment/comment.controller.js.html b/coverage/server/api/comment/comment.controller.js.html index c3c3fa0..e16bbad 100644 --- a/coverage/server/api/comment/comment.controller.js.html +++ b/coverage/server/api/comment/comment.controller.js.html @@ -20,28 +20,28 @@

- 87.69% + 15.38% Statements - 57/65 + 10/65
- 100% + 0% Branches - 14/14 + 0/14
- 90% + 50% Functions - 9/10 + 5/10
- 87.69% + 15.38% Lines - 57/65 + 10/65
-
+
1 2 @@ -154,47 +154,47 @@

109 110

    -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x     -27x -3x -3x -3x +6x +  +  +    -3x -1x -2x -1x +  +  +  +    -3x -2x -2x +  +  +    -1x +    -1x -1x -1x -1x +  +  +  +          -1x -1x -1x +  +  +              -24x +6x       @@ -212,54 +212,54 @@

      -26x -2x -2x -1x -1x +6x +  +  +  +    -1x -1x -1x +  +  +        -1x -1x -1x -1x -1x +  +  +  +  +            -26x -2x -2x -2x +6x +  +  +    -1x -1x -1x +  +  +    -1x +        -27x -3x -3x -3x -1x -1x +6x +  +  +  +  +    -2x -2x -1x -1x +  +  +  +    -1x +     

'use strict'
  
@@ -270,33 +270,33 @@ 

const Blog = mongoose.model('Article')   //添加新的评论. -exports.addNewComment = async (ctx,next) => { - const aid = ctx.request.body.aid - let content = ctx.request.body.content - const userId = ctx.req.user._id +exports.addNewComment = async (ctx,next) => { + const aid = ctx.request.body.aid + let content = ctx.request.body.content + const userId = ctx.req.user._id let error_msg - if(!aid){ - error_msg = '缺少必须参数' - }else if(!content || content == ''){ - error_msg = '评论内容不能为空' + if(!aid){ + error_msg = '缺少必须参数' + }else if(!content || content == ''){ + error_msg = '评论内容不能为空' } - if(error_msg){ - ctx.status = 422 - return ctx.body = {error_msg:error_msg} + if(error_msg){ + ctx.status = 422 + return ctx.body = {error_msg:error_msg} } - content = xss(content) + content = xss(content)   - try{ - let result = await Comment.create({ aid:aid,content:content,user_id:userId }) - let comment = result.toObject() - comment.user_id = { + try{ + let result = await Comment.create({ aid:aid,content:content,user_id:userId }) + let comment = result.toObject() + comment.user_id = { _id:ctx.req.user._id, nickname:ctx.req.user.nickname, avatar:ctx.req.user.avatar } - await Blog.findByIdAndUpdate(aid,{$inc:{comment_count:1}}).exec() - ctx.status = 200 - ctx.body = {success:true,data:comment} + await Blog.findByIdAndUpdate(aid,{$inc:{comment_count:1}}).exec() + ctx.status = 200 + ctx.body = {success:true,data:comment} }catch(err){ ctx.throw(err) } @@ -321,54 +321,54 @@

} } //添加回复 -exports.addNewReply = async (ctx,next)=>{ - const cid = ctx.params.id - if(!ctx.request.body.content || ctx.request.body.content == ''){ - ctx.status = 422 - return ctx.body = {error_msg:'回复内容不能为空'} +exports.addNewReply = async (ctx,next)=>{ + const cid = ctx.params.id + if(!ctx.request.body.content || ctx.request.body.content == ''){ + ctx.status = 422 + return ctx.body = {error_msg:'回复内容不能为空'} } - ctx.request.body.content = xss(ctx.request.body.content) - let reply = ctx.request.body - reply.user_info = { + ctx.request.body.content = xss(ctx.request.body.content) + let reply = ctx.request.body + reply.user_info = { id:ctx.req.user._id, nickname:ctx.req.user.nickname } - reply.created = new Date() - try{ - const result = await Comment.findByIdAndUpdate(cid,{'$push':{'replys':reply}},{new:true}) - ctx.status = 200 - ctx.body = {success:true,data:result.replys} + reply.created = new Date() + try{ + const result = await Comment.findByIdAndUpdate(cid,{'$push':{'replys':reply}},{new:true}) + ctx.status = 200 + ctx.body = {success:true,data:result.replys} }catch(err){ ctx.throw(err) } } //删除评论. -exports.delComment = async (ctx,next)=>{ - const cid = ctx.params.id - try{ - const result = await Comment.findByIdAndRemove(cid) +exports.delComment = async (ctx,next)=>{ + const cid = ctx.params.id + try{ + const result = await Comment.findByIdAndRemove(cid) //评论数-1 - Blog.findByIdAndUpdate(result.aid,{$inc:{comment_count:-1}}).exec() - ctx.status = 200 - ctx.body = {success:true} + Blog.findByIdAndUpdate(result.aid,{$inc:{comment_count:-1}}).exec() + ctx.status = 200 + ctx.body = {success:true} }catch(err){ - ctx.throw(err) + ctx.throw(err) } } //删除回复 -exports.delReply = async (ctx,next)=>{ - const cid = ctx.params.id - const rid = ctx.request.body.rid - if(!rid){ - ctx.status = 422 - return ctx.body = {error_msg:'缺少回复ID.'} +exports.delReply = async (ctx,next)=>{ + const cid = ctx.params.id + const rid = ctx.request.body.rid + if(!rid){ + ctx.status = 422 + return ctx.body = {error_msg:'缺少回复ID.'} } - try{ - const result = await Comment.findByIdAndUpdate(cid,{$pull:{replys:{ _id:mongoose.Types.ObjectId(rid) }}},{new:true}) - ctx.status = 200 - ctx.body = {success:true,data:result} + try{ + const result = await Comment.findByIdAndUpdate(cid,{$pull:{replys:{ _id:mongoose.Types.ObjectId(rid) }}},{new:true}) + ctx.status = 200 + ctx.body = {success:true,data:result} }catch(err){ - ctx.throw(err) + ctx.throw(err) } }

@@ -376,7 +376,7 @@

diff --git a/coverage/server/api/comment/index.html b/coverage/server/api/comment/index.html index 199438f..4579df2 100644 --- a/coverage/server/api/comment/index.html +++ b/coverage/server/api/comment/index.html @@ -20,28 +20,28 @@

- 89.19% + 25.68% Statements - 66/74 + 19/74
- 100% + 0% Branches - 14/14 + 0/14
- 90% + 50% Functions - 9/10 + 5/10
- 89.19% + 25.68% Lines - 66/74 + 19/74
-
+
@@ -59,16 +59,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -90,7 +90,7 @@

diff --git a/coverage/server/api/comment/index.js.html b/coverage/server/api/comment/index.js.html index 229226c..c61735f 100644 --- a/coverage/server/api/comment/index.js.html +++ b/coverage/server/api/comment/index.js.html @@ -58,18 +58,18 @@

13 14

comment.controller.js
87.69%57/65100%14/1490%9/1087.69%57/65comment.controller.js
15.38%10/650%0/1450%5/1015.38%10/65
    -8x -8x -8x +2x +2x +2x     -8x -8x +2x +2x   -8x -8x -8x -8x
'use strict'
+2x
+2x
+2x
+2x
'use strict'
  
 const router = require('koa-router')()
 const controller = require('./comment.controller')
@@ -88,7 +88,7 @@ 

diff --git a/coverage/server/api/logs/index.html b/coverage/server/api/logs/index.html index 4e0318e..ed2c05a 100644 --- a/coverage/server/api/logs/index.html +++ b/coverage/server/api/logs/index.html @@ -20,28 +20,28 @@

- 100% + 42.11% Statements - 19/19 + 8/19
- 100% + 0% Branches - 8/8 + 0/8
- 100% + 50% Functions - 2/2 + 1/2
- 100% + 42.11% Lines - 19/19 + 8/19
-
+
@@ -72,16 +72,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -90,7 +90,7 @@

diff --git a/coverage/server/api/logs/index.js.html b/coverage/server/api/logs/index.js.html index ee6d201..e3239dd 100644 --- a/coverage/server/api/logs/index.js.html +++ b/coverage/server/api/logs/index.js.html @@ -53,13 +53,13 @@

8 9

logs.controller.js
100%14/14100%8/8100%2/2100%14/14logs.controller.js
21.43%3/140%0/850%1/221.43%3/14
    -8x -8x -8x +2x +2x +2x   -8x +2x   -8x
'use strict'
+2x
'use strict'
  
 const router = require('koa-router')()
 const controller = require('./logs.controller')
@@ -73,7 +73,7 @@ 

diff --git a/coverage/server/api/logs/logs.controller.js.html b/coverage/server/api/logs/logs.controller.js.html index 0264c74..4e6c3fc 100644 --- a/coverage/server/api/logs/logs.controller.js.html +++ b/coverage/server/api/logs/logs.controller.js.html @@ -20,28 +20,28 @@

- 100% + 21.43% Statements - 14/14 + 3/14
- 100% + 0% Branches - 8/8 + 0/8
- 100% + 50% Functions - 2/2 + 1/2
- 100% + 21.43% Lines - 14/14 + 3/14
-
+
1 2 @@ -65,43 +65,43 @@

20 21

    -8x -8x -  -26x -2x 2x 2x   -2x -2x -2x -1x +6x +  +  +    -2x -2x -2x -2x +  +  +  +  +  +  +  +  +     
'use strict'
  
 const mongoose = require('mongoose')
 const Logs = mongoose.model('Logs')
  
-exports.getLogsList = async (ctx, next)=>{
-	let currentPage = (parseInt(ctx.query.currentPage) > 0)?parseInt(ctx.query.currentPage):1
-	let itemsPerPage = (parseInt(ctx.query.itemsPerPage) > 0)?parseInt(ctx.query.itemsPerPage):10
-	let startRow = (currentPage - 1) * itemsPerPage
+exports.getLogsList = async (ctx, next)=>{
+	let currentPage = (parseInt(ctx.query.currentPage) > 0)?parseInt(ctx.query.currentPage):1
+	let itemsPerPage = (parseInt(ctx.query.itemsPerPage) > 0)?parseInt(ctx.query.itemsPerPage):10
+	let startRow = (currentPage - 1) * itemsPerPage
  
-	let sortName = String(ctx.query.sortName) || 'created'
-	let sortOrder = ctx.query.sortOrder
-	if(sortOrder === 'false'){
-		sortName = '-' + sortName
+	let sortName = String(ctx.query.sortName) || 'created'
+	let sortOrder = ctx.query.sortOrder
+	if(sortOrder === 'false'){
+		sortName = '-' + sortName
 	}
-	const logsList = await Logs.find({}).skip(startRow).limit(itemsPerPage).sort(sortName).exec()
-	const count = await Logs.count()
-	ctx.status = 200
-	ctx.body = { data: logsList,count:count }
+	const logsList = await Logs.find({}).skip(startRow).limit(itemsPerPage).sort(sortName).exec()
+	const count = await Logs.count()
+	ctx.status = 200
+	ctx.body = { data: logsList,count:count }
 }
  
@@ -109,7 +109,7 @@

diff --git a/coverage/server/api/mobile/index.html b/coverage/server/api/mobile/index.html index d3d0476..7ace913 100644 --- a/coverage/server/api/mobile/index.html +++ b/coverage/server/api/mobile/index.html @@ -20,28 +20,28 @@

- 90% + 60% Statements - 9/10 + 6/10
- 50% + 0% Branches - 1/2 + 0/2
- 100% + 50% Functions - 2/2 + 1/2
- 90% + 60% Lines - 9/10 + 6/10
-
+
@@ -72,16 +72,16 @@

- - - - + + + + + + - - - - + + @@ -90,7 +90,7 @@

diff --git a/coverage/server/api/mobile/index.js.html b/coverage/server/api/mobile/index.js.html index 12b9423..fca9ded 100644 --- a/coverage/server/api/mobile/index.js.html +++ b/coverage/server/api/mobile/index.js.html @@ -52,12 +52,12 @@

7 8

mobile.controller.js
83.33%5/6mobile.controller.js
33.33%2/60%0/2 50% 1/2100%2/283.33%5/633.33%2/6
    -8x -8x +2x +2x   -8x +2x   -8x
'use strict'
+2x
'use strict'
  
 const router = require('koa-router')()
 const controller = require('./mobile.controller')
@@ -70,7 +70,7 @@ 

diff --git a/coverage/server/api/mobile/mobile.controller.js.html b/coverage/server/api/mobile/mobile.controller.js.html index 0c10363..0874c2a 100644 --- a/coverage/server/api/mobile/mobile.controller.js.html +++ b/coverage/server/api/mobile/mobile.controller.js.html @@ -20,28 +20,28 @@

- 83.33% + 33.33% Statements - 5/6 + 2/6
- 50% + 0% Branches - 1/2 + 0/2
- 100% + 50% Functions - 2/2 + 1/2
- 83.33% + 33.33% Lines - 5/6 + 2/6
-
+
1 2 @@ -57,12 +57,12 @@

12 13

    -8x +2x   -25x -1x -1x -1x +6x +  +  +        @@ -71,10 +71,10 @@

  const config = require('../../config/env')   -exports.getApps = async (ctx)=>{ - Eif(config.apps){ - ctx.status = 200 - ctx.body = {success:true,data:config.apps} +exports.getApps = async (ctx)=>{ + if(config.apps){ + ctx.status = 200 + ctx.body = {success:true,data:config.apps} }else{ ctx.throw(404) } @@ -85,7 +85,7 @@

diff --git a/coverage/server/api/tags/index.html b/coverage/server/api/tags/index.html index 2516d3f..f1bc8ad 100644 --- a/coverage/server/api/tags/index.html +++ b/coverage/server/api/tags/index.html @@ -20,28 +20,28 @@

- 93.52% + 24.07% Statements - 101/108 + 26/108
- 90% + 0% Branches - 18/20 + 0/20
- 100% + 50% Functions - 18/18 + 9/18
- 93.52% + 24.07% Lines - 101/108 + 26/108
-
+
@@ -72,16 +72,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -90,7 +90,7 @@

diff --git a/coverage/server/api/tags/index.js.html b/coverage/server/api/tags/index.js.html index 6107f5b..fe95dca 100644 --- a/coverage/server/api/tags/index.js.html +++ b/coverage/server/api/tags/index.js.html @@ -61,21 +61,21 @@

16 17

tags.controller.js
92.63%88/9590%18/20100%18/1892.63%88/95tags.controller.js
13.68%13/950%0/2050%9/1813.68%13/95
    -8x -8x -8x +2x +2x +2x   -8x -8x -8x -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x +2x +2x +2x   -8x -8x
'use strict'
+2x
+2x
'use strict'
  
 const router = require('koa-router')()
 const controller = require('./tags.controller')
@@ -97,7 +97,7 @@ 

diff --git a/coverage/server/api/tags/tags.controller.js.html b/coverage/server/api/tags/tags.controller.js.html index db55256..a7d27db 100644 --- a/coverage/server/api/tags/tags.controller.js.html +++ b/coverage/server/api/tags/tags.controller.js.html @@ -20,28 +20,28 @@

- 92.63% + 13.68% Statements - 88/95 + 13/95
- 90% + 0% Branches - 18/20 + 0/20
- 100% + 50% Functions - 18/18 + 9/18
- 92.63% + 13.68% Lines - 88/95 + 13/95
-
+
1 2 @@ -200,119 +200,119 @@

155 156

    -8x -8x -8x -8x -  -  -27x -3x -3x -1x -1x -  2x 2x 2x -1x -1x +2x   -1x -1x -1x +  +6x +  +  +  +  +  +  +  +  +  +  +  +  +  +              -25x -1x -1x -1x -1x +6x +  +  +  +              -25x -1x -1x -1x +6x +  +  +    -1x -1x -1x -1x +  +  +  +              -27x -3x -3x -3x -2x -1x -1x +6x +  +  +  +  +  +    -1x -1x -1x +  +  +      -1x +          -26x -2x -2x -2x -1x +6x +  +  +  +    -2x -2x +  +        -2x -2x +  +            -28x +6x   -4x -4x +  +    -4x -1x -3x -1x +  +  +  +      -4x -2x -2x +  +  +    -2x -2x -2x -1x -1x +  +  +  +  +    -1x -1x -1x +  +  +        @@ -320,36 +320,36 @@

      -26x -2x -2x -2x -1x -1x +6x +  +  +  +  +    -1x +        -25x -1x -1x -1x +6x +  +  +    -1x -1x -1x -1x +  +  +  +            -25x -1x -1x -1x -1x +6x +  +  +  +        @@ -361,113 +361,113 @@

const Tag = mongoose.model('Tag')   //添加添签分类. -exports.addTagCat = async (ctx, next)=>{ - const catName = ctx.request.body.name - if(!catName){ - ctx.status = 422 - return ctx.body = {error_msg:'标签分类名称不能为空.'} +exports.addTagCat = async (ctx, next)=>{ + const catName = ctx.request.body.name + if(!catName){ + ctx.status = 422 + return ctx.body = {error_msg:'标签分类名称不能为空.'} } - try{ - const cat = await TagCategory.findOne({name:catName}) - if(cat){ - ctx.status = 403 - return ctx.body = {error_msg:'分类名称已经存在.'} + try{ + const cat = await TagCategory.findOne({name:catName}) + if(cat){ + ctx.status = 403 + return ctx.body = {error_msg:'分类名称已经存在.'} } - const result = await TagCategory.create(ctx.request.body) - ctx.status = 200 - ctx.body = {success:true,cat_id:result._id} + const result = await TagCategory.create(ctx.request.body) + ctx.status = 200 + ctx.body = {success:true,cat_id:result._id} }catch(err){ ctx.throw(err) } }   //获取分类列表 -exports.getTagCatList = async (ctx, next)=>{ - try{ - const result = await TagCategory.find() - ctx.status = 200 - ctx.body = {success:true,data:result} +exports.getTagCatList = async (ctx, next)=>{ + try{ + const result = await TagCategory.find() + ctx.status = 200 + ctx.body = {success:true,data:result} }catch(err){ ctx.throw(err) } }   //更新分类 -exports.updateTagCat = async (ctx, next)=>{ - const id = ctx.params.id - Eif(ctx.request.body._id){ - delete ctx.request.body._id +exports.updateTagCat = async (ctx, next)=>{ + const id = ctx.params.id + if(ctx.request.body._id){ + delete ctx.request.body._id } - try{ - const result = await TagCategory.findByIdAndUpdate(id,ctx.request.body,{new:true}) - ctx.status = 200 - ctx.body = {success:true,cat_id:result._id} + try{ + const result = await TagCategory.findByIdAndUpdate(id,ctx.request.body,{new:true}) + ctx.status = 200 + ctx.body = {success:true,cat_id:result._id} }catch(err){ ctx.throw(err) } } //删除分类 //(如果分类下有标签,则不可删除) -exports.delTagCat = async (ctx, next)=>{ - const id = ctx.params.id - try{ - const tag = await Tag.findOne({cid:id}) - if(tag){ - ctx.status = 403 - ctx.body = {error_msg:'此分类下有标签不可删除.'} +exports.delTagCat = async (ctx, next)=>{ + const id = ctx.params.id + try{ + const tag = await Tag.findOne({cid:id}) + if(tag){ + ctx.status = 403 + ctx.body = {error_msg:'此分类下有标签不可删除.'} }else{ - await TagCategory.findByIdAndRemove(id) - ctx.status = 200 - ctx.body = {success:true} + await TagCategory.findByIdAndRemove(id) + ctx.status = 200 + ctx.body = {success:true} } }catch(err){ - ctx.throw(err) + ctx.throw(err) } }   //获取标签列表 -exports.getTagList = async (ctx, next)=>{ - const cid = ctx.params.id - let condition = {} - if(cid != 0){ - condition = {cid:cid} +exports.getTagList = async (ctx, next)=>{ + const cid = ctx.params.id + let condition = {} + if(cid != 0){ + condition = {cid:cid} } - try{ - const tagList = await Tag.find(condition) + try{ + const tagList = await Tag.find(condition) .sort('sort') .populate('cid') .exec() - ctx.status = 200 - ctx.body = {success:true,data:tagList} + ctx.status = 200 + ctx.body = {success:true,data:tagList} }catch(err){ ctx.throw(err) } } //添加标签 -exports.addTag = async (ctx, next)=>{ +exports.addTag = async (ctx, next)=>{ //标签名称不能重复,标签分类名称必须有. - const cid = ctx.request.body.cid - const tagName = ctx.request.body.name + const cid = ctx.request.body.cid + const tagName = ctx.request.body.name let error_msg - if(!tagName){ - error_msg = '标签名称不能为空.' - }else if(!cid){ - error_msg = '必须选择一个标签分类.' + if(!tagName){ + error_msg = '标签名称不能为空.' + }else if(!cid){ + error_msg = '必须选择一个标签分类.' }   - if(error_msg){ - ctx.status = 422 - return ctx.body = {error_msg:error_msg} + if(error_msg){ + ctx.status = 422 + return ctx.body = {error_msg:error_msg} } - try{ - const tag = await Tag.findOne({name:tagName}) - if(tag){ - ctx.status = 403 - return ctx.body = {error_msg:'标签名称已经存在.'} + try{ + const tag = await Tag.findOne({name:tagName}) + if(tag){ + ctx.status = 403 + return ctx.body = {error_msg:'标签名称已经存在.'} }else{ - const result = await Tag.create(ctx.request.body) - ctx.status = 200 - ctx.body = {success:true,tag_id:result._id} + const result = await Tag.create(ctx.request.body) + ctx.status = 200 + ctx.body = {success:true,tag_id:result._id} } }catch(err){ ctx.throw(err) @@ -475,36 +475,36 @@

}   //删除标签 -exports.deleteTag = async (ctx, next)=>{ - const id = ctx.params.id - try{ - await Tag.findByIdAndRemove(id) - ctx.status = 200 - ctx.body = {success:true} +exports.deleteTag = async (ctx, next)=>{ + const id = ctx.params.id + try{ + await Tag.findByIdAndRemove(id) + ctx.status = 200 + ctx.body = {success:true} }catch(err){ - ctx.throw(err) + ctx.throw(err) } } //更新标签 -exports.updateTag = async (ctx, next)=>{ - const id = ctx.params.id - Eif(ctx.request.body._id){ - delete ctx.request.body._id +exports.updateTag = async (ctx, next)=>{ + const id = ctx.params.id + if(ctx.request.body._id){ + delete ctx.request.body._id } - try{ - const result = await Tag.findByIdAndUpdate(id,ctx.request.body,{new:true}) - ctx.status = 200 - ctx.body = {success:true,tag_id:result._id} + try{ + const result = await Tag.findByIdAndUpdate(id,ctx.request.body,{new:true}) + ctx.status = 200 + ctx.body = {success:true,tag_id:result._id} }catch(err){ ctx.throw(err) } } //前台数据 -exports.getFrontTagList = async (ctx, next)=>{ - try{ - const result = await Tag.find({is_show:true},{},{sort:{'sort':-1}}) - ctx.status = 200 - ctx.body = {data:result} +exports.getFrontTagList = async (ctx, next)=>{ + try{ + const result = await Tag.find({is_show:true},{},{sort:{'sort':-1}}) + ctx.status = 200 + ctx.body = {data:result} }catch(err){ ctx.throw(err) } @@ -514,7 +514,7 @@

diff --git a/coverage/server/api/users/index.html b/coverage/server/api/users/index.html index 93270ee..545d22d 100644 --- a/coverage/server/api/users/index.html +++ b/coverage/server/api/users/index.html @@ -20,28 +20,28 @@

- 92.7% + 19.71% Statements - 127/137 + 27/137
- 89.04% + 0% Branches - 65/73 + 0/73
- 94.44% + 50% Functions - 17/18 + 9/18
- 92.7% + 19.71% Lines - 127/137 + 27/137
-
+
@@ -72,16 +72,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -90,7 +90,7 @@

diff --git a/coverage/server/api/users/index.js.html b/coverage/server/api/users/index.js.html index a412eea..7a92dde 100644 --- a/coverage/server/api/users/index.js.html +++ b/coverage/server/api/users/index.js.html @@ -62,21 +62,21 @@

17 18

user.controller.js
91.94%114/12489.04%65/7394.44%17/1891.94%114/124user.controller.js
11.29%14/1240%0/7350%9/1811.29%14/124
    -8x -8x -8x +2x +2x +2x   -8x -8x -8x -8x +2x +2x +2x +2x   -8x -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x +2x  
'use strict'
  
 const router = require('koa-router')()
@@ -100,7 +100,7 @@ 

diff --git a/coverage/server/api/users/user.controller.js.html b/coverage/server/api/users/user.controller.js.html index db06a79..6b57f80 100644 --- a/coverage/server/api/users/user.controller.js.html +++ b/coverage/server/api/users/user.controller.js.html @@ -20,28 +20,28 @@

- 91.94% + 11.29% Statements - 114/124 + 14/124
- 89.04% + 0% Branches - 65/73 + 0/73
- 94.44% + 50% Functions - 17/18 + 9/18
- 91.94% + 11.29% Lines - 114/124 + 14/124
-
+
1 2 @@ -244,200 +244,200 @@

199 200

    -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x       -24x +6x             -25x -1x -1x -1x -1x -1x +6x +  +  +  +  +            -26x -2x -2x -2x +6x +  +  +    -2x -2x -2x -1x +  +  +  +    -2x -2x -2x -2x -2x +  +  +  +  +              -30x -6x -6x -6x 6x +  +  +  +    -6x -1x -5x -3x -2x +  +  +  +  +      -2x +      -6x -4x -4x +  +  +    -2x -2x -2x -2x -1x +  +  +  +  +          -1x -1x +  +    -1x +          -27x -3x +6x +    -3x -1x -1x +  +  +    -2x -2x -1x +  +  +          -1x -1x +  +    -1x +            -31x +6x   -7x -7x -7x -7x -7x +  +  +  +  +    -7x -1x -6x -1x -5x +  +  +  +  +    -1x -4x -1x +  +  +    -7x -4x -4x +  +  +    -3x -3x -3x -3x -3x -3x +  +  +  +  +  +    -3x -1x +  +    -3x -2x +  +          -2x -2x +  +    -1x +          -28x -4x -4x +6x +  +        -4x -1x -3x +  +  +    -1x +    -4x -2x -2x +  +  +    -2x -2x -2x -2x -1x -1x +  +  +  +  +  +    -1x +        -25x -1x -1x -1x -1x +6x +  +  +  +            -25x -1x -1x -1x +6x +  +  +        @@ -458,185 +458,185 @@

ctx.body = buffer }   -exports.getMe = async (ctx,next)=>{ - const userId = ctx.req.user._id - try{ - const user = await User.findById(userId) - ctx.status = 200 - ctx.body = user.userInfo +exports.getMe = async (ctx,next)=>{ + const userId = ctx.req.user._id + try{ + const user = await User.findById(userId) + ctx.status = 200 + ctx.body = user.userInfo }catch(err){ ctx.throw(err) } } //后台获取用户列表 -exports.getUserList = async (ctx,next)=>{ - let currentPage = (parseInt(ctx.query.currentPage) > 0)?parseInt(ctx.query.currentPage):1 - let itemsPerPage = (parseInt(ctx.query.itemsPerPage) > 0)?parseInt(ctx.query.itemsPerPage):10 - let startRow = (currentPage - 1) * itemsPerPage +exports.getUserList = async (ctx,next)=>{ + let currentPage = (parseInt(ctx.query.currentPage) > 0)?parseInt(ctx.query.currentPage):1 + let itemsPerPage = (parseInt(ctx.query.itemsPerPage) > 0)?parseInt(ctx.query.itemsPerPage):10 + let startRow = (currentPage - 1) * itemsPerPage   - let sortName = String(ctx.query.sortName) || 'created' - let sortOrder = ctx.query.sortOrder - if(sortOrder === 'false'){ - sortName = '-' + sortName + let sortName = String(ctx.query.sortName) || 'created' + let sortOrder = ctx.query.sortOrder + if(sortOrder === 'false'){ + sortName = '-' + sortName } - try{ - const count = await User.count() - const userList = await User.find({}).skip(startRow).limit(itemsPerPage).sort(sortName).exec() - ctx.status = 200 - ctx.body = { data: userList, count:count } + try{ + const count = await User.count() + const userList = await User.find({}).skip(startRow).limit(itemsPerPage).sort(sortName).exec() + ctx.status = 200 + ctx.body = { data: userList, count:count } }catch(err){ ctx.throw(err) } }   //添加用户 -exports.addUser = async (ctx,next)=>{ - const nickname = ctx.request.body.nickname?ctx.request.body.nickname.replace(/(^\s+)|(\s+$)/g, ''):'' - const email = ctx.request.body.email?ctx.request.body.email.replace(/(^\s+)|(\s+$)/g, ''):'' - const NICKNAME_REGEXP = /^[(\u4e00-\u9fa5)0-9a-zA-Z\_\s@]+$/ - const EMAIL_REGEXP = /^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/ +exports.addUser = async (ctx,next)=>{ + const nickname = ctx.request.body.nickname?ctx.request.body.nickname.replace(/(^\s+)|(\s+$)/g, ''):'' + const email = ctx.request.body.email?ctx.request.body.email.replace(/(^\s+)|(\s+$)/g, ''):'' + const NICKNAME_REGEXP = /^[(\u4e00-\u9fa5)0-9a-zA-Z\_\s@]+$/ + const EMAIL_REGEXP = /^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/ let error_msg - if(nickname === ''){ - error_msg = '呢称不能为空' - }else if(email === ''){ - error_msg = '邮箱地址不能为空' - }else Iif(nickname.length <= 2 || nickname.length >15 || !NICKNAME_REGEXP.test(nickname)){ + if(nickname === ''){ + error_msg = '呢称不能为空' + }else if(email === ''){ + error_msg = '邮箱地址不能为空' + }else if(nickname.length <= 2 || nickname.length >15 || !NICKNAME_REGEXP.test(nickname)){ //不符合呢称规定. error_msg = '呢称不合法' - }else Iif(email.length <=4 || email.length > 30 || !EMAIL_REGEXP.test(email)){ + }else if(email.length <=4 || email.length > 30 || !EMAIL_REGEXP.test(email)){ error_msg = '邮箱地址不合法' } - if(error_msg){ - ctx.status = 422 - return ctx.body = {error_msg:error_msg} + if(error_msg){ + ctx.status = 422 + return ctx.body = {error_msg:error_msg} } - try{ - let newUser = new User(ctx.request.body) - newUser.role = 'user' - const user = await newUser.save() - await Logs.create({ + try{ + let newUser = new User(ctx.request.body) + newUser.role = 'user' + const user = await newUser.save() + await Logs.create({ uid: ctx.req.user._id, - content:'创建新用户 '+ (user.email || user.nickname), + content:'创建新用户 '+ (user.email || user.nickname), type:'user' }) - ctx.status = 200 - ctx.body = {success:true,user_id:user._id} + ctx.status = 200 + ctx.body = {success:true,user_id:user._id} }catch(err){ - ctx.throw(err) + ctx.throw(err) } }   //删除用户 -exports.destroy = async (ctx,next)=>{ - const userId = ctx.req.user._id +exports.destroy = async (ctx,next)=>{ + const userId = ctx.req.user._id   - if(String(userId) === String(ctx.params.id)){ - ctx.status = 403 - return ctx.body = {message:'不能删除自己已经登录的账号'} + if(String(userId) === String(ctx.params.id)){ + ctx.status = 403 + return ctx.body = {message:'不能删除自己已经登录的账号'} }else{ - try{ - const user = await User.findByIdAndRemove(ctx.params.id) - await Logs.create({ + try{ + const user = await User.findByIdAndRemove(ctx.params.id) + await Logs.create({ uid:userId, - content:'删除用户'+ (user.email || user.nickname), + content:'删除用户'+ (user.email || user.nickname), type:'user' }) - ctx.status = 200 - ctx.body = {success:true} + ctx.status = 200 + ctx.body = {success:true} }catch(err){ - ctx.throw(err) + ctx.throw(err) } } }   //更新用户 -exports.updateUser = async (ctx,next)=>{ +exports.updateUser = async (ctx,next)=>{ //被编辑人 - const editUserId = ctx.params.id - const nickname = ctx.request.body.nickname?ctx.request.body.nickname.replace(/(^\s+)|(\s+$)/g, ''):'' - const email = ctx.request.body.email?ctx.request.body.email.replace(/(^\s+)|(\s+$)/g, ''):'' - const NICKNAME_REGEXP = /^[(\u4e00-\u9fa5)0-9a-zA-Z\_\s@]+$/ - const EMAIL_REGEXP = /^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/ + const editUserId = ctx.params.id + const nickname = ctx.request.body.nickname?ctx.request.body.nickname.replace(/(^\s+)|(\s+$)/g, ''):'' + const email = ctx.request.body.email?ctx.request.body.email.replace(/(^\s+)|(\s+$)/g, ''):'' + const NICKNAME_REGEXP = /^[(\u4e00-\u9fa5)0-9a-zA-Z\_\s@]+$/ + const EMAIL_REGEXP = /^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/ let error_msg - if(nickname === ''){ - error_msg = '呢称不能为空' - }else if(email === ''){ - error_msg = '邮箱地址不能为空' - }else if(nickname.length <= 2 || nickname.length >15 || !NICKNAME_REGEXP.test(nickname)){ + if(nickname === ''){ + error_msg = '呢称不能为空' + }else if(email === ''){ + error_msg = '邮箱地址不能为空' + }else if(nickname.length <= 2 || nickname.length >15 || !NICKNAME_REGEXP.test(nickname)){ //不符合呢称规定. - error_msg = '呢称不合法' - }else if(email.length <=4 || email.length > 30 || !EMAIL_REGEXP.test(email)){ - error_msg = '邮箱地址不合法' + error_msg = '呢称不合法' + }else if(email.length <=4 || email.length > 30 || !EMAIL_REGEXP.test(email)){ + error_msg = '邮箱地址不合法' } - if(error_msg){ - ctx.status = 422 - return ctx.body = {error_msg:error_msg} + if(error_msg){ + ctx.status = 422 + return ctx.body = {error_msg:error_msg} } - try{ - let user = await User.findById(editUserId) - user.nickname = ctx.request.body.nickname - user.email = ctx.request.body.email.toLowerCase() - Eif(ctx.request.body.status){ - user.status = ctx.request.body.status + try{ + let user = await User.findById(editUserId) + user.nickname = ctx.request.body.nickname + user.email = ctx.request.body.email.toLowerCase() + if(ctx.request.body.status){ + user.status = ctx.request.body.status } - if(ctx.request.body.newPassword){ - user.password = ctx.request.body.newPassword + if(ctx.request.body.newPassword){ + user.password = ctx.request.body.newPassword } - const newUser = await user.save() - await Logs.create({ + const newUser = await user.save() + await Logs.create({ email:ctx.req.user._id, - content:'编辑用户'+ (newUser.email || newUser.nickname), + content:'编辑用户'+ (newUser.email || newUser.nickname), type:'user' }) - ctx.status = 200 - ctx.body = {success:true,user_id:newUser._id} + ctx.status = 200 + ctx.body = {success:true,user_id:newUser._id} }catch(err){ - ctx.throw(err) + ctx.throw(err) } }   //前台用户更新自己信息 -exports.mdUser = async (ctx,next)=>{ - const nickname = ctx.request.body.nickname?ctx.request.body.nickname.replace(/(^\s+)|(\s+$)/g, ''):'' - const NICKNAME_REGEXP = /^[(\u4e00-\u9fa5)0-9a-zA-Z\_\s@]+$/ +exports.mdUser = async (ctx,next)=>{ + const nickname = ctx.request.body.nickname?ctx.request.body.nickname.replace(/(^\s+)|(\s+$)/g, ''):'' + const NICKNAME_REGEXP = /^[(\u4e00-\u9fa5)0-9a-zA-Z\_\s@]+$/ //var EMAIL_REGEXP = /^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/ //检测一下 let error_msg - if(nickname === ''){ - error_msg = '呢称不能为空' - }else if(nickname.length <= 2 || nickname.length >15 || !NICKNAME_REGEXP.test(nickname)){ + if(nickname === ''){ + error_msg = '呢称不能为空' + }else if(nickname.length <= 2 || nickname.length >15 || !NICKNAME_REGEXP.test(nickname)){ //不符合呢称规定. - error_msg = '呢称不合法' + error_msg = '呢称不合法' } - if(error_msg){ - ctx.status = 422 - return ctx.body = {error_msg:error_msg} + if(error_msg){ + ctx.status = 422 + return ctx.body = {error_msg:error_msg} } - let user = ctx.req.user - user.nickname = nickname - try{ - const result = await user.save() - ctx.status = 200 - ctx.body = {success:true,data:result.userInfo} + let user = ctx.req.user + user.nickname = nickname + try{ + const result = await user.save() + ctx.status = 200 + ctx.body = {success:true,data:result.userInfo} }catch(err){ - ctx.throw(err) + ctx.throw(err) } } //前台获取用户社交账号绑定情况. -exports.getUserProvider = async (ctx,next)=>{ - try{ - const user = await User.findById(ctx.req.user._id) - ctx.status = 200 - ctx.body = {data:user.providerInfo} +exports.getUserProvider = async (ctx,next)=>{ + try{ + const user = await User.findById(ctx.req.user._id) + ctx.status = 200 + ctx.body = {data:user.providerInfo} }catch(err){ ctx.throw(err) } } //获取第三方登录列表. -exports.getSnsLogins = async (ctx,next)=>{ - Eif(config.snsLogins){ - ctx.status = 200 - ctx.body = {success:true,data:config.snsLogins} +exports.getSnsLogins = async (ctx,next)=>{ + if(config.snsLogins){ + ctx.status = 200 + ctx.body = {success:true,data:config.snsLogins} }else{ ctx.throw(404) } @@ -646,7 +646,7 @@

diff --git a/coverage/server/app.js.html b/coverage/server/app.js.html index 15005eb..7c31b36 100644 --- a/coverage/server/app.js.html +++ b/coverage/server/app.js.html @@ -20,28 +20,28 @@

- 85% + 70% Statements - 17/20 + 14/20
- 50% + 33.33% Branches - 3/6 + 2/6
- 100% + 33.33% Functions - 3/3 + 1/3
- 85% + 70% Lines - 17/20 + 14/20
-
+
1 2 @@ -80,38 +80,38 @@

35

      -8x -8x -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x +2x +2x     -8x +2x             -117x -93x -93x +6x +  +      -8x -8x -8x +2x +2x +2x   -8x -10x +2x +          -8x
'use strict'
+2x
'use strict'
  
 // 设置默认环境变量
 process.env.NODE_ENV = process.env.NODE_ENV || 'development'
@@ -130,17 +130,17 @@ 

  //log记录 //router use : this.logger.error('msg') -app.use(async (ctx, next) => { - ctx.logger = logger - await next() +app.use(async (ctx, next) => { + ctx.logger = logger + await next() }) //错误处理中间件 app.use(errorHandleMiddle()) require('./config/koa')(app) require('./routes')(app) //错误监听 -app.on('error',(err,ctx)=>{ - Iif (process.env.NODE_ENV != 'test') { +app.on('error',(err,ctx)=>{ + if (process.env.NODE_ENV != 'test') { console.error('error', err) } }) @@ -151,7 +151,7 @@

diff --git a/coverage/server/auth/auth.service.js.html b/coverage/server/auth/auth.service.js.html index 6bfd739..9a0842f 100644 --- a/coverage/server/auth/auth.service.js.html +++ b/coverage/server/auth/auth.service.js.html @@ -20,24 +20,24 @@

- 77.5% + 50% Statements - 31/40 + 20/40
- 43.75% + 6.25% Branches - 7/16 + 1/16
- 92.86% + 57.14% Functions - 13/14 + 8/14
- 81.82% + 48.48% Lines - 27/33 + 16/33
@@ -134,24 +134,24 @@

89 90

    -8x -8x -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x +2x +2x           -567x +124x   -71x +      -71x +        @@ -160,17 +160,17 @@

      -1038x +224x     -71x -71x +  +      -71x -71x -71x -71x +  +  +  +        @@ -179,12 +179,12 @@

      -176x -410x +44x +88x     -58x -58x +  +        @@ -196,14 +196,14 @@

      -6x +              -48x +12x       @@ -217,10 +217,10 @@

      -8x -8x -8x -8x +2x +2x +2x +2x  

'use strict'
  
 const mongoose = require('mongoose')
@@ -236,11 +236,11 @@ 

*/ function authToken() { return compose([ - async (ctx,next)=> { - Iif(ctx.query && ctx.query.access_token){ + async (ctx,next)=> { + if(ctx.query && ctx.query.access_token){ ctx.headers.authorization = 'Bearer ' + ctx.query.access_token } - await next() + await next() }, koajwt({ secret: config.session.secrets,passthrough: true }) ]) @@ -251,15 +251,15 @@

function isAuthenticated() { return compose([ authToken(), - async (ctx,next) =>{ - Iif(!ctx.state.user) ctx.throw('UnauthorizedError',401) - await next() + async (ctx,next) =>{ + if(!ctx.state.user) ctx.throw('UnauthorizedError',401) + await next() }, - async (ctx,next) =>{ - var user = await User.findById(ctx.state.user._id) - Iif (!user) ctx.throw('UnauthorizedError',401) - ctx.req.user = user - await next() + async (ctx,next) =>{ + var user = await User.findById(ctx.state.user._id) + if (!user) ctx.throw('UnauthorizedError',401) + ctx.req.user = user + await next() } ]) } @@ -271,9 +271,9 @@

Iif (!roleRequired) this.throw('Required role needs to be set') return compose([ isAuthenticated(), - async (ctx,next) =>{ - Eif (config.userRoles.indexOf(ctx.req.user.role) >= config.userRoles.indexOf(roleRequired)) { - await next() + async (ctx,next) =>{ + if (config.userRoles.indexOf(ctx.req.user.role) >= config.userRoles.indexOf(roleRequired)) { + await next() }else { ctx.throw(403) } @@ -284,8 +284,8 @@

/** * 生成token */ -function signToken(id) { - return jwt.sign({ _id: id }, config.session.secrets, { expiresIn: config.session.cookie.maxAge/1000 }) +function signToken(id) { + return jwt.sign({ _id: id }, config.session.secrets, { expiresIn: config.session.cookie.maxAge/1000 }) }   /** @@ -316,7 +316,7 @@

diff --git a/coverage/server/auth/github/index.html b/coverage/server/auth/github/index.html index bcc8f1d..83945aa 100644 --- a/coverage/server/auth/github/index.html +++ b/coverage/server/auth/github/index.html @@ -90,7 +90,7 @@

diff --git a/coverage/server/auth/github/index.js.html b/coverage/server/auth/github/index.js.html index bbb902d..1ea3b1b 100644 --- a/coverage/server/auth/github/index.js.html +++ b/coverage/server/auth/github/index.js.html @@ -81,15 +81,15 @@

36 37

    -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x       -24x +6x       @@ -114,7 +114,7 @@

      -8x +2x  

'use strict'
  
 const router = require('koa-router')()
@@ -157,7 +157,7 @@ 

diff --git a/coverage/server/auth/github/passport.js.html b/coverage/server/auth/github/passport.js.html index 8baac60..3ccd37e 100644 --- a/coverage/server/auth/github/passport.js.html +++ b/coverage/server/auth/github/passport.js.html @@ -87,13 +87,13 @@

42 43

    -8x -8x -8x -8x +2x +2x +2x +2x   -8x -16x +2x +4x       @@ -175,7 +175,7 @@

diff --git a/coverage/server/auth/index.html b/coverage/server/auth/index.html index b375900..65185b5 100644 --- a/coverage/server/auth/index.html +++ b/coverage/server/auth/index.html @@ -20,28 +20,28 @@

- 83.64% + 63.64% Statements - 46/55 + 35/55
- 43.75% + 6.25% Branches - 7/16 + 1/16
- 92.86% + 57.14% Functions - 13/14 + 8/14
- 87.5% + 64.58% Lines - 42/48 + 31/48
-
+
@@ -60,15 +60,15 @@

- - - - - - - - - + + + + + + + + + @@ -90,7 +90,7 @@

diff --git a/coverage/server/auth/index.js.html b/coverage/server/auth/index.js.html index 22e1092..e212338 100644 --- a/coverage/server/auth/index.js.html +++ b/coverage/server/auth/index.js.html @@ -65,25 +65,25 @@

20 21

auth.service.js
77.5%31/4043.75%7/1692.86%13/1481.82%27/33
50%20/406.25%1/1657.14%8/1448.48%16/33
    -8x -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x +2x     -8x -8x -8x -8x +2x +2x +2x +2x   -8x -8x -8x -8x +2x +2x +2x +2x   -8x
'use strict'
+2x
'use strict'
  
 const router = require('koa-router')()
 const passport = require('koa-passport')
@@ -109,7 +109,7 @@ 

diff --git a/coverage/server/auth/local/index.html b/coverage/server/auth/local/index.html index d916d44..a597a04 100644 --- a/coverage/server/auth/local/index.html +++ b/coverage/server/auth/local/index.html @@ -20,28 +20,28 @@

- 78.43% + 27.45% Statements - 40/51 + 14/51
- 53.85% + 0% Branches - 14/26 + 0/26
- 100% + 50% Functions - 10/10 + 5/10
- 79.17% + 27.08% Lines - 38/48 + 13/48
-
+
@@ -59,29 +59,29 @@

- - - - - - - - - - + + + + + + + + + + - - - - - - - - - - + + + + + + + + + + @@ -90,7 +90,7 @@

diff --git a/coverage/server/auth/local/index.js.html b/coverage/server/auth/local/index.js.html index 93a1788..c149ef0 100644 --- a/coverage/server/auth/local/index.js.html +++ b/coverage/server/auth/local/index.js.html @@ -20,28 +20,28 @@

- 67.86% + 28.57% Statements - 19/28 + 8/28
- 33.33% + 0% Branches - 6/18 + 0/18
- 100% + 42.86% Functions - 7/7 + 3/7
- 69.23% + 30.77% Lines - 18/26 + 8/26
-
+
index.js
67.86%19/2833.33%6/18100%7/769.23%18/26index.js
28.57%8/280%0/1842.86%3/730.77%8/26
passport.js
91.3%21/23100%8/8100%3/390.91%20/22passport.js
26.09%6/230%0/866.67%2/322.73%5/22
1 2 @@ -87,17 +87,17 @@

42 43

    -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x     -34x +6x     -10x +        @@ -106,27 +106,27 @@

      -10x +        -10x -  +      -34x -30x -10x -10x -4x -4x   6x -6x +  +  +  +  +  +  +  +        -8x +2x  

'use strict'
  
 const mongoose = require('mongoose')
@@ -136,10 +136,10 @@ 

const auth = require('../auth.service')   function checkCaptcha() { - return async (ctx, next) => { + return async (ctx, next) => { //测试环境不用验证码 let error_msg - Iif(process.env.NODE_ENV !== 'test' && !ctx.req.headers.jackblog){ + if(process.env.NODE_ENV !== 'test' && !ctx.req.headers.jackblog){ if(!ctx.request.body.captcha){ error_msg = '验证码不能为空.' }else if(ctx.session.captcha !== ctx.request.body.captcha.toLowerCase()){ @@ -148,23 +148,23 @@

error_msg = '用户名和密码不能为空.' } } - Iif(error_msg){ + if(error_msg){ ctx.status = 422 return ctx.body = {error_msg:error_msg} } - await next() + await next() } }   -router.post('/', checkCaptcha(), async (ctx,next) =>{ - await passport.authenticate('local', async (err, user, info)=> { - Iif (err) ctx.throw(err) - if(info){ - ctx.status = 403 - return ctx.body = info +router.post('/', checkCaptcha(), async (ctx,next) =>{ + await passport.authenticate('local', async (err, user, info)=> { + if (err) ctx.throw(err) + if(info){ + ctx.status = 403 + return ctx.body = info } - const token = auth.signToken(user._id) - ctx.body = {token: token} + const token = auth.signToken(user._id) + ctx.body = {token: token} })(ctx, next) })   @@ -175,7 +175,7 @@

diff --git a/coverage/server/auth/local/passport.js.html b/coverage/server/auth/local/passport.js.html index ea79344..4894c45 100644 --- a/coverage/server/auth/local/passport.js.html +++ b/coverage/server/auth/local/passport.js.html @@ -20,28 +20,28 @@

- 91.3% + 26.09% Statements - 21/23 + 6/23
- 100% + 0% Branches - 8/8 + 0/8
- 100% + 66.67% Functions - 3/3 + 2/3
- 90.91% + 22.73% Lines - 20/22 + 5/22
-
+

-	
-	
+	
+	
@@ -90,7 +90,7 @@ 

diff --git a/coverage/server/config/env/index.js.html b/coverage/server/config/env/index.js.html index 5951e84..4f3fa67 100644 --- a/coverage/server/config/env/index.js.html +++ b/coverage/server/config/env/index.js.html @@ -25,9 +25,9 @@

8/8
- 93.48% + 92.86% Branches - 43/46 + 39/42
100% @@ -132,11 +132,11 @@

87 88

- - - - - - - - - - + + + + + + + + + + @@ -103,7 +103,7 @@

diff --git a/coverage/server/model/article.model.js.html b/coverage/server/model/article.model.js.html index 3ba21d9..6501936 100644 --- a/coverage/server/model/article.model.js.html +++ b/coverage/server/model/article.model.js.html @@ -20,9 +20,9 @@

- 100% + 85.71% Statements - 7/7 + 6/7
100% @@ -30,14 +30,14 @@

0/0

- 100% + 0% Functions - 1/1 + 0/1
- 100% + 85.71% Lines - 7/7 + 6/7
@@ -125,10 +125,10 @@

      -8x -8x +2x +2x   -8x +2x       @@ -181,10 +181,10 @@

      -8x +2x     -1x +        @@ -196,8 +196,8 @@

      -8x -8x

1 2 @@ -82,35 +82,35 @@

37 38

    -8x -8x -8x +2x +2x +2x   -8x -26x +2x +4x         -10x -10x -10x -1x -1x +  +  +  +  +    -9x -1x -1x +  +  +    -8x -1x -1x +  +  +    -7x -1x -1x +  +  +    -6x +        @@ -128,26 +128,26 @@

usernameField: 'email', passwordField: 'password' // this is the virtual field on the model }, - async (email, password, done) => { - try { - const user = await User.findOne({email: email.toLowerCase()}) - if (!user) { - logger.error('登录用户名错误',{'username':email}) - return done(null, false, { error_msg: '用户名或密码错误.' }) + async (email, password, done) => { + try { + const user = await User.findOne({email: email.toLowerCase()}) + if (!user) { + logger.error('登录用户名错误',{'username':email}) + return done(null, false, { error_msg: '用户名或密码错误.' }) } - if (!user.authenticate(password)) { - logger.error('登录密码错误',{'username':email}) - return done(null, false, { error_msg: '用户名或密码错误.' }) + if (!user.authenticate(password)) { + logger.error('登录密码错误',{'username':email}) + return done(null, false, { error_msg: '用户名或密码错误.' }) } - if(user.status === 2){ - logger.error('被阻止登录', {'username':email}) - return done(null, false, { error_msg: '用户被阻止登录.' }) + if(user.status === 2){ + logger.error('被阻止登录', {'username':email}) + return done(null, false, { error_msg: '用户被阻止登录.' }) } - if(user.status === 0){ - logger.error('未验证用户登录',{'username':email}) - return done(null, false, { error_msg: '用户未验证.' }) + if(user.status === 0){ + logger.error('未验证用户登录',{'username':email}) + return done(null, false, { error_msg: '用户未验证.' }) } - return done(null, user) + return done(null, user) } catch (err) { logger.debug('LocalStrategy error') return done(err) @@ -160,7 +160,7 @@

diff --git a/coverage/server/auth/qq/index.html b/coverage/server/auth/qq/index.html index c7097d3..d39e3d8 100644 --- a/coverage/server/auth/qq/index.html +++ b/coverage/server/auth/qq/index.html @@ -90,7 +90,7 @@

diff --git a/coverage/server/auth/qq/index.js.html b/coverage/server/auth/qq/index.js.html index 4ade2c3..528da97 100644 --- a/coverage/server/auth/qq/index.js.html +++ b/coverage/server/auth/qq/index.js.html @@ -82,15 +82,15 @@

37 38

    -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x       -24x +6x       @@ -116,7 +116,7 @@

      -8x +2x  

'use strict'
  
 const router = require('koa-router')()
@@ -160,7 +160,7 @@ 

diff --git a/coverage/server/auth/qq/passport.js.html b/coverage/server/auth/qq/passport.js.html index a59178e..62caed1 100644 --- a/coverage/server/auth/qq/passport.js.html +++ b/coverage/server/auth/qq/passport.js.html @@ -91,13 +91,13 @@

46 47

    -8x -8x -8x -8x +2x +2x +2x +2x   -8x -16x +2x +4x       @@ -187,7 +187,7 @@

diff --git a/coverage/server/auth/weibo/index.html b/coverage/server/auth/weibo/index.html index 0cc8d17..0b466cf 100644 --- a/coverage/server/auth/weibo/index.html +++ b/coverage/server/auth/weibo/index.html @@ -90,7 +90,7 @@

diff --git a/coverage/server/auth/weibo/index.js.html b/coverage/server/auth/weibo/index.js.html index a5d503c..4f25b7d 100644 --- a/coverage/server/auth/weibo/index.js.html +++ b/coverage/server/auth/weibo/index.js.html @@ -82,15 +82,15 @@

37 38

    -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x       -24x +6x       @@ -116,7 +116,7 @@

      -8x +2x  

'use strict'
  
 const router = require('koa-router')()
@@ -160,7 +160,7 @@ 

diff --git a/coverage/server/auth/weibo/passport.js.html b/coverage/server/auth/weibo/passport.js.html index cb323a6..e1a61d4 100644 --- a/coverage/server/auth/weibo/passport.js.html +++ b/coverage/server/auth/weibo/passport.js.html @@ -86,13 +86,13 @@

41 42

    -8x -8x -8x -8x +2x +2x +2x +2x   -8x -16x +2x +4x       @@ -172,7 +172,7 @@

diff --git a/coverage/server/config/env/index.html b/coverage/server/config/env/index.html index c7ca1ad..41316e6 100644 --- a/coverage/server/config/env/index.html +++ b/coverage/server/config/env/index.html @@ -25,9 +25,9 @@

9/9
- 93.75% + 93.18% Branches - 45/48 + 41/44
100% @@ -63,8 +63,8 @@

100% 8/893.48%43/4692.86%39/42 100% 0/0 100%    -8x -8x -8x +2x +2x +2x   -8x +2x       @@ -211,12 +211,12 @@

      -8x +2x   -8x -8x +2x +2x   -8x +2x  

'use strict'
  
 var path = require('path')
@@ -231,8 +231,8 @@ 

mongo: { options: { useMongoClient: true, - user: process.env.MONGO_USERNAME || '', - pass: process.env.MONGO_PASSWORD || '' + // user: process.env.MONGO_USERNAME || '', + // pass: process.env.MONGO_PASSWORD || '' } }, //redis 配置 @@ -310,7 +310,7 @@

diff --git a/coverage/server/config/env/test.js.html b/coverage/server/config/env/test.js.html index ec28be8..4939e1e 100644 --- a/coverage/server/config/env/test.js.html +++ b/coverage/server/config/env/test.js.html @@ -64,7 +64,7 @@

      -8x +2x       @@ -83,7 +83,7 @@

// =========================== module.exports = { mongo: { - uri: 'mongodb://localhost/jackblog-test' + uri: `mongodb://${null}:${null}@localhost:27017/jackblog-test` }, redis: { db: 2, @@ -100,7 +100,7 @@

diff --git a/coverage/server/config/index.html b/coverage/server/config/index.html index de74ebb..2bcbfed 100644 --- a/coverage/server/config/index.html +++ b/coverage/server/config/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/server/config/koa.js.html b/coverage/server/config/koa.js.html index e05d3e2..228906f 100644 --- a/coverage/server/config/koa.js.html +++ b/coverage/server/config/koa.js.html @@ -82,30 +82,30 @@

37 38

    -8x -8x -8x -8x -8x -8x -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x   -8x -8x +2x +2x       -8x +2x     -8x -8x -8x -8x +2x +2x +2x +2x       @@ -114,8 +114,8 @@

      -8x -8x +2x +2x    

'use strict'
  
@@ -160,7 +160,7 @@ 

diff --git a/coverage/server/connect.js.html b/coverage/server/connect.js.html index 9275f88..06b96c4 100644 --- a/coverage/server/connect.js.html +++ b/coverage/server/connect.js.html @@ -59,23 +59,23 @@

14 15 16 -17

8x -8x -8x -8x +172x +2x +2x +2x     -8x -8x -8x -48x -48x +2x +2x +2x +12x +12x       -8x +2x   -8x
const path = require('path')
+2x
const path = require('path')
 const fs = require('fs')
 const mongoose = require('mongoose')
 const config = require('./config/env')
@@ -97,7 +97,7 @@ 

diff --git a/coverage/server/index.html b/coverage/server/index.html index a2dafe2..d371a6d 100644 --- a/coverage/server/index.html +++ b/coverage/server/index.html @@ -20,24 +20,24 @@

- 92% + 86% Statements - 46/50 + 43/50
- 50% + 37.5% Branches - 4/8 + 3/8
- 83.33% + 50% Functions - 5/6 + 3/6
- 92% + 86% Lines - 46/50 + 43/50
@@ -59,16 +59,16 @@

app.js
85%17/2050%3/6100%3/385%17/20app.js
70%14/2033.33%2/633.33%1/370%14/20
/** 
+2x
+2x
/** 
  * 文章表
  */
 'use strict'
@@ -260,8 +260,8 @@ 

  ArticleSchema .virtual('info') - .get(function() { - return { + .get(function() { + return { '_id': this._id, 'title': this.title, 'content': this.content, @@ -280,7 +280,7 @@

diff --git a/coverage/server/model/comment.model.js.html b/coverage/server/model/comment.model.js.html index 724dcfa..045bd43 100644 --- a/coverage/server/model/comment.model.js.html +++ b/coverage/server/model/comment.model.js.html @@ -87,10 +87,10 @@

      -8x -8x +2x +2x   -8x +2x       @@ -120,8 +120,8 @@

      -8x -8x

/**
+2x
+2x
/**
  * 评论表
  */
 'use strict'
@@ -166,7 +166,7 @@ 

diff --git a/coverage/server/model/index.html b/coverage/server/model/index.html index f0869da..25a4358 100644 --- a/coverage/server/model/index.html +++ b/coverage/server/model/index.html @@ -20,28 +20,28 @@

- 90.63% + 60.94% Statements - 58/64 + 39/64
- 66.67% + 0% Branches - 8/12 + 0/12
- 75% + 0% Functions - 9/12 + 0/12
- 93.44% + 63.93% Lines - 57/61 + 39/61
-
+
@@ -60,15 +60,15 @@

- - - + + + - - - - + + + + @@ -124,16 +124,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -142,7 +142,7 @@

diff --git a/coverage/server/model/logs.model.js.html b/coverage/server/model/logs.model.js.html index b2b9aac..d1a6674 100644 --- a/coverage/server/model/logs.model.js.html +++ b/coverage/server/model/logs.model.js.html @@ -67,10 +67,10 @@

22 23

article.model.js
100%7/7
85.71%6/7 100% 0/0100%1/1100%7/70%0/185.71%6/7
user.model.js
83.78%31/3766.67%8/1272.73%8/1188.24%30/34user.model.js
35.14%13/370%0/120%0/1138.24%13/34
    -8x -8x +2x +2x   -8x +2x       @@ -86,8 +86,8 @@

      -8x -8x

'use strict'
+2x
+2x
'use strict'
  
 const mongoose = require('mongoose')
 const	Schema = mongoose.Schema
@@ -115,7 +115,7 @@ 

diff --git a/coverage/server/model/tag.category.model.js.html b/coverage/server/model/tag.category.model.js.html index 2a7de2e..99ff788 100644 --- a/coverage/server/model/tag.category.model.js.html +++ b/coverage/server/model/tag.category.model.js.html @@ -65,10 +65,10 @@

      -8x -8x +2x +2x   -8x +2x       @@ -76,8 +76,8 @@

      -8x -8x

/**
+2x
+2x
/**
  * 标签分类表,管理标签
  */
 'use strict'
@@ -100,7 +100,7 @@ 

diff --git a/coverage/server/model/tag.model.js.html b/coverage/server/model/tag.model.js.html index b9f178f..139a554 100644 --- a/coverage/server/model/tag.model.js.html +++ b/coverage/server/model/tag.model.js.html @@ -82,10 +82,10 @@

      -8x -8x +2x +2x   -8x +2x       @@ -108,8 +108,8 @@

      -8x -8x

/**
+2x
+2x
/**
  * 标签表
  */
  
@@ -148,7 +148,7 @@ 

diff --git a/coverage/server/model/user.model.js.html b/coverage/server/model/user.model.js.html index 1dd2f43..9664f18 100644 --- a/coverage/server/model/user.model.js.html +++ b/coverage/server/model/user.model.js.html @@ -20,28 +20,28 @@

- 83.78% + 35.14% Statements - 31/37 + 13/37
- 66.67% + 0% Branches - 8/12 + 0/12
- 72.73% + 0% Functions - 8/11 + 0/11
- 88.24% + 38.24% Lines - 30/34 + 13/34
-
+
1 2 @@ -224,11 +224,11 @@

      -8x -8x -8x +2x +2x +2x   -8x +2x       @@ -305,22 +305,22 @@

      -8x +2x     -11x -11x -11x +  +  +              -8x +2x     -2x +        @@ -330,10 +330,10 @@

      -8x +2x     -1x +        @@ -344,7 +344,7 @@

      -8x +2x       @@ -353,23 +353,23 @@

      -8x +2x     -15x -15x -15x -15x -4x -3x +  +  +  +  +  +    -11x +            -8x +2x       @@ -377,24 +377,24 @@

      -9x +        -11x +        -20x -20x -20x +  +  +        -8x +2x   -8x -8x +2x +2x  

/** 
  * 用户表
  */
@@ -483,10 +483,10 @@ 

*/ UserSchema .virtual('password') - .set(function(password) { - this._password = password - this.salt = this.makeSalt() - this.hashedPassword = this.encryptPassword(password) + .set(function(password) { + this._password = password + this.salt = this.makeSalt() + this.hashedPassword = this.encryptPassword(password) }) .get(function() { return this._password @@ -495,8 +495,8 @@

  UserSchema .virtual('userInfo') - .get(function() { - return { + .get(function() { + return { 'nickname': this.nickname, 'role': this.role, 'email': this.email, @@ -508,8 +508,8 @@

  UserSchema .virtual('providerInfo') - .get(function() { - return { + .get(function() { + return { 'qq': this.qq, 'github': this.github, 'weibo': this.weibo, @@ -531,15 +531,15 @@

  UserSchema .path('nickname') - .validate(function(value, respond) { - var self = this - this.constructor.findOne({nickname: value}, function(err, user) { - Iif(err) throw err - if(user) { - if(self.id === user.id) return respond(true) - return respond(false) + .validate(function(value, respond) { + var self = this + this.constructor.findOne({nickname: value}, function(err, user) { + if(err) throw err + if(user) { + if(self.id === user.id) return respond(true) + return respond(false) } - respond(true) + respond(true) }) }, '这个呢称已经被使用.') /** @@ -552,18 +552,18 @@

return (selfRoles.indexOf('admin') !== -1 || selfRoles.indexOf(role) !== -1) }, //验证用户密码 - authenticate: function(plainText) { - return this.encryptPassword(plainText) === this.hashedPassword + authenticate: function(plainText) { + return this.encryptPassword(plainText) === this.hashedPassword }, //生成盐 - makeSalt: function() { - return crypto.randomBytes(16).toString('base64') + makeSalt: function() { + return crypto.randomBytes(16).toString('base64') }, //生成密码 - encryptPassword: function(password) { - Iif (!password || !this.salt) return '' - var salt = new Buffer(this.salt, 'base64') - return crypto.pbkdf2Sync(password, salt, 10000, 64, 'sha1').toString('base64') + encryptPassword: function(password) { + if (!password || !this.salt) return '' + var salt = new Buffer(this.salt, 'base64') + return crypto.pbkdf2Sync(password, salt, 10000, 64, 'sha1').toString('base64') } }   @@ -577,7 +577,7 @@

diff --git a/coverage/server/routes.js.html b/coverage/server/routes.js.html index 9341923..8ebb5d4 100644 --- a/coverage/server/routes.js.html +++ b/coverage/server/routes.js.html @@ -65,27 +65,27 @@

20 21 22 -23

8x -8x -8x -8x -8x -8x -8x -8x +232x +2x +2x +2x +2x +2x +2x +2x   -8x -8x -8x -8x -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x +2x +2x +2x +2x     -8x +2x    
const Router = require('koa-router')()
 const logs = require('./api/logs')
@@ -115,7 +115,7 @@ 

diff --git a/coverage/server/util/debug/index.html b/coverage/server/util/debug/index.html index 80512fe..68402bb 100644 --- a/coverage/server/util/debug/index.html +++ b/coverage/server/util/debug/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/server/util/debug/index.js.html b/coverage/server/util/debug/index.js.html index fb3a671..1e402e4 100644 --- a/coverage/server/util/debug/index.js.html +++ b/coverage/server/util/debug/index.js.html @@ -51,10 +51,10 @@

6 7

    -8x +2x   -8x -48x +2x +12x  
'use strict'
  
 const pkg = require('../../../package.json')
@@ -67,7 +67,7 @@ 

diff --git a/coverage/server/util/error/index.html b/coverage/server/util/error/index.html index 2c749b6..8338860 100644 --- a/coverage/server/util/error/index.html +++ b/coverage/server/util/error/index.html @@ -20,28 +20,28 @@

- 100% + 28.57% Statements - 14/14 + 4/14
- 75% + 0% Branches - 6/8 + 0/8
- 100% + 50% Functions - 4/4 + 2/4
- 100% + 28.57% Lines - 14/14 + 4/14
-
+
@@ -59,16 +59,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -77,7 +77,7 @@

diff --git a/coverage/server/util/error/index.js.html b/coverage/server/util/error/index.js.html index 8b03d4c..a9122ed 100644 --- a/coverage/server/util/error/index.js.html +++ b/coverage/server/util/error/index.js.html @@ -20,28 +20,28 @@

- 100% + 28.57% Statements - 14/14 + 4/14
- 75% + 0% Branches - 6/8 + 0/8
- 100% + 50% Functions - 4/4 + 2/4
- 100% + 28.57% Lines - 14/14 + 4/14
-
+
index.js
100%14/1475%6/8100%4/4100%14/14index.js
28.57%4/140%0/850%2/428.57%4/14
1 2 @@ -65,46 +65,46 @@

20 21 22 -23

8x +232x   -8x -117x -93x -93x +2x +6x +  +    -10x -10x -10x -3x -3x -3x +  +  +  +  +  +        -10x -10x +  +          -8x
const _ = require('lodash')
+2x
const _ = require('lodash')
  
 const errorHandleMiddle = function () {
-	return async (ctx, next) => {
-	  try {
-	    await next()
+	return async (ctx, next) => {
+	  try {
+	    await next()
 	  } catch (err) {
-	    ctx.status = err.status || 500
-	    let error_msg = err.message
-	    if(err.errors && typeof(err.errors) === 'object'){
-	    	_.mapValues(err.errors, (item)=>{
-	    		Eif(item.message){
-	    			error_msg = item.message
+	    ctx.status = err.status || 500
+	    let error_msg = err.message
+	    if(err.errors && typeof(err.errors) === 'object'){
+	    	_.mapValues(err.errors, (item)=>{
+	    		if(item.message){
+	    			error_msg = item.message
 	    		}
 	    	})
 	    }
-	    ctx.body = {error_msg: error_msg}
-	    ctx.app.emit('error', err, ctx)
+	    ctx.body = {error_msg: error_msg}
+	    ctx.app.emit('error', err, ctx)
 	  }
 	}
 }
@@ -115,7 +115,7 @@ 

diff --git a/coverage/server/util/logs/index.html b/coverage/server/util/logs/index.html index 6016c9f..7a660f9 100644 --- a/coverage/server/util/logs/index.html +++ b/coverage/server/util/logs/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/server/util/logs/index.js.html b/coverage/server/util/logs/index.js.html index cf69383..0967037 100644 --- a/coverage/server/util/logs/index.js.html +++ b/coverage/server/util/logs/index.js.html @@ -81,11 +81,11 @@

36 37

    -8x -8x -8x +2x +2x +2x   -8x +2x       @@ -114,7 +114,7 @@

      -8x +2x  

'use strict'
  
 const path = require('path')
@@ -157,7 +157,7 @@ 

diff --git a/coverage/server/util/qiniu/index.html b/coverage/server/util/qiniu/index.html index 4e89338..544a02c 100644 --- a/coverage/server/util/qiniu/index.html +++ b/coverage/server/util/qiniu/index.html @@ -20,28 +20,28 @@

- 100% + 58.82% Statements - 51/51 + 30/51
- 100% + 0% Branches - 2/2 + 0/2
- 100% + 0% Functions - 13/13 + 0/13
- 100% + 58.82% Lines - 51/51 + 30/51
-
+
@@ -59,16 +59,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -77,7 +77,7 @@

diff --git a/coverage/server/util/qiniu/index.js.html b/coverage/server/util/qiniu/index.js.html index 168d4ab..e1c8096 100644 --- a/coverage/server/util/qiniu/index.js.html +++ b/coverage/server/util/qiniu/index.js.html @@ -20,28 +20,28 @@

- 100% + 58.82% Statements - 51/51 + 30/51
- 100% + 0% Branches - 2/2 + 0/2
- 100% + 0% Functions - 13/13 + 0/13
- 100% + 58.82% Lines - 51/51 + 30/51
-
+
index.js
100%51/51100%2/2100%13/13100%51/51index.js
58.82%30/510%0/20%0/1358.82%30/51
1 2 @@ -133,79 +133,79 @@

88 89

    -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x   -8x -8x -8x +2x +2x +2x     -8x -8x -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x +2x +2x   -8x -8x -8x -8x -8x -8x -8x +2x +2x +2x +2x +2x +2x +2x       -1x -1x +  +      -8x -8x +2x +2x   -8x -1x -1x -1x +2x +  +  +          -8x -1x -1x -1x -1x -1x +2x +  +  +  +  +          -8x +2x   -1x -1x -1x +  +  +        -8x +2x   -1x -1x -1x +  +  +        -8x -1x -1x +2x +  +        @@ -214,10 +214,10 @@

      -8x -1x -1x -1x +2x +  +  +     

'use strict'
  
@@ -249,51 +249,51 @@ 

exports.allList = allList   //获取上传凭证 -function getUptoken(bucketname) { - var putPolicy = new qiniu.rs.PutPolicy(bucketname) - return putPolicy.token() +function getUptoken(bucketname) { + var putPolicy = new qiniu.rs.PutPolicy(bucketname) + return putPolicy.token() } //不同空间可以相互操作,在这里只在一个空间下操作 var bucket = config.qiniu.bucket exports.bucket = bucket //将网络图片上传到七牛服务器 -exports.fetch = function (url,key) { - return this.fetchFile(url,bucket,key).then(function (result) { - result.url = config.qiniu.domain + result.key - return result +exports.fetch = function (url,key) { + return this.fetchFile(url,bucket,key).then(function (result) { + result.url = config.qiniu.domain + result.key + return result }) }   //上传文件 -exports.upload = function (path,key) { - var extra = new qiniu.io.PutExtra() - var uptoken = getUptoken(config.qiniu.bucket) - return this.uploadFile(uptoken, key, path, extra).then(function(result){ - result.url = config.qiniu.domain + result.key - return result +exports.upload = function (path,key) { + var extra = new qiniu.io.PutExtra() + var uptoken = getUptoken(config.qiniu.bucket) + return this.uploadFile(uptoken, key, path, extra).then(function(result){ + result.url = config.qiniu.domain + result.key + return result }) }   //将源空间的指定资源移动到目标空间,或在同一空间内对资源重命名。 -exports.move = function(keySrc,keyDest){ +exports.move = function(keySrc,keyDest){ var bucketSrc,bucketDest - bucketSrc = bucketDest = bucket - return this.moveFile(bucketSrc, keySrc, bucketDest, keyDest).then(function (result) { - return result + bucketSrc = bucketDest = bucket + return this.moveFile(bucketSrc, keySrc, bucketDest, keyDest).then(function (result) { + return result }) } //复制文件 -exports.copy = function(keySrc,keyDest){ +exports.copy = function(keySrc,keyDest){ var bucketSrc,bucketDest - bucketSrc = bucketDest = bucket - return this.copyFile(bucketSrc, keySrc, bucketDest, keyDest).then(function (result) { - return result + bucketSrc = bucketDest = bucket + return this.copyFile(bucketSrc, keySrc, bucketDest, keyDest).then(function (result) { + return result }) }   -exports.remove = function(key){ - return this.removeFile(bucket,key).then(function (result) { - return result +exports.remove = function(key){ + return this.removeFile(bucket,key).then(function (result) { + return result }) } /* @@ -302,10 +302,10 @@

marker 上一次列举返回的位置标记,作为本次列举的起点信息。缺省值为空字符串 delimiter 指定目录分隔符,列出所有公共前缀(模拟列出目录效果)。默认值为空字符串。 */ -exports.list = function(prefix, marker, limit, delimiter){ - var delimiter = delimiter || '' - return this.allList(bucket, prefix, marker, limit, delimiter).then(function(result){ - return result +exports.list = function(prefix, marker, limit, delimiter){ + var delimiter = delimiter || '' + return this.allList(bucket, prefix, marker, limit, delimiter).then(function(result){ + return result }) }

@@ -313,7 +313,7 @@

diff --git a/coverage/server/util/redis/index.html b/coverage/server/util/redis/index.html index 5752ef8..f31bd9c 100644 --- a/coverage/server/util/redis/index.html +++ b/coverage/server/util/redis/index.html @@ -77,7 +77,7 @@

diff --git a/coverage/server/util/redis/index.js.html b/coverage/server/util/redis/index.js.html index 0e27a99..b696ac0 100644 --- a/coverage/server/util/redis/index.js.html +++ b/coverage/server/util/redis/index.js.html @@ -58,18 +58,18 @@

13 14

    -8x -8x -8x -8x +2x +2x +2x +2x   -8x +2x   -8x +2x       -8x
'use strict'
+2x
'use strict'
  
 const _ = require('lodash')
 const Redis = require('ioredis')
@@ -88,7 +88,7 @@ 

diff --git a/coverage/server/util/tools/index.html b/coverage/server/util/tools/index.html index f7826d1..2ec361f 100644 --- a/coverage/server/util/tools/index.html +++ b/coverage/server/util/tools/index.html @@ -20,28 +20,28 @@

- 100% + 15.79% Statements - 19/19 + 3/19
- 80% + 0% Branches - 8/10 + 0/10
- 100% + 0% Functions - 3/3 + 0/3
- 100% + 15.79% Lines - 19/19 + 3/19
-
+
@@ -59,16 +59,16 @@

- - - - - - - - - - + + + + + + + + + + @@ -77,7 +77,7 @@

diff --git a/coverage/server/util/tools/index.js.html b/coverage/server/util/tools/index.js.html index 597835b..7e92cfe 100644 --- a/coverage/server/util/tools/index.js.html +++ b/coverage/server/util/tools/index.js.html @@ -20,28 +20,28 @@

- 100% + 15.79% Statements - 19/19 + 3/19
- 80% + 0% Branches - 8/10 + 0/10
- 100% + 0% Functions - 3/3 + 0/3
- 100% + 15.79% Lines - 19/19 + 3/19
-
+
index.js
100%19/1980%8/10100%3/3100%19/19index.js
15.79%3/190%0/100%0/315.79%3/19
1 2 @@ -75,63 +75,63 @@

30 31

    -9x +3x   -9x -2x -2x -2x -2x -2x -18x +3x +  +  +  +  +  +    -2x +      -9x -5x -5x -5x -4x -4x -4x +3x +  +  +  +  +  +    -4x -4x +  +        -5x +     
"use strict"
  
 const _ = require('lodash')
 //生成随机字符串
-exports.randomString = function (len) {
-	len = len || 12
-	const $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'    /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
-	const maxPos = $chars.length
-	let pwd = ''
-  for (let i = 0; i < len; i++) {
-    pwd += $chars.charAt(Math.floor(Math.random() * maxPos))
+exports.randomString = function (len) {
+	len = len || 12
+	const $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'    /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
+	const maxPos = $chars.length
+	let pwd = ''
+  for (let i = 0; i < len; i++) {
+    pwd += $chars.charAt(Math.floor(Math.random() * maxPos))
   }
- return pwd
+ return pwd
 }
 //从markdown中提取图片
-exports.extractImage = function (content) {
-  let results = []
-	const images = content.match(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g)
-	if(_.isArray(images) && images.length > 0){
-		for(let i = 0,j = images.length;i<j;i++){
-			var url = images[i].replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/,function ($1,m1,m2,m3,m4) {
-				return m4 || ''
+exports.extractImage = function (content) {
+  let results = []
+	const images = content.match(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g)
+	if(_.isArray(images) && images.length > 0){
+		for(let i = 0,j = images.length;i<j;i++){
+			var url = images[i].replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/,function ($1,m1,m2,m3,m4) {
+				return m4 || ''
 			})
-			Eif(url !== ''){
-				results.push({url:url})
+			if(url !== ''){
+				results.push({url:url})
 			}
 		}
 	}
-	return results
+	return results
 }
  
@@ -139,7 +139,7 @@

diff --git a/logs/production-error.log.0 b/logs/production-error.log.0 new file mode 100644 index 0000000..e69de29 diff --git a/logs/test-error.log.0 b/logs/test-error.log.0 index d67988f..41a9da7 100644 --- a/logs/test-error.log.0 +++ b/logs/test-error.log.0 @@ -1,8 +1,4 @@ -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":24415,"level":50,"msg":"登录密码错误 { username: 'test011499766253597@tets.com' }","time":"2017-07-11T09:44:31.958Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":24415,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-07-11T09:44:31.982Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":24415,"level":50,"msg":"未验证用户登录 { username: 'test021499766253597@tets.com' }","time":"2017-07-11T09:44:32.032Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":24415,"level":50,"msg":"被阻止登录 { username: 'test031499766253597@tets.com' }","time":"2017-07-11T09:44:32.084Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28165,"level":50,"msg":"登录密码错误 { username: 'test011499770200186@tets.com' }","time":"2017-07-11T10:50:10.957Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28165,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-07-11T10:50:10.980Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28165,"level":50,"msg":"未验证用户登录 { username: 'test021499770200186@tets.com' }","time":"2017-07-11T10:50:11.038Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28165,"level":50,"msg":"被阻止登录 { username: 'test031499770200186@tets.com' }","time":"2017-07-11T10:50:11.093Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":33341,"level":50,"msg":"登录密码错误 { username: 'test011499850069777@tets.com' }","time":"2017-07-12T09:01:39.811Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":33341,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-07-12T09:01:39.838Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":33341,"level":50,"msg":"未验证用户登录 { username: 'test021499850069777@tets.com' }","time":"2017-07-12T09:01:39.897Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":33341,"level":50,"msg":"被阻止登录 { username: 'test031499850069777@tets.com' }","time":"2017-07-12T09:01:39.971Z","v":0} diff --git a/logs/test-error.log.1 b/logs/test-error.log.1 index ce8d230..d67988f 100644 --- a/logs/test-error.log.1 +++ b/logs/test-error.log.1 @@ -1,12 +1,8 @@ -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":9986,"level":50,"msg":"登录密码错误 { username: 'test011499655931026@tets.com' }","time":"2017-07-10T03:05:40.464Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":9986,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-07-10T03:05:40.487Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":9986,"level":50,"msg":"未验证用户登录 { username: 'test021499655931027@tets.com' }","time":"2017-07-10T03:05:40.542Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":9986,"level":50,"msg":"被阻止登录 { username: 'test031499655931027@tets.com' }","time":"2017-07-10T03:05:40.600Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11114,"level":50,"msg":"登录密码错误 { username: 'test011499657034522@tets.com' }","time":"2017-07-10T03:24:03.768Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11114,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-07-10T03:24:03.792Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11114,"level":50,"msg":"未验证用户登录 { username: 'test021499657034522@tets.com' }","time":"2017-07-10T03:24:03.846Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11114,"level":50,"msg":"被阻止登录 { username: 'test031499657034522@tets.com' }","time":"2017-07-10T03:24:03.899Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11592,"level":50,"msg":"登录密码错误 { username: 'test011499657360204@tets.com' }","time":"2017-07-10T03:29:30.506Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11592,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-07-10T03:29:30.529Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11592,"level":50,"msg":"未验证用户登录 { username: 'test021499657360204@tets.com' }","time":"2017-07-10T03:29:30.587Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11592,"level":50,"msg":"被阻止登录 { username: 'test031499657360204@tets.com' }","time":"2017-07-10T03:29:30.637Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":24415,"level":50,"msg":"登录密码错误 { username: 'test011499766253597@tets.com' }","time":"2017-07-11T09:44:31.958Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":24415,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-07-11T09:44:31.982Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":24415,"level":50,"msg":"未验证用户登录 { username: 'test021499766253597@tets.com' }","time":"2017-07-11T09:44:32.032Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":24415,"level":50,"msg":"被阻止登录 { username: 'test031499766253597@tets.com' }","time":"2017-07-11T09:44:32.084Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28165,"level":50,"msg":"登录密码错误 { username: 'test011499770200186@tets.com' }","time":"2017-07-11T10:50:10.957Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28165,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-07-11T10:50:10.980Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28165,"level":50,"msg":"未验证用户登录 { username: 'test021499770200186@tets.com' }","time":"2017-07-11T10:50:11.038Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28165,"level":50,"msg":"被阻止登录 { username: 'test031499770200186@tets.com' }","time":"2017-07-11T10:50:11.093Z","v":0} diff --git a/logs/test-error.log.2 b/logs/test-error.log.2 index 4eb111a..ce8d230 100644 --- a/logs/test-error.log.2 +++ b/logs/test-error.log.2 @@ -1,24 +1,12 @@ -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62467,"level":50,"msg":"登录密码错误 { username: 'test011495354154466@tets.com' }","time":"2017-05-21T08:09:23.413Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62467,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-21T08:09:23.436Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62467,"level":50,"msg":"未验证用户登录 { username: 'test021495354154466@tets.com' }","time":"2017-05-21T08:09:23.494Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62467,"level":50,"msg":"被阻止登录 { username: 'test031495354154466@tets.com' }","time":"2017-05-21T08:09:23.553Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62815,"level":50,"msg":"登录密码错误 { username: 'test011495354357182@tets.com' }","time":"2017-05-21T08:12:50.188Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62815,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-21T08:12:50.214Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62815,"level":50,"msg":"未验证用户登录 { username: 'test021495354357182@tets.com' }","time":"2017-05-21T08:12:50.270Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62815,"level":50,"msg":"被阻止登录 { username: 'test031495354357182@tets.com' }","time":"2017-05-21T08:12:50.332Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62931,"level":50,"msg":"登录密码错误 { username: 'test011495354411139@tets.com' }","time":"2017-05-21T08:13:48.790Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62931,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-21T08:13:48.832Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62931,"level":50,"msg":"未验证用户登录 { username: 'test021495354411139@tets.com' }","time":"2017-05-21T08:13:48.903Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62931,"level":50,"msg":"被阻止登录 { username: 'test031495354411139@tets.com' }","time":"2017-05-21T08:13:48.983Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":66009,"level":50,"msg":"登录密码错误 { username: 'test011495356424433@tets.com' }","time":"2017-05-21T08:47:15.944Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":66009,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-21T08:47:15.970Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":66009,"level":50,"msg":"未验证用户登录 { username: 'test021495356424433@tets.com' }","time":"2017-05-21T08:47:16.040Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":66009,"level":50,"msg":"被阻止登录 { username: 'test031495356424433@tets.com' }","time":"2017-05-21T08:47:16.098Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67168,"level":50,"msg":"登录密码错误 { username: 'test011495357248958@tets.com' }","time":"2017-05-21T09:00:59.330Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67168,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-21T09:00:59.352Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67168,"level":50,"msg":"未验证用户登录 { username: 'test021495357248958@tets.com' }","time":"2017-05-21T09:00:59.431Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67168,"level":50,"msg":"被阻止登录 { username: 'test031495357248958@tets.com' }","time":"2017-05-21T09:00:59.487Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67417,"level":50,"msg":"登录密码错误 { username: 'test011495357436866@tets.com' }","time":"2017-05-21T09:04:07.099Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67417,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-21T09:04:07.119Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67417,"level":50,"msg":"未验证用户登录 { username: 'test021495357436866@tets.com' }","time":"2017-05-21T09:04:07.166Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67417,"level":50,"msg":"被阻止登录 { username: 'test031495357436866@tets.com' }","time":"2017-05-21T09:04:07.232Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":9986,"level":50,"msg":"登录密码错误 { username: 'test011499655931026@tets.com' }","time":"2017-07-10T03:05:40.464Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":9986,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-07-10T03:05:40.487Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":9986,"level":50,"msg":"未验证用户登录 { username: 'test021499655931027@tets.com' }","time":"2017-07-10T03:05:40.542Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":9986,"level":50,"msg":"被阻止登录 { username: 'test031499655931027@tets.com' }","time":"2017-07-10T03:05:40.600Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11114,"level":50,"msg":"登录密码错误 { username: 'test011499657034522@tets.com' }","time":"2017-07-10T03:24:03.768Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11114,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-07-10T03:24:03.792Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11114,"level":50,"msg":"未验证用户登录 { username: 'test021499657034522@tets.com' }","time":"2017-07-10T03:24:03.846Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11114,"level":50,"msg":"被阻止登录 { username: 'test031499657034522@tets.com' }","time":"2017-07-10T03:24:03.899Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11592,"level":50,"msg":"登录密码错误 { username: 'test011499657360204@tets.com' }","time":"2017-07-10T03:29:30.506Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11592,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-07-10T03:29:30.529Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11592,"level":50,"msg":"未验证用户登录 { username: 'test021499657360204@tets.com' }","time":"2017-07-10T03:29:30.587Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":11592,"level":50,"msg":"被阻止登录 { username: 'test031499657360204@tets.com' }","time":"2017-07-10T03:29:30.637Z","v":0} diff --git a/logs/test-error.log.3 b/logs/test-error.log.3 index 065f4b4..4eb111a 100644 --- a/logs/test-error.log.3 +++ b/logs/test-error.log.3 @@ -1,36 +1,24 @@ -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":27482,"level":50,"msg":"登录密码错误 { username: 'test011493716797472@tets.com' }","time":"2017-05-02T09:20:04.338Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":27482,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:20:04.491Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":27482,"level":50,"msg":"未验证用户登录 { username: 'test021493716797472@tets.com' }","time":"2017-05-02T09:20:04.717Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":27482,"level":50,"msg":"被阻止登录 { username: 'test031493716797472@tets.com' }","time":"2017-05-02T09:20:04.946Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28034,"level":50,"msg":"登录密码错误 { username: 'test011493717239796@tets.com' }","time":"2017-05-02T09:27:25.905Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28034,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:27:25.934Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28034,"level":50,"msg":"未验证用户登录 { username: 'test021493717239796@tets.com' }","time":"2017-05-02T09:27:26.005Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28034,"level":50,"msg":"被阻止登录 { username: 'test031493717239796@tets.com' }","time":"2017-05-02T09:27:26.063Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29060,"level":50,"msg":"登录密码错误 { username: 'test011493718010690@tets.com' }","time":"2017-05-02T09:40:16.381Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29060,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:40:16.434Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29060,"level":50,"msg":"未验证用户登录 { username: 'test021493718010690@tets.com' }","time":"2017-05-02T09:40:16.514Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29060,"level":50,"msg":"被阻止登录 { username: 'test031493718010690@tets.com' }","time":"2017-05-02T09:40:16.598Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29203,"level":50,"msg":"登录密码错误 { username: 'test011493718135453@tets.com' }","time":"2017-05-02T09:42:21.988Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29203,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:42:22.014Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29203,"level":50,"msg":"未验证用户登录 { username: 'test021493718135453@tets.com' }","time":"2017-05-02T09:42:22.094Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29203,"level":50,"msg":"被阻止登录 { username: 'test031493718135453@tets.com' }","time":"2017-05-02T09:42:22.158Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29374,"level":50,"msg":"登录密码错误 { username: 'test011493718264152@tets.com' }","time":"2017-05-02T09:44:29.614Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29374,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:44:29.666Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29374,"level":50,"msg":"未验证用户登录 { username: 'test021493718264152@tets.com' }","time":"2017-05-02T09:44:29.757Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29374,"level":50,"msg":"被阻止登录 { username: 'test031493718264152@tets.com' }","time":"2017-05-02T09:44:29.838Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29449,"level":50,"msg":"登录密码错误 { username: 'test011493718324275@tets.com' }","time":"2017-05-02T09:45:29.233Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29449,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:45:29.265Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29449,"level":50,"msg":"未验证用户登录 { username: 'test021493718324275@tets.com' }","time":"2017-05-02T09:45:29.338Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29449,"level":50,"msg":"被阻止登录 { username: 'test031493718324275@tets.com' }","time":"2017-05-02T09:45:29.399Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29556,"level":50,"msg":"登录密码错误 { username: 'test011493718403340@tets.com' }","time":"2017-05-02T09:46:48.959Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29556,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:46:49.012Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29556,"level":50,"msg":"未验证用户登录 { username: 'test021493718403341@tets.com' }","time":"2017-05-02T09:46:49.110Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29556,"level":50,"msg":"被阻止登录 { username: 'test031493718403341@tets.com' }","time":"2017-05-02T09:46:49.184Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30099,"level":50,"msg":"登录密码错误 { username: 'test011493718835648@tets.com' }","time":"2017-05-02T09:54:01.475Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30099,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:54:01.556Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30099,"level":50,"msg":"未验证用户登录 { username: 'test021493718835648@tets.com' }","time":"2017-05-02T09:54:01.624Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30099,"level":50,"msg":"被阻止登录 { username: 'test031493718835648@tets.com' }","time":"2017-05-02T09:54:01.698Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30211,"level":50,"msg":"登录密码错误 { username: 'test011493718900389@tets.com' }","time":"2017-05-02T09:55:06.189Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30211,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:55:06.378Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30211,"level":50,"msg":"未验证用户登录 { username: 'test021493718900390@tets.com' }","time":"2017-05-02T09:55:06.634Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30211,"level":50,"msg":"被阻止登录 { username: 'test031493718900390@tets.com' }","time":"2017-05-02T09:55:06.842Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62467,"level":50,"msg":"登录密码错误 { username: 'test011495354154466@tets.com' }","time":"2017-05-21T08:09:23.413Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62467,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-21T08:09:23.436Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62467,"level":50,"msg":"未验证用户登录 { username: 'test021495354154466@tets.com' }","time":"2017-05-21T08:09:23.494Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62467,"level":50,"msg":"被阻止登录 { username: 'test031495354154466@tets.com' }","time":"2017-05-21T08:09:23.553Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62815,"level":50,"msg":"登录密码错误 { username: 'test011495354357182@tets.com' }","time":"2017-05-21T08:12:50.188Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62815,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-21T08:12:50.214Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62815,"level":50,"msg":"未验证用户登录 { username: 'test021495354357182@tets.com' }","time":"2017-05-21T08:12:50.270Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62815,"level":50,"msg":"被阻止登录 { username: 'test031495354357182@tets.com' }","time":"2017-05-21T08:12:50.332Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62931,"level":50,"msg":"登录密码错误 { username: 'test011495354411139@tets.com' }","time":"2017-05-21T08:13:48.790Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62931,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-21T08:13:48.832Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62931,"level":50,"msg":"未验证用户登录 { username: 'test021495354411139@tets.com' }","time":"2017-05-21T08:13:48.903Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":62931,"level":50,"msg":"被阻止登录 { username: 'test031495354411139@tets.com' }","time":"2017-05-21T08:13:48.983Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":66009,"level":50,"msg":"登录密码错误 { username: 'test011495356424433@tets.com' }","time":"2017-05-21T08:47:15.944Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":66009,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-21T08:47:15.970Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":66009,"level":50,"msg":"未验证用户登录 { username: 'test021495356424433@tets.com' }","time":"2017-05-21T08:47:16.040Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":66009,"level":50,"msg":"被阻止登录 { username: 'test031495356424433@tets.com' }","time":"2017-05-21T08:47:16.098Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67168,"level":50,"msg":"登录密码错误 { username: 'test011495357248958@tets.com' }","time":"2017-05-21T09:00:59.330Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67168,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-21T09:00:59.352Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67168,"level":50,"msg":"未验证用户登录 { username: 'test021495357248958@tets.com' }","time":"2017-05-21T09:00:59.431Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67168,"level":50,"msg":"被阻止登录 { username: 'test031495357248958@tets.com' }","time":"2017-05-21T09:00:59.487Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67417,"level":50,"msg":"登录密码错误 { username: 'test011495357436866@tets.com' }","time":"2017-05-21T09:04:07.099Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67417,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-21T09:04:07.119Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67417,"level":50,"msg":"未验证用户登录 { username: 'test021495357436866@tets.com' }","time":"2017-05-21T09:04:07.166Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":67417,"level":50,"msg":"被阻止登录 { username: 'test031495357436866@tets.com' }","time":"2017-05-21T09:04:07.232Z","v":0} diff --git a/logs/test-error.log.4 b/logs/test-error.log.4 index 45994cc..065f4b4 100644 --- a/logs/test-error.log.4 +++ b/logs/test-error.log.4 @@ -1,8 +1,36 @@ -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19209,"level":50,"msg":"登录密码错误 { username: 'test011488120311653@tets.com' }","time":"2017-02-26T14:45:23.895Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19209,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-02-26T14:45:23.930Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19209,"level":50,"msg":"未验证用户登录 { username: 'test021488120311653@tets.com' }","time":"2017-02-26T14:45:24.003Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19209,"level":50,"msg":"被阻止登录 { username: 'test031488120311653@tets.com' }","time":"2017-02-26T14:45:24.063Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19353,"level":50,"msg":"登录密码错误 { username: 'test011488120456866@tets.com' }","time":"2017-02-26T14:47:47.998Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19353,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-02-26T14:47:48.038Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19353,"level":50,"msg":"未验证用户登录 { username: 'test021488120456866@tets.com' }","time":"2017-02-26T14:47:48.133Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19353,"level":50,"msg":"被阻止登录 { username: 'test031488120456866@tets.com' }","time":"2017-02-26T14:47:48.234Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":27482,"level":50,"msg":"登录密码错误 { username: 'test011493716797472@tets.com' }","time":"2017-05-02T09:20:04.338Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":27482,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:20:04.491Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":27482,"level":50,"msg":"未验证用户登录 { username: 'test021493716797472@tets.com' }","time":"2017-05-02T09:20:04.717Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":27482,"level":50,"msg":"被阻止登录 { username: 'test031493716797472@tets.com' }","time":"2017-05-02T09:20:04.946Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28034,"level":50,"msg":"登录密码错误 { username: 'test011493717239796@tets.com' }","time":"2017-05-02T09:27:25.905Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28034,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:27:25.934Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28034,"level":50,"msg":"未验证用户登录 { username: 'test021493717239796@tets.com' }","time":"2017-05-02T09:27:26.005Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":28034,"level":50,"msg":"被阻止登录 { username: 'test031493717239796@tets.com' }","time":"2017-05-02T09:27:26.063Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29060,"level":50,"msg":"登录密码错误 { username: 'test011493718010690@tets.com' }","time":"2017-05-02T09:40:16.381Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29060,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:40:16.434Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29060,"level":50,"msg":"未验证用户登录 { username: 'test021493718010690@tets.com' }","time":"2017-05-02T09:40:16.514Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29060,"level":50,"msg":"被阻止登录 { username: 'test031493718010690@tets.com' }","time":"2017-05-02T09:40:16.598Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29203,"level":50,"msg":"登录密码错误 { username: 'test011493718135453@tets.com' }","time":"2017-05-02T09:42:21.988Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29203,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:42:22.014Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29203,"level":50,"msg":"未验证用户登录 { username: 'test021493718135453@tets.com' }","time":"2017-05-02T09:42:22.094Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29203,"level":50,"msg":"被阻止登录 { username: 'test031493718135453@tets.com' }","time":"2017-05-02T09:42:22.158Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29374,"level":50,"msg":"登录密码错误 { username: 'test011493718264152@tets.com' }","time":"2017-05-02T09:44:29.614Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29374,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:44:29.666Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29374,"level":50,"msg":"未验证用户登录 { username: 'test021493718264152@tets.com' }","time":"2017-05-02T09:44:29.757Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29374,"level":50,"msg":"被阻止登录 { username: 'test031493718264152@tets.com' }","time":"2017-05-02T09:44:29.838Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29449,"level":50,"msg":"登录密码错误 { username: 'test011493718324275@tets.com' }","time":"2017-05-02T09:45:29.233Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29449,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:45:29.265Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29449,"level":50,"msg":"未验证用户登录 { username: 'test021493718324275@tets.com' }","time":"2017-05-02T09:45:29.338Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29449,"level":50,"msg":"被阻止登录 { username: 'test031493718324275@tets.com' }","time":"2017-05-02T09:45:29.399Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29556,"level":50,"msg":"登录密码错误 { username: 'test011493718403340@tets.com' }","time":"2017-05-02T09:46:48.959Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29556,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:46:49.012Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29556,"level":50,"msg":"未验证用户登录 { username: 'test021493718403341@tets.com' }","time":"2017-05-02T09:46:49.110Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":29556,"level":50,"msg":"被阻止登录 { username: 'test031493718403341@tets.com' }","time":"2017-05-02T09:46:49.184Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30099,"level":50,"msg":"登录密码错误 { username: 'test011493718835648@tets.com' }","time":"2017-05-02T09:54:01.475Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30099,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:54:01.556Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30099,"level":50,"msg":"未验证用户登录 { username: 'test021493718835648@tets.com' }","time":"2017-05-02T09:54:01.624Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30099,"level":50,"msg":"被阻止登录 { username: 'test031493718835648@tets.com' }","time":"2017-05-02T09:54:01.698Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30211,"level":50,"msg":"登录密码错误 { username: 'test011493718900389@tets.com' }","time":"2017-05-02T09:55:06.189Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30211,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-05-02T09:55:06.378Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30211,"level":50,"msg":"未验证用户登录 { username: 'test021493718900390@tets.com' }","time":"2017-05-02T09:55:06.634Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":30211,"level":50,"msg":"被阻止登录 { username: 'test031493718900390@tets.com' }","time":"2017-05-02T09:55:06.842Z","v":0} diff --git a/logs/test-error.log.5 b/logs/test-error.log.5 index ce8adf1..45994cc 100644 --- a/logs/test-error.log.5 +++ b/logs/test-error.log.5 @@ -1,20 +1,8 @@ -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":3480,"level":50,"msg":"登录密码错误 { username: 'test011483256390895@tets.com' }","time":"2017-01-01T07:39:57.532Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":3480,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-01-01T07:39:57.651Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":3480,"level":50,"msg":"未验证用户登录 { username: 'test021483256390896@tets.com' }","time":"2017-01-01T07:39:57.893Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":3480,"level":50,"msg":"被阻止登录 { username: 'test031483256390896@tets.com' }","time":"2017-01-01T07:39:58.107Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":4287,"level":50,"msg":"登录密码错误 { username: 'test011483256816653@tets.com' }","time":"2017-01-01T07:47:02.858Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":4287,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-01-01T07:47:02.991Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":4287,"level":50,"msg":"未验证用户登录 { username: 'test021483256816653@tets.com' }","time":"2017-01-01T07:47:03.215Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":4287,"level":50,"msg":"被阻止登录 { username: 'test031483256816653@tets.com' }","time":"2017-01-01T07:47:03.444Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6180,"level":50,"msg":"登录密码错误 { username: 'test011483258772603@tets.com' }","time":"2017-01-01T08:19:39.025Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6180,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-01-01T08:19:39.143Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6180,"level":50,"msg":"未验证用户登录 { username: 'test021483258772603@tets.com' }","time":"2017-01-01T08:19:39.400Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6180,"level":50,"msg":"被阻止登录 { username: 'test031483258772603@tets.com' }","time":"2017-01-01T08:19:39.667Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6327,"level":50,"msg":"登录密码错误 { username: 'test011483258884201@tets.com' }","time":"2017-01-01T08:21:34.805Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6327,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-01-01T08:21:34.838Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6327,"level":50,"msg":"未验证用户登录 { username: 'test021483258884201@tets.com' }","time":"2017-01-01T08:21:34.914Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6327,"level":50,"msg":"被阻止登录 { username: 'test031483258884201@tets.com' }","time":"2017-01-01T08:21:34.981Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":7049,"level":50,"msg":"登录密码错误 { username: 'test011483259781199@tets.com' }","time":"2017-01-01T08:36:39.591Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":7049,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-01-01T08:36:39.648Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":7049,"level":50,"msg":"未验证用户登录 { username: 'test021483259781199@tets.com' }","time":"2017-01-01T08:36:39.730Z","v":0} -{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":7049,"level":50,"msg":"被阻止登录 { username: 'test031483259781199@tets.com' }","time":"2017-01-01T08:36:39.815Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19209,"level":50,"msg":"登录密码错误 { username: 'test011488120311653@tets.com' }","time":"2017-02-26T14:45:23.895Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19209,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-02-26T14:45:23.930Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19209,"level":50,"msg":"未验证用户登录 { username: 'test021488120311653@tets.com' }","time":"2017-02-26T14:45:24.003Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19209,"level":50,"msg":"被阻止登录 { username: 'test031488120311653@tets.com' }","time":"2017-02-26T14:45:24.063Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19353,"level":50,"msg":"登录密码错误 { username: 'test011488120456866@tets.com' }","time":"2017-02-26T14:47:47.998Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19353,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-02-26T14:47:48.038Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19353,"level":50,"msg":"未验证用户登录 { username: 'test021488120456866@tets.com' }","time":"2017-02-26T14:47:48.133Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":19353,"level":50,"msg":"被阻止登录 { username: 'test031488120456866@tets.com' }","time":"2017-02-26T14:47:48.234Z","v":0} diff --git a/logs/test-error.log.6 b/logs/test-error.log.6 index e69de29..ce8adf1 100644 --- a/logs/test-error.log.6 +++ b/logs/test-error.log.6 @@ -0,0 +1,20 @@ +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":3480,"level":50,"msg":"登录密码错误 { username: 'test011483256390895@tets.com' }","time":"2017-01-01T07:39:57.532Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":3480,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-01-01T07:39:57.651Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":3480,"level":50,"msg":"未验证用户登录 { username: 'test021483256390896@tets.com' }","time":"2017-01-01T07:39:57.893Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":3480,"level":50,"msg":"被阻止登录 { username: 'test031483256390896@tets.com' }","time":"2017-01-01T07:39:58.107Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":4287,"level":50,"msg":"登录密码错误 { username: 'test011483256816653@tets.com' }","time":"2017-01-01T07:47:02.858Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":4287,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-01-01T07:47:02.991Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":4287,"level":50,"msg":"未验证用户登录 { username: 'test021483256816653@tets.com' }","time":"2017-01-01T07:47:03.215Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":4287,"level":50,"msg":"被阻止登录 { username: 'test031483256816653@tets.com' }","time":"2017-01-01T07:47:03.444Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6180,"level":50,"msg":"登录密码错误 { username: 'test011483258772603@tets.com' }","time":"2017-01-01T08:19:39.025Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6180,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-01-01T08:19:39.143Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6180,"level":50,"msg":"未验证用户登录 { username: 'test021483258772603@tets.com' }","time":"2017-01-01T08:19:39.400Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6180,"level":50,"msg":"被阻止登录 { username: 'test031483258772603@tets.com' }","time":"2017-01-01T08:19:39.667Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6327,"level":50,"msg":"登录密码错误 { username: 'test011483258884201@tets.com' }","time":"2017-01-01T08:21:34.805Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6327,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-01-01T08:21:34.838Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6327,"level":50,"msg":"未验证用户登录 { username: 'test021483258884201@tets.com' }","time":"2017-01-01T08:21:34.914Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":6327,"level":50,"msg":"被阻止登录 { username: 'test031483258884201@tets.com' }","time":"2017-01-01T08:21:34.981Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":7049,"level":50,"msg":"登录密码错误 { username: 'test011483259781199@tets.com' }","time":"2017-01-01T08:36:39.591Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":7049,"level":50,"msg":"登录用户名错误 { username: 'ttttt@ttttt.com' }","time":"2017-01-01T08:36:39.648Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":7049,"level":50,"msg":"未验证用户登录 { username: 'test021483259781199@tets.com' }","time":"2017-01-01T08:36:39.730Z","v":0} +{"name":"jackblog","hostname":"hugongzideMacBook-Air.local","pid":7049,"level":50,"msg":"被阻止登录 { username: 'test031483259781199@tets.com' }","time":"2017-01-01T08:36:39.815Z","v":0} diff --git a/package-lock.json b/package-lock.json index e340df9..ce7dbc6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "jackblog-api-koa", - "version": "2.3.2", + "version": "2.3.3", "lockfileVersion": 1, "dependencies": { "@ava/babel-plugin-throws-helper": { diff --git a/package.json b/package.json index 002d757..5e400ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jackblog-api-koa", - "version": "2.3.2", + "version": "2.3.3", "description": "jackblog API koa版", "main": "server/app.js", "scripts": { diff --git a/server/config/env/development.js b/server/config/env/development.js index b0ef21b..d92d366 100644 --- a/server/config/env/development.js +++ b/server/config/env/development.js @@ -5,7 +5,7 @@ module.exports = { //开发环境mongodb配置 mongo: { - uri: `mongodb://${encodeURIComponent(process.env.MONGO_USERNAME || '')}:${encodeURIComponent(process.env.MONGO_PASSWORD || '')}@localhost:27017/jackblog-dev` + uri: `mongodb://localhost/jackblog-dev` }, //开发环境redis配置 redis: { diff --git a/server/config/env/production.js b/server/config/env/production.js index e0eb5c9..d39476c 100644 --- a/server/config/env/production.js +++ b/server/config/env/production.js @@ -8,7 +8,7 @@ module.exports = { port: process.env.PORT || 8800, //生产环境mongodb配置 mongo: { - uri: `mongodb://${encodeURIComponent(process.env.MONGO_USERNAME || '')}:${encodeURIComponent(process.env.MONGO_PASSWORD || '')}@${MONGO_ADDR}/jackblog` + uri: `mongodb://${encodeURIComponent(process.env.MONGO_USERNAME)}:${encodeURIComponent(process.env.MONGO_PASSWORD)}@${MONGO_ADDR}/jackblog` }, //生产环境redis配置 redis: { diff --git a/server/config/env/test.js b/server/config/env/test.js index 182c6e5..d2954e3 100644 --- a/server/config/env/test.js +++ b/server/config/env/test.js @@ -4,7 +4,7 @@ // =========================== module.exports = { mongo: { - uri: `mongodb://${encodeURIComponent(process.env.MONGO_USERNAME || '')}:${encodeURIComponent(process.env.MONGO_PASSWORD || '')}@localhost:27017/jackblog-test` + uri: `mongodb://localhost/jackblog-test` }, redis: { db: 2, diff --git a/server/connect.js b/server/connect.js index a8b2a77..29c508f 100644 --- a/server/connect.js +++ b/server/connect.js @@ -4,7 +4,6 @@ const mongoose = require('mongoose') const config = require('./config/env') // 连接数据库. -console.log(config.mongo.uri) mongoose.connect(config.mongo.uri, config.mongo.options) const modelsPath = path.join(__dirname, 'model') fs.readdirSync(modelsPath).forEach(function (file) {