13
14
-2x
-2x
-2x
+8x
+8x
+8x
-2x
-2x
+8x
+8x
-2x
-2x
-2x
-2x | 'use strict'
+8x
+8x
+8x
+8x | '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 ed2c05a..5cdf8e0 100644
--- a/coverage/server/api/logs/index.html
+++ b/coverage/server/api/logs/index.html
@@ -20,28 +20,28 @@
- 42.11%
+ 100%
Statements
- 8/19
+ 19/19
- 0%
+ 100%
Branches
- 0/8
+ 8/8
- 50%
+ 100%
Functions
- 1/2
+ 2/2
- 42.11%
+ 100%
Lines
- 8/19
+ 19/19
-
+
@@ -72,16 +72,16 @@
- logs.controller.js |
- |
- 21.43% |
- 3/14 |
- 0% |
- 0/8 |
- 50% |
- 1/2 |
- 21.43% |
- 3/14 |
+ logs.controller.js |
+ |
+ 100% |
+ 14/14 |
+ 100% |
+ 8/8 |
+ 100% |
+ 2/2 |
+ 100% |
+ 14/14 |
@@ -90,7 +90,7 @@
diff --git a/coverage/server/api/logs/index.js.html b/coverage/server/api/logs/index.js.html
index e3239dd..1c14f70 100644
--- a/coverage/server/api/logs/index.js.html
+++ b/coverage/server/api/logs/index.js.html
@@ -53,13 +53,13 @@
8
9
-2x
-2x
-2x
+8x
+8x
+8x
-2x
+8x
-2x | 'use strict'
+8x | '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 4e6c3fc..de93384 100644
--- a/coverage/server/api/logs/logs.controller.js.html
+++ b/coverage/server/api/logs/logs.controller.js.html
@@ -20,28 +20,28 @@
- 21.43%
+ 100%
Statements
- 3/14
+ 14/14
- 0%
+ 100%
Branches
- 0/8
+ 8/8
- 50%
+ 100%
Functions
- 1/2
+ 2/2
- 21.43%
+ 100%
Lines
- 3/14
+ 14/14
-
+
1
2
@@ -65,43 +65,43 @@
20
21 |
+8x
+8x
+
+26x
+2x
2x
2x
-6x
-
-
-
-
-
-
-
-
+2x
+2x
+2x
+1x
-
-
-
-
+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 7ace913..d6591b5 100644
--- a/coverage/server/api/mobile/index.html
+++ b/coverage/server/api/mobile/index.html
@@ -20,28 +20,28 @@
- 60%
+ 90%
Statements
- 6/10
+ 9/10
- 0%
+ 50%
Branches
- 0/2
+ 1/2
- 50%
+ 100%
Functions
- 1/2
+ 2/2
- 60%
+ 90%
Lines
- 6/10
+ 9/10
-
+
@@ -72,16 +72,16 @@
- mobile.controller.js |
- |
- 33.33% |
- 2/6 |
- 0% |
- 0/2 |
+ mobile.controller.js |
+ |
+ 83.33% |
+ 5/6 |
50% |
1/2 |
- 33.33% |
- 2/6 |
+ 100% |
+ 2/2 |
+ 83.33% |
+ 5/6 |
@@ -90,7 +90,7 @@
diff --git a/coverage/server/api/mobile/index.js.html b/coverage/server/api/mobile/index.js.html
index fca9ded..cf72b35 100644
--- a/coverage/server/api/mobile/index.js.html
+++ b/coverage/server/api/mobile/index.js.html
@@ -52,12 +52,12 @@
7
8
-2x
-2x
+8x
+8x
-2x
+8x
-2x | 'use strict'
+8x | '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 0874c2a..7d6e6b1 100644
--- a/coverage/server/api/mobile/mobile.controller.js.html
+++ b/coverage/server/api/mobile/mobile.controller.js.html
@@ -20,28 +20,28 @@
- 33.33%
+ 83.33%
Statements
- 2/6
+ 5/6
- 0%
+ 50%
Branches
- 0/2
+ 1/2
- 50%
+ 100%
Functions
- 1/2
+ 2/2
- 33.33%
+ 83.33%
Lines
- 2/6
+ 5/6
-
+
1
2
@@ -57,12 +57,12 @@
12
13 |
-2x
+8x
-6x
-
-
-
+25x
+1x
+1x
+1x
@@ -71,10 +71,10 @@
const config = require('../../config/env')
-exports.getApps = async (ctx)=>{
- if(config.apps){
- ctx.status = 200
- ctx.body = {success:true,data:config.apps}
+exports.getApps = async (ctx)=>{
+ Eif(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 f1bc8ad..f0063e9 100644
--- a/coverage/server/api/tags/index.html
+++ b/coverage/server/api/tags/index.html
@@ -20,28 +20,28 @@
- 24.07%
+ 93.52%
Statements
- 26/108
+ 101/108
- 0%
+ 90%
Branches
- 0/20
+ 18/20
- 50%
+ 100%
Functions
- 9/18
+ 18/18
- 24.07%
+ 93.52%
Lines
- 26/108
+ 101/108
-
+
@@ -72,16 +72,16 @@
- tags.controller.js |
- |
- 13.68% |
- 13/95 |
- 0% |
- 0/20 |
- 50% |
- 9/18 |
- 13.68% |
- 13/95 |
+ tags.controller.js |
+ |
+ 92.63% |
+ 88/95 |
+ 90% |
+ 18/20 |
+ 100% |
+ 18/18 |
+ 92.63% |
+ 88/95 |
@@ -90,7 +90,7 @@
diff --git a/coverage/server/api/tags/index.js.html b/coverage/server/api/tags/index.js.html
index fe95dca..a83e286 100644
--- a/coverage/server/api/tags/index.js.html
+++ b/coverage/server/api/tags/index.js.html
@@ -61,21 +61,21 @@
16
17
-2x
-2x
-2x
+8x
+8x
+8x
-2x
-2x
-2x
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
-2x
-2x | 'use strict'
+8x
+8x | '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 a7d27db..73733eb 100644
--- a/coverage/server/api/tags/tags.controller.js.html
+++ b/coverage/server/api/tags/tags.controller.js.html
@@ -20,28 +20,28 @@
- 13.68%
+ 92.63%
Statements
- 13/95
+ 88/95
- 0%
+ 90%
Branches
- 0/20
+ 18/20
- 50%
+ 100%
Functions
- 9/18
+ 18/18
- 13.68%
+ 92.63%
Lines
- 13/95
+ 88/95
-
+
1
2
@@ -200,119 +200,119 @@
155
156 |
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
-6x
-
-
-
-
+27x
+3x
+3x
+1x
+1x
-
-
-
-
-
+2x
+2x
+2x
+1x
+1x
-
-
-
+1x
+1x
+1x
-6x
-
-
-
-
+25x
+1x
+1x
+1x
+1x
-6x
-
-
-
+25x
+1x
+1x
+1x
-
-
-
-
+1x
+1x
+1x
+1x
-6x
-
-
-
-
-
-
+27x
+3x
+3x
+3x
+2x
+1x
+1x
-
-
-
+1x
+1x
+1x
-
+1x
-6x
-
-
-
-
+26x
+2x
+2x
+2x
+1x
-
-
+2x
+2x
-
-
+2x
+2x
-6x
+28x
-
-
+4x
+4x
-
-
-
-
+4x
+1x
+3x
+1x
-
-
-
+4x
+2x
+2x
-
-
-
-
-
+2x
+2x
+2x
+1x
+1x
-
-
-
+1x
+1x
+1x
@@ -320,36 +320,36 @@
-6x
-
-
-
-
-
+26x
+2x
+2x
+2x
+1x
+1x
-
+1x
-6x
-
-
-
+25x
+1x
+1x
+1x
-
-
-
-
+1x
+1x
+1x
+1x
-6x
-
-
-
-
+25x
+1x
+1x
+1x
+1x
@@ -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
- if(ctx.request.body._id){
- delete ctx.request.body._id
+exports.updateTagCat = async (ctx, next)=>{
+ const id = ctx.params.id
+ Eif(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
- if(ctx.request.body._id){
- delete ctx.request.body._id
+exports.updateTag = async (ctx, next)=>{
+ const id = ctx.params.id
+ Eif(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 545d22d..7c4c7b0 100644
--- a/coverage/server/api/users/index.html
+++ b/coverage/server/api/users/index.html
@@ -20,28 +20,28 @@
- 19.71%
+ 92.7%
Statements
- 27/137
+ 127/137
- 0%
+ 89.04%
Branches
- 0/73
+ 65/73
- 50%
+ 94.44%
Functions
- 9/18
+ 17/18
- 19.71%
+ 92.7%
Lines
- 27/137
+ 127/137
-
+
@@ -72,16 +72,16 @@
- user.controller.js |
- |
- 11.29% |
- 14/124 |
- 0% |
- 0/73 |
- 50% |
- 9/18 |
- 11.29% |
- 14/124 |
+ user.controller.js |
+ |
+ 91.94% |
+ 114/124 |
+ 89.04% |
+ 65/73 |
+ 94.44% |
+ 17/18 |
+ 91.94% |
+ 114/124 |
@@ -90,7 +90,7 @@
diff --git a/coverage/server/api/users/index.js.html b/coverage/server/api/users/index.js.html
index 7a92dde..af5506f 100644
--- a/coverage/server/api/users/index.js.html
+++ b/coverage/server/api/users/index.js.html
@@ -62,21 +62,21 @@
17
18
-2x
-2x
-2x
+8x
+8x
+8x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
-2x
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
+8x
| '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 6b57f80..9884b0e 100644
--- a/coverage/server/api/users/user.controller.js.html
+++ b/coverage/server/api/users/user.controller.js.html
@@ -20,28 +20,28 @@
- 11.29%
+ 91.94%
Statements
- 14/124
+ 114/124
- 0%
+ 89.04%
Branches
- 0/73
+ 65/73
- 50%
+ 94.44%
Functions
- 9/18
+ 17/18
- 11.29%
+ 91.94%
Lines
- 14/124
+ 114/124
-
+
1
2
@@ -244,200 +244,200 @@
199
200 |
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
-6x
+24x
-6x
-
-
-
-
-
+25x
+1x
+1x
+1x
+1x
+1x
-6x
-
-
-
+26x
+2x
+2x
+2x
-
-
-
-
+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
-6x
-
+27x
+3x
-
-
-
+3x
+1x
+1x
-
-
-
+2x
+2x
+1x
-
-
+1x
+1x
-
+1x
-6x
+31x
-
-
-
-
-
+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
-6x
-
-
+28x
+4x
+4x
-
-
-
+4x
+1x
+3x
-
+1x
-
-
-
+4x
+2x
+2x
-
-
-
-
-
-
+2x
+2x
+2x
+2x
+1x
+1x
-
+1x
-6x
-
-
-
-
+25x
+1x
+1x
+1x
+1x
-6x
-
-
-
+25x
+1x
+1x
+1x
@@ -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 if(nickname.length <= 2 || nickname.length >15 || !NICKNAME_REGEXP.test(nickname)){
+ if(nickname === ''){
+ error_msg = '呢称不能为空'
+ }else if(email === ''){
+ error_msg = '邮箱地址不能为空'
+ }else Iif(nickname.length <= 2 || nickname.length >15 || !NICKNAME_REGEXP.test(nickname)){
//不符合呢称规定.
error_msg = '呢称不合法'
- }else if(email.length <=4 || email.length > 30 || !EMAIL_REGEXP.test(email)){
+ }else Iif(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()
- if(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()
+ Eif(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)=>{
- if(config.snsLogins){
- ctx.status = 200
- ctx.body = {success:true,data:config.snsLogins}
+exports.getSnsLogins = async (ctx,next)=>{
+ Eif(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 7c31b36..1cdfec6 100644
--- a/coverage/server/app.js.html
+++ b/coverage/server/app.js.html
@@ -20,28 +20,28 @@
- 70%
+ 85%
Statements
- 14/20
+ 17/20
- 33.33%
+ 50%
Branches
- 2/6
+ 3/6
- 33.33%
+ 100%
Functions
- 1/3
+ 3/3
- 70%
+ 85%
Lines
- 14/20
+ 17/20
-
+
1
2
@@ -80,38 +80,38 @@
35 |
-2x
-2x
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
-2x
+8x
-6x
-
-
+117x
+93x
+93x
-2x
-2x
-2x
+8x
+8x
+8x
-2x
-
+8x
+10x
-2x | 'use strict'
+8x | '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)=>{
- if (process.env.NODE_ENV != 'test') {
+app.on('error',(err,ctx)=>{
+ Iif (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 9a0842f..0a71093 100644
--- a/coverage/server/auth/auth.service.js.html
+++ b/coverage/server/auth/auth.service.js.html
@@ -20,24 +20,24 @@
- 50%
+ 77.5%
Statements
- 20/40
+ 31/40
- 6.25%
+ 43.75%
Branches
- 1/16
+ 7/16
- 57.14%
+ 92.86%
Functions
- 8/14
+ 13/14
- 48.48%
+ 81.82%
Lines
- 16/33
+ 27/33
@@ -134,24 +134,24 @@
89
90 |
-2x
-2x
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
-124x
+567x
-
+71x
-
+71x
@@ -160,17 +160,17 @@
-224x
+1038x
-
-
+71x
+71x
-
-
-
-
+71x
+71x
+71x
+71x
@@ -179,12 +179,12 @@
-44x
-88x
+176x
+410x
-
-
+58x
+58x
@@ -196,14 +196,14 @@
-
+6x
-12x
+48x
@@ -217,10 +217,10 @@
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
| 'use strict'
const mongoose = require('mongoose')
@@ -236,11 +236,11 @@
*/
function authToken() {
return compose([
- async (ctx,next)=> {
- if(ctx.query && ctx.query.access_token){
+ async (ctx,next)=> {
+ Iif(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) =>{
- if(!ctx.state.user) ctx.throw('UnauthorizedError',401)
- await next()
+ async (ctx,next) =>{
+ Iif(!ctx.state.user) ctx.throw('UnauthorizedError',401)
+ 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()
+ async (ctx,next) =>{
+ var user = await User.findById(ctx.state.user._id)
+ Iif (!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) =>{
- if (config.userRoles.indexOf(ctx.req.user.role) >= config.userRoles.indexOf(roleRequired)) {
- await next()
+ async (ctx,next) =>{
+ Eif (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 83945aa..bf52cca 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 1ea3b1b..5dbe70a 100644
--- a/coverage/server/auth/github/index.js.html
+++ b/coverage/server/auth/github/index.js.html
@@ -81,15 +81,15 @@
36
37 |
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
-6x
+24x
@@ -114,7 +114,7 @@
-2x
+8x
| '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 3ccd37e..f848b26 100644
--- a/coverage/server/auth/github/passport.js.html
+++ b/coverage/server/auth/github/passport.js.html
@@ -87,13 +87,13 @@
42
43 |
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
-2x
-4x
+8x
+16x
@@ -175,7 +175,7 @@
diff --git a/coverage/server/auth/index.html b/coverage/server/auth/index.html
index 65185b5..64a7e64 100644
--- a/coverage/server/auth/index.html
+++ b/coverage/server/auth/index.html
@@ -20,28 +20,28 @@
- 63.64%
+ 83.64%
Statements
- 35/55
+ 46/55
- 6.25%
+ 43.75%
Branches
- 1/16
+ 7/16
- 57.14%
+ 92.86%
Functions
- 8/14
+ 13/14
- 64.58%
+ 87.5%
Lines
- 31/48
+ 42/48
-
+
@@ -60,15 +60,15 @@
auth.service.js |
- |
- 50% |
- 20/40 |
- 6.25% |
- 1/16 |
- 57.14% |
- 8/14 |
- 48.48% |
- 16/33 |
+ |
+ 77.5% |
+ 31/40 |
+ 43.75% |
+ 7/16 |
+ 92.86% |
+ 13/14 |
+ 81.82% |
+ 27/33 |
@@ -90,7 +90,7 @@
diff --git a/coverage/server/auth/index.js.html b/coverage/server/auth/index.js.html
index e212338..53f2db4 100644
--- a/coverage/server/auth/index.js.html
+++ b/coverage/server/auth/index.js.html
@@ -65,25 +65,25 @@
20
21
-2x
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
+8x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
-2x | 'use strict'
+8x | '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 a597a04..7e72c1b 100644
--- a/coverage/server/auth/local/index.html
+++ b/coverage/server/auth/local/index.html
@@ -20,28 +20,28 @@
- 27.45%
+ 78.43%
Statements
- 14/51
+ 40/51
- 0%
+ 53.85%
Branches
- 0/26
+ 14/26
- 50%
+ 100%
Functions
- 5/10
+ 10/10
- 27.08%
+ 79.17%
Lines
- 13/48
+ 38/48
-
+
@@ -59,29 +59,29 @@
- index.js |
- |
- 28.57% |
- 8/28 |
- 0% |
- 0/18 |
- 42.86% |
- 3/7 |
- 30.77% |
- 8/26 |
+ index.js |
+ |
+ 67.86% |
+ 19/28 |
+ 33.33% |
+ 6/18 |
+ 100% |
+ 7/7 |
+ 69.23% |
+ 18/26 |
- passport.js |
- |
- 26.09% |
- 6/23 |
- 0% |
- 0/8 |
- 66.67% |
- 2/3 |
- 22.73% |
- 5/22 |
+ passport.js |
+ |
+ 91.3% |
+ 21/23 |
+ 100% |
+ 8/8 |
+ 100% |
+ 3/3 |
+ 90.91% |
+ 20/22 |
@@ -90,7 +90,7 @@
diff --git a/coverage/server/auth/local/index.js.html b/coverage/server/auth/local/index.js.html
index c149ef0..aeb373e 100644
--- a/coverage/server/auth/local/index.js.html
+++ b/coverage/server/auth/local/index.js.html
@@ -20,28 +20,28 @@
- 28.57%
+ 67.86%
Statements
- 8/28
+ 19/28
- 0%
+ 33.33%
Branches
- 0/18
+ 6/18
- 42.86%
+ 100%
Functions
- 3/7
+ 7/7
- 30.77%
+ 69.23%
Lines
- 8/26
+ 18/26
-
+
1
2
@@ -87,17 +87,17 @@
42
43 |
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
-6x
+34x
-
+10x
@@ -106,27 +106,27 @@
-
+10x
-
+10x
-6x
-
-
-
-
-
+34x
+30x
+10x
+10x
+4x
+4x
-
-
+6x
+6x
-2x
+8x
| '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
- if(process.env.NODE_ENV !== 'test' && !ctx.req.headers.jackblog){
+ Iif(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 = '用户名和密码不能为空.'
}
}
- if(error_msg){
+ Iif(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)=> {
- if (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)=> {
+ Iif (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 4894c45..02855c6 100644
--- a/coverage/server/auth/local/passport.js.html
+++ b/coverage/server/auth/local/passport.js.html
@@ -20,28 +20,28 @@
- 26.09%
+ 91.3%
Statements
- 6/23
+ 21/23
- 0%
+ 100%
Branches
- 0/8
+ 8/8
- 66.67%
+ 100%
Functions
- 2/3
+ 3/3
- 22.73%
+ 90.91%
Lines
- 5/22
+ 20/22
-
+
1
2
@@ -82,35 +82,35 @@
37
38 |
-2x
-2x
-2x
+8x
+8x
+8x
-2x
-4x
+8x
+26x
-
-
-
-
-
+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 d39e3d8..1b91bcd 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 528da97..1de495b 100644
--- a/coverage/server/auth/qq/index.js.html
+++ b/coverage/server/auth/qq/index.js.html
@@ -82,15 +82,15 @@
37
38 |
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
-6x
+24x
@@ -116,7 +116,7 @@
-2x
+8x
| '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 62caed1..78806a6 100644
--- a/coverage/server/auth/qq/passport.js.html
+++ b/coverage/server/auth/qq/passport.js.html
@@ -91,13 +91,13 @@
46
47 |
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
-2x
-4x
+8x
+16x
@@ -187,7 +187,7 @@
diff --git a/coverage/server/auth/weibo/index.html b/coverage/server/auth/weibo/index.html
index 0b466cf..8c98c07 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 4f25b7d..3289b08 100644
--- a/coverage/server/auth/weibo/index.js.html
+++ b/coverage/server/auth/weibo/index.js.html
@@ -82,15 +82,15 @@
37
38 |
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
-6x
+24x
@@ -116,7 +116,7 @@
-2x
+8x
| '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 e1a61d4..79aa149 100644
--- a/coverage/server/auth/weibo/passport.js.html
+++ b/coverage/server/auth/weibo/passport.js.html
@@ -86,13 +86,13 @@
41
42 |
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
-2x
-4x
+8x
+16x
@@ -172,7 +172,7 @@
diff --git a/coverage/server/config/env/index.html b/coverage/server/config/env/index.html
index 41316e6..ab4eac5 100644
--- a/coverage/server/config/env/index.html
+++ b/coverage/server/config/env/index.html
@@ -90,7 +90,7 @@
diff --git a/coverage/server/config/env/index.js.html b/coverage/server/config/env/index.js.html
index 4f3fa67..cfd557a 100644
--- a/coverage/server/config/env/index.js.html
+++ b/coverage/server/config/env/index.js.html
@@ -132,11 +132,11 @@
87
88 |
-2x
-2x
-2x
+8x
+8x
+8x
-2x
+8x
@@ -211,12 +211,12 @@
-2x
+8x
-2x
-2x
+8x
+8x
-2x
+8x
| 'use strict'
var path = require('path')
@@ -310,7 +310,7 @@
diff --git a/coverage/server/config/env/test.js.html b/coverage/server/config/env/test.js.html
index 4939e1e..32bc4d3 100644
--- a/coverage/server/config/env/test.js.html
+++ b/coverage/server/config/env/test.js.html
@@ -64,7 +64,7 @@
-2x
+8x
@@ -83,7 +83,7 @@
// ===========================
module.exports = {
mongo: {
- uri: `mongodb://${null}:${null}@localhost:27017/jackblog-test`
+ uri: `mongodb://localhost/jackblog-test`
},
redis: {
db: 2,
@@ -100,7 +100,7 @@
diff --git a/coverage/server/config/index.html b/coverage/server/config/index.html
index 2bcbfed..12bb9f3 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 228906f..412ed95 100644
--- a/coverage/server/config/koa.js.html
+++ b/coverage/server/config/koa.js.html
@@ -82,30 +82,30 @@
37
38 |
-2x
-2x
-2x
-2x
-2x
-2x
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
-2x
-2x
+8x
+8x
-2x
+8x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
@@ -114,8 +114,8 @@
-2x
-2x
+8x
+8x
| 'use strict'
@@ -160,7 +160,7 @@
diff --git a/coverage/server/connect.js.html b/coverage/server/connect.js.html
index 06b96c4..2fb0413 100644
--- a/coverage/server/connect.js.html
+++ b/coverage/server/connect.js.html
@@ -59,23 +59,23 @@
14
15
16
-17 | 2x
-2x
-2x
-2x
+17 | 8x
+8x
+8x
+8x
-2x
-2x
-2x
-12x
-12x
+8x
+8x
+8x
+48x
+48x
-2x
+8x
-2x | const path = require('path')
+8x | 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 d371a6d..f0670e8 100644
--- a/coverage/server/index.html
+++ b/coverage/server/index.html
@@ -20,24 +20,24 @@
- 86%
+ 92%
Statements
- 43/50
+ 46/50
- 37.5%
+ 50%
Branches
- 3/8
+ 4/8
- 50%
+ 83.33%
Functions
- 3/6
+ 5/6
- 86%
+ 92%
Lines
- 43/50
+ 46/50
@@ -59,16 +59,16 @@
|
- app.js |
- |
- 70% |
- 14/20 |
- 33.33% |
- 2/6 |
- 33.33% |
- 1/3 |
- 70% |
- 14/20 |
+ app.js |
+ |
+ 85% |
+ 17/20 |
+ 50% |
+ 3/6 |
+ 100% |
+ 3/3 |
+ 85% |
+ 17/20 |
@@ -103,7 +103,7 @@
diff --git a/coverage/server/model/article.model.js.html b/coverage/server/model/article.model.js.html
index 6501936..8a330aa 100644
--- a/coverage/server/model/article.model.js.html
+++ b/coverage/server/model/article.model.js.html
@@ -20,9 +20,9 @@
- 85.71%
+ 100%
Statements
- 6/7
+ 7/7
100%
@@ -30,14 +30,14 @@
0/0
- 0%
+ 100%
Functions
- 0/1
+ 1/1
- 85.71%
+ 100%
Lines
- 6/7
+ 7/7
@@ -125,10 +125,10 @@
-2x
-2x
+8x
+8x
-2x
+8x
@@ -181,10 +181,10 @@
-2x
+8x
-
+1x
@@ -196,8 +196,8 @@
-2x
-2x/**
+8x
+8x | /**
* 文章表
*/
'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 045bd43..4916c26 100644
--- a/coverage/server/model/comment.model.js.html
+++ b/coverage/server/model/comment.model.js.html
@@ -87,10 +87,10 @@
-2x
-2x
+8x
+8x
-2x
+8x
@@ -120,8 +120,8 @@
-2x
-2x | /**
+8x
+8x | /**
* 评论表
*/
'use strict'
@@ -166,7 +166,7 @@
diff --git a/coverage/server/model/index.html b/coverage/server/model/index.html
index 25a4358..2b4fe30 100644
--- a/coverage/server/model/index.html
+++ b/coverage/server/model/index.html
@@ -20,28 +20,28 @@
- 60.94%
+ 90.63%
Statements
- 39/64
+ 58/64
- 0%
+ 66.67%
Branches
- 0/12
+ 8/12
- 0%
+ 75%
Functions
- 0/12
+ 9/12
- 63.93%
+ 93.44%
Lines
- 39/61
+ 57/61
-
+
@@ -60,15 +60,15 @@
article.model.js |
- |
- 85.71% |
- 6/7 |
+ |
+ 100% |
+ 7/7 |
100% |
0/0 |
- 0% |
- 0/1 |
- 85.71% |
- 6/7 |
+ 100% |
+ 1/1 |
+ 100% |
+ 7/7 |
@@ -124,16 +124,16 @@
- user.model.js |
- |
- 35.14% |
- 13/37 |
- 0% |
- 0/12 |
- 0% |
- 0/11 |
- 38.24% |
- 13/34 |
+ user.model.js |
+ |
+ 83.78% |
+ 31/37 |
+ 66.67% |
+ 8/12 |
+ 72.73% |
+ 8/11 |
+ 88.24% |
+ 30/34 |
@@ -142,7 +142,7 @@
diff --git a/coverage/server/model/logs.model.js.html b/coverage/server/model/logs.model.js.html
index d1a6674..86857aa 100644
--- a/coverage/server/model/logs.model.js.html
+++ b/coverage/server/model/logs.model.js.html
@@ -67,10 +67,10 @@
22
23
-2x
-2x
+8x
+8x
-2x
+8x
@@ -86,8 +86,8 @@
-2x
-2x | 'use strict'
+8x
+8x | '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 99ff788..75fd6d9 100644
--- a/coverage/server/model/tag.category.model.js.html
+++ b/coverage/server/model/tag.category.model.js.html
@@ -65,10 +65,10 @@
-2x
-2x
+8x
+8x
-2x
+8x
@@ -76,8 +76,8 @@
-2x
-2x | /**
+8x
+8x | /**
* 标签分类表,管理标签
*/
'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 139a554..18ef324 100644
--- a/coverage/server/model/tag.model.js.html
+++ b/coverage/server/model/tag.model.js.html
@@ -82,10 +82,10 @@
-2x
-2x
+8x
+8x
-2x
+8x
@@ -108,8 +108,8 @@
-2x
-2x | /**
+8x
+8x | /**
* 标签表
*/
@@ -148,7 +148,7 @@
diff --git a/coverage/server/model/user.model.js.html b/coverage/server/model/user.model.js.html
index 9664f18..dfe1936 100644
--- a/coverage/server/model/user.model.js.html
+++ b/coverage/server/model/user.model.js.html
@@ -20,28 +20,28 @@
- 35.14%
+ 83.78%
Statements
- 13/37
+ 31/37
- 0%
+ 66.67%
Branches
- 0/12
+ 8/12
- 0%
+ 72.73%
Functions
- 0/11
+ 8/11
- 38.24%
+ 88.24%
Lines
- 13/34
+ 30/34
-
+
1
2
@@ -224,11 +224,11 @@
-2x
-2x
-2x
+8x
+8x
+8x
-2x
+8x
@@ -305,22 +305,22 @@
-2x
+8x
-
-
-
+11x
+11x
+11x
-2x
+8x
-
+2x
@@ -330,10 +330,10 @@
-2x
+8x
-
+1x
@@ -344,7 +344,7 @@
-2x
+8x
@@ -353,23 +353,23 @@
-2x
+8x
-
-
-
-
-
-
+15x
+15x
+15x
+15x
+4x
+3x
-
+11x
-2x
+8x
@@ -377,24 +377,24 @@
-
+9x
-
+11x
-
-
-
+20x
+20x
+20x
-2x
+8x
-2x
-2x
+8x
+8x
| /**
* 用户表
*/
@@ -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) {
- if(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) {
+ Iif(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) {
- if (!password || !this.salt) return ''
- var salt = new Buffer(this.salt, 'base64')
- return crypto.pbkdf2Sync(password, salt, 10000, 64, 'sha1').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')
}
}
@@ -577,7 +577,7 @@
diff --git a/coverage/server/routes.js.html b/coverage/server/routes.js.html
index 8ebb5d4..3104ff5 100644
--- a/coverage/server/routes.js.html
+++ b/coverage/server/routes.js.html
@@ -65,27 +65,27 @@
20
21
22
-23 | 2x
-2x
-2x
-2x
-2x
-2x
-2x
-2x
+23 | 8x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
-2x
-2x
-2x
-2x
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
-2x
+8x
| 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 68402bb..8f49e10 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 1e402e4..9d3a123 100644
--- a/coverage/server/util/debug/index.js.html
+++ b/coverage/server/util/debug/index.js.html
@@ -51,10 +51,10 @@
6
7 |
-2x
+8x
-2x
-12x
+8x
+48x
| '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 8338860..26b82fa 100644
--- a/coverage/server/util/error/index.html
+++ b/coverage/server/util/error/index.html
@@ -20,28 +20,28 @@
- 28.57%
+ 100%
Statements
- 4/14
+ 14/14
- 0%
+ 75%
Branches
- 0/8
+ 6/8
- 50%
+ 100%
Functions
- 2/4
+ 4/4
- 28.57%
+ 100%
Lines
- 4/14
+ 14/14
-
+
@@ -59,16 +59,16 @@
- index.js |
- |
- 28.57% |
- 4/14 |
- 0% |
- 0/8 |
- 50% |
- 2/4 |
- 28.57% |
- 4/14 |
+ index.js |
+ |
+ 100% |
+ 14/14 |
+ 75% |
+ 6/8 |
+ 100% |
+ 4/4 |
+ 100% |
+ 14/14 |
@@ -77,7 +77,7 @@
diff --git a/coverage/server/util/error/index.js.html b/coverage/server/util/error/index.js.html
index a9122ed..0897319 100644
--- a/coverage/server/util/error/index.js.html
+++ b/coverage/server/util/error/index.js.html
@@ -20,28 +20,28 @@
- 28.57%
+ 100%
Statements
- 4/14
+ 14/14
- 0%
+ 75%
Branches
- 0/8
+ 6/8
- 50%
+ 100%
Functions
- 2/4
+ 4/4
- 28.57%
+ 100%
Lines
- 4/14
+ 14/14
-
+
1
2
@@ -65,46 +65,46 @@
20
21
22
-23 | 2x
+23 | 8x
-2x
-6x
-
-
+8x
+117x
+93x
+93x
-
-
-
-
-
-
+10x
+10x
+10x
+3x
+3x
+3x
-
-
+10x
+10x
-2x | const _ = require('lodash')
+8x | 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)=>{
- if(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)=>{
+ Eif(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 7a660f9..d1fa1b2 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 0967037..3e761f3 100644
--- a/coverage/server/util/logs/index.js.html
+++ b/coverage/server/util/logs/index.js.html
@@ -81,11 +81,11 @@
36
37 |
-2x
-2x
-2x
+8x
+8x
+8x
-2x
+8x
@@ -114,7 +114,7 @@
-2x
+8x
| '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 544a02c..1e25eca 100644
--- a/coverage/server/util/qiniu/index.html
+++ b/coverage/server/util/qiniu/index.html
@@ -20,28 +20,28 @@
- 58.82%
+ 100%
Statements
- 30/51
+ 51/51
- 0%
+ 100%
Branches
- 0/2
+ 2/2
- 0%
+ 100%
Functions
- 0/13
+ 13/13
- 58.82%
+ 100%
Lines
- 30/51
+ 51/51
-
+
@@ -59,16 +59,16 @@
- index.js |
- |
- 58.82% |
- 30/51 |
- 0% |
- 0/2 |
- 0% |
- 0/13 |
- 58.82% |
- 30/51 |
+ index.js |
+ |
+ 100% |
+ 51/51 |
+ 100% |
+ 2/2 |
+ 100% |
+ 13/13 |
+ 100% |
+ 51/51 |
@@ -77,7 +77,7 @@
diff --git a/coverage/server/util/qiniu/index.js.html b/coverage/server/util/qiniu/index.js.html
index e1c8096..e8f1159 100644
--- a/coverage/server/util/qiniu/index.js.html
+++ b/coverage/server/util/qiniu/index.js.html
@@ -20,28 +20,28 @@
- 58.82%
+ 100%
Statements
- 30/51
+ 51/51
- 0%
+ 100%
Branches
- 0/2
+ 2/2
- 0%
+ 100%
Functions
- 0/13
+ 13/13
- 58.82%
+ 100%
Lines
- 30/51
+ 51/51
-
+
1
2
@@ -133,79 +133,79 @@
88
89 |
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
-2x
-2x
-2x
+8x
+8x
+8x
-2x
-2x
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
-2x
-2x
-2x
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
+8x
+8x
+8x
-
-
+1x
+1x
-2x
-2x
+8x
+8x
-2x
-
-
-
+8x
+1x
+1x
+1x
-2x
-
-
-
-
-
+8x
+1x
+1x
+1x
+1x
+1x
-2x
+8x
-
-
-
+1x
+1x
+1x
-2x
+8x
-
-
-
+1x
+1x
+1x
-2x
-
-
+8x
+1x
+1x
@@ -214,10 +214,10 @@
-2x
-
-
-
+8x
+1x
+1x
+1x
| '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 f31bd9c..5f13b2c 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 b696ac0..a17ce96 100644
--- a/coverage/server/util/redis/index.js.html
+++ b/coverage/server/util/redis/index.js.html
@@ -58,18 +58,18 @@
13
14
-2x
-2x
-2x
-2x
+8x
+8x
+8x
+8x
-2x
+8x
-2x
+8x
-2x | 'use strict'
+8x | '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 2ec361f..63555d5 100644
--- a/coverage/server/util/tools/index.html
+++ b/coverage/server/util/tools/index.html
@@ -20,28 +20,28 @@
- 15.79%
+ 100%
Statements
- 3/19
+ 19/19
- 0%
+ 80%
Branches
- 0/10
+ 8/10
- 0%
+ 100%
Functions
- 0/3
+ 3/3
- 15.79%
+ 100%
Lines
- 3/19
+ 19/19
-
+
@@ -59,16 +59,16 @@
- index.js |
- |
- 15.79% |
- 3/19 |
- 0% |
- 0/10 |
- 0% |
- 0/3 |
- 15.79% |
- 3/19 |
+ index.js |
+ |
+ 100% |
+ 19/19 |
+ 80% |
+ 8/10 |
+ 100% |
+ 3/3 |
+ 100% |
+ 19/19 |
@@ -77,7 +77,7 @@
diff --git a/coverage/server/util/tools/index.js.html b/coverage/server/util/tools/index.js.html
index 7e92cfe..21b962f 100644
--- a/coverage/server/util/tools/index.js.html
+++ b/coverage/server/util/tools/index.js.html
@@ -20,28 +20,28 @@
- 15.79%
+ 100%
Statements
- 3/19
+ 19/19
- 0%
+ 80%
Branches
- 0/10
+ 8/10
- 0%
+ 100%
Functions
- 0/3
+ 3/3
- 15.79%
+ 100%
Lines
- 3/19
+ 19/19
-
+
1
2
@@ -75,63 +75,63 @@
30
31 |
-3x
+9x
-3x
-
-
-
-
-
-
+9x
+2x
+2x
+2x
+2x
+2x
+18x
-
+2x
-3x
-
-
-
-
-
-
+9x
+5x
+5x
+5x
+4x
+4x
+4x
-
-
+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 || ''
})
- if(url !== ''){
- results.push({url:url})
+ Eif(url !== ''){
+ results.push({url:url})
}
}
}
- return results
+ return results
}
|
@@ -139,7 +139,7 @@
| | | | | | | | | | | | | | | |