- 浏览: 2542697 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Blog Project(2)Express Backend API - istanbul - mocha - bunyan
There 2 Mongo UI Tools: mongohub and rebomongo
Set Up Project Basic
gulp
istanbul
http://gotwarlost.github.io/istanbul/
http://www.ruanyifeng.com/blog/2015/06/istanbul.html
http://www.jianshu.com/p/e297d2eceb05
http://blog.csdn.net/csr0312/article/details/47044259
Install istanbul on my local
>sudo npm install -g istanbul
>cat simple.js
var a = 1;
var b = 1;
if ((a + b) > 2) {
console.log('more than two');
}
>istanbul cover simple.js
=============================================================================
Writing coverage object [/Users/carl/work/nodejs/nodejstest/coverage/coverage.json]
Writing coverage reports at [/Users/carl/work/nodejs/nodejstest/coverage]
=============================================================================
=============================== Coverage summary ===============================
Statements : 75% ( 3/4 )
Branches : 50% ( 1/2 )
Functions : 100% ( 0/0 )
Lines : 75% ( 3/4 )
================================================================================
line coverage - if every line is executed
function coverage - if all functions are called
branch coverage - if all ‘if’ statements get executed
statement coverage - if all statements get executed
There is a html report as well
>open coverage/lcov-report/index.html
Set standard to be 90%
>istanbul check-coverage --statement 90
ERROR: Coverage for statements (75%) does not meet global threshold (90%)
Mocha
We usually use istanbul with mocha
Install mocha in global
>sudo npm install -g mocha
install chai on local
>npm install chai
Simple sqrt.js
> cat sqrt.js
var My = {
sqrt: function(x) {
if (x < 0){
throw new Error("can not be negative");
}
return Math.exp(Math.log(x)/2);
}
};
module.exports = My;
Simple tests codes
>cat test/test.sqrt.js
var chai = require('chai');
var expect = chai.expect;
var My = require('../sqrt.js');
describe("sqrt", function() {
it("4 sqrt should be 2", function() {
expect(My.sqrt(4)).to.equal(2);
});
it("throw exception if x is negative", function() {
expect(function(){ My.sqrt(-1); }).to.throw("can not be negative");
});
});
Work together
>istanbul cover _mocha
sqrt
✓ 4 sqrt should be 2
✓ throw exception if x is negative
2 passing (8ms)
=============================================================================
Writing coverage object [/Users/carl/work/nodejs/nodejstest2/coverage/coverage.json]
Writing coverage reports at [/Users/carl/work/nodejs/nodejstest2/coverage]
=============================================================================
=============================== Coverage summary ===============================
Statements : 100% ( 5/5 )
Branches : 100% ( 2/2 )
Functions : 100% ( 1/1 )
Lines : 100% ( 5/5 )
================================================================================
Logging System - bunyan
https://github.com/trentm/node-bunyan
http://www.ctolib.com/node-bunyan.html#installation
Installation
>npm install bunyan --save
>sudo npm install -g bunyan
Simple usage of the Logger
>cat hi.js
var bunyan = require('bunyan');
var log = bunyan.createLogger({name: 'myapp'});
log.info("hi");
log.warn({lang:'fr'}, 'hello');
Show the logging
>node hi.js
{"name":"myapp","hostname":"ip-10-10-21-215.ec2.internal","pid":28178,"level":30,"msg":"hi","time":"2017-06-08T15:20:22.400Z","v":0}
{"name":"myapp","hostname":"ip-10-10-21-215.ec2.internal","pid":28178,"level":40,"lang":"fr","msg":"hello","time":"2017-06-08T15:20:22.402Z","v":0}
Logging in nice format
>node hi.js | bunyan
[2017-06-08T15:22:22.449Z] INFO: myapp/28340 on ip-10-10-21-215.ec2.internal: hi
[2017-06-08T15:22:22.451Z] WARN: myapp/28340 on ip-10-10-21-215.ec2.internal: hello (lang=fr)
>node hi.js | bunyan -l warn
[2017-06-08T15:22:43.041Z] WARN: myapp/28359 on ip-10-10-21-215.ec2.internal: hello (lang=fr)
>node hi.js | bunyan -c 'this.lang == "fr"'
[2017-06-08T15:23:24.429Z] WARN: myapp/28468 on ip-10-10-21-215.ec2.internal: hello (lang=fr)
Commons Tool
https://lodash.com/
https://lodash.com/docs/4.17.4
http://wwsun.github.io/posts/lodash-top-10-functions.html
Markdown-it
https://github.com/markdown-it/markdown-it
https://markdown-it.github.io/
Passport
http://blog.fens.me/nodejs-express-passport/
Here is the version of empty projects
https://github.com/luohuazju/sillycat-blog-backend-express/tree/version-1
References:
http://sillycat.iteye.com/blog/2378442
https://github.com/jackhutu/jackblog-api-express
There 2 Mongo UI Tools: mongohub and rebomongo
Set Up Project Basic
gulp
istanbul
http://gotwarlost.github.io/istanbul/
http://www.ruanyifeng.com/blog/2015/06/istanbul.html
http://www.jianshu.com/p/e297d2eceb05
http://blog.csdn.net/csr0312/article/details/47044259
Install istanbul on my local
>sudo npm install -g istanbul
>cat simple.js
var a = 1;
var b = 1;
if ((a + b) > 2) {
console.log('more than two');
}
>istanbul cover simple.js
=============================================================================
Writing coverage object [/Users/carl/work/nodejs/nodejstest/coverage/coverage.json]
Writing coverage reports at [/Users/carl/work/nodejs/nodejstest/coverage]
=============================================================================
=============================== Coverage summary ===============================
Statements : 75% ( 3/4 )
Branches : 50% ( 1/2 )
Functions : 100% ( 0/0 )
Lines : 75% ( 3/4 )
================================================================================
line coverage - if every line is executed
function coverage - if all functions are called
branch coverage - if all ‘if’ statements get executed
statement coverage - if all statements get executed
There is a html report as well
>open coverage/lcov-report/index.html
Set standard to be 90%
>istanbul check-coverage --statement 90
ERROR: Coverage for statements (75%) does not meet global threshold (90%)
Mocha
We usually use istanbul with mocha
Install mocha in global
>sudo npm install -g mocha
install chai on local
>npm install chai
Simple sqrt.js
> cat sqrt.js
var My = {
sqrt: function(x) {
if (x < 0){
throw new Error("can not be negative");
}
return Math.exp(Math.log(x)/2);
}
};
module.exports = My;
Simple tests codes
>cat test/test.sqrt.js
var chai = require('chai');
var expect = chai.expect;
var My = require('../sqrt.js');
describe("sqrt", function() {
it("4 sqrt should be 2", function() {
expect(My.sqrt(4)).to.equal(2);
});
it("throw exception if x is negative", function() {
expect(function(){ My.sqrt(-1); }).to.throw("can not be negative");
});
});
Work together
>istanbul cover _mocha
sqrt
✓ 4 sqrt should be 2
✓ throw exception if x is negative
2 passing (8ms)
=============================================================================
Writing coverage object [/Users/carl/work/nodejs/nodejstest2/coverage/coverage.json]
Writing coverage reports at [/Users/carl/work/nodejs/nodejstest2/coverage]
=============================================================================
=============================== Coverage summary ===============================
Statements : 100% ( 5/5 )
Branches : 100% ( 2/2 )
Functions : 100% ( 1/1 )
Lines : 100% ( 5/5 )
================================================================================
Logging System - bunyan
https://github.com/trentm/node-bunyan
http://www.ctolib.com/node-bunyan.html#installation
Installation
>npm install bunyan --save
>sudo npm install -g bunyan
Simple usage of the Logger
>cat hi.js
var bunyan = require('bunyan');
var log = bunyan.createLogger({name: 'myapp'});
log.info("hi");
log.warn({lang:'fr'}, 'hello');
Show the logging
>node hi.js
{"name":"myapp","hostname":"ip-10-10-21-215.ec2.internal","pid":28178,"level":30,"msg":"hi","time":"2017-06-08T15:20:22.400Z","v":0}
{"name":"myapp","hostname":"ip-10-10-21-215.ec2.internal","pid":28178,"level":40,"lang":"fr","msg":"hello","time":"2017-06-08T15:20:22.402Z","v":0}
Logging in nice format
>node hi.js | bunyan
[2017-06-08T15:22:22.449Z] INFO: myapp/28340 on ip-10-10-21-215.ec2.internal: hi
[2017-06-08T15:22:22.451Z] WARN: myapp/28340 on ip-10-10-21-215.ec2.internal: hello (lang=fr)
>node hi.js | bunyan -l warn
[2017-06-08T15:22:43.041Z] WARN: myapp/28359 on ip-10-10-21-215.ec2.internal: hello (lang=fr)
>node hi.js | bunyan -c 'this.lang == "fr"'
[2017-06-08T15:23:24.429Z] WARN: myapp/28468 on ip-10-10-21-215.ec2.internal: hello (lang=fr)
Commons Tool
https://lodash.com/
https://lodash.com/docs/4.17.4
http://wwsun.github.io/posts/lodash-top-10-functions.html
Markdown-it
https://github.com/markdown-it/markdown-it
https://markdown-it.github.io/
Passport
http://blog.fens.me/nodejs-express-passport/
Here is the version of empty projects
https://github.com/luohuazju/sillycat-blog-backend-express/tree/version-1
References:
http://sillycat.iteye.com/blog/2378442
https://github.com/jackhutu/jackblog-api-express
发表评论
-
Stop Update Here
2020-04-28 09:00 310I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 468NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 362Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 364Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 330Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 424Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 428Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 367Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 445VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 377Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 468NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 414Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 332Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 243GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 445GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 321GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 307Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 310Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 286Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 303Serverless with NodeJS and Tenc ...
相关推荐
ta_lib-0.5.1-cp312-cp312-win32.whl
课程设计 在线实时的斗兽棋游戏,时间赶,粗暴的使用jQuery + websoket 实现实时H5对战游戏 + java.zip课程设计
ta_lib-0.5.1-cp310-cp310-win_amd64.whl
基于springboot+vue物流系统源码数据库文档.zip
GEE训练教程——Landsat5、8和Sentinel-2、DEM和各2哦想指数下载
知识图谱
333498005787635解决keil下载失败的文件.zip
【微信机器人原理与实现】 微信机器人是通过模拟微信客户端的行为,自动处理消息、发送消息的程序。在Python中实现微信机器人的主要库是WeChatBot,它提供了丰富的接口,允许开发者方便地进行微信消息的接收与发送。这个项目标题中的"基于python实现的微信机器人源码"指的是使用Python编程语言编写的微信机器人程序。 1. **Python基础**:Python是一种高级编程语言,以其简洁的语法和强大的功能深受开发者喜爱。在实现微信机器人时,你需要熟悉Python的基本语法、数据类型、函数、类以及异常处理等概念。 2. **微信API与WeChatBot库**:微信为开发者提供了微信公共平台和微信开放平台,可以获取到必要的API来实现机器人功能。WeChatBot库是Python中一个用于微信开发的第三方库,它封装了微信的API,简化了消息处理的流程。使用WeChatBot,开发者可以快速搭建起一个微信机器人。 3. **微信OAuth2.0授权**:为了能够接入微信,首先需要通过OAuth2.0协议获取用户的授权。用户授权后,机器人可以获取到微信用户的身份信息,从而进行
基于springboot实验室研究生信息管理系统源码数据库文档.zip
张力控制,色标跟踪,多轴同步,电子凸轮,横切等工艺控制案例。
在Python编程环境中,处理Microsoft Word文档是一项常见的任务。Python提供了几个库来实现这一目标,如`python-docx`,它可以让我们创建、修改和操作.docx文件。本教程将重点介绍如何利用Python进行Word文档的合并、格式转换以及转换为PDF。 1. **合并Word文档(merge4docx)** 合并多个Word文档是一项实用的功能,特别是在处理大量报告或文档集合时。在Python中,可以使用`python-docx`库实现。我们需要导入`docx`模块,然后读取每个文档并将其内容插入到主文档中。以下是一个基本示例: ```python from docx import Document def merge4docx(file_list, output_file): main_doc = Document() for file in file_list: doc = Document(file) for paragraph in doc.paragraphs: main_doc.add_paragraph(paragraph.text) m
基于springboot+Javaweb的二手图书交易系统源码数据库文档.zip
基于springboot餐品美食论坛源码数据库文档.zip
基于springboot亚运会志愿者管理系统源码数据库文档.zip
使用WPF的数据样式绑定,切换对象数据值来完成控件动态切换背景渐变动画效果。 使用动画样式渲染比线程修改性能消耗更低更稳定
基于SpringBoot的企业客源关系管理系统源码数据库文档.zip
基于springboot+vue的桂林旅游网站系统源码数据库文档.zip
基于springboot嗨玩旅游网站源码数据库文档.zip
基于springboot的流浪动物管理系统源码数据库文档.zip
基于springboot课件通中小学教学课件共享平台源码数据库文档.zip