- 浏览: 2551061 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
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 315I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 475NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 367Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 368Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 335Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 429Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 435Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 373Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 454VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 384Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 475NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 421Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 336Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 246GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 450GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 326GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 312Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 317Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 292Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 311Serverless with NodeJS and Tenc ...
相关推荐
Api-symfony-flex-backend.zip,带有symfony flex的rest api这是什么,一个api可以被认为是多个软件设备之间通信的指导手册。例如,api可用于web应用程序之间的数据库通信。通过提取实现并将数据放弃到对象中,api简化...
文档(ReDoc): ://public-transport-quality-grades.github.io/backend-api/ SwaggerUI: ://public-transport-quality-grades.github.io/backend-api/swagger-ui/ 完整规格: JSON YAML 警告:仅当Travis CI...
标题 "快速学习:https://www.smashingmagazine.com/2020/04/express-api-backend-project-postgresql" 暗示了一个关于使用 Express 框架构建基于 PostgreSQL 数据库的 API 后端项目的教程。Express 是一个非常流行...
标题中的“pw-backend-node-express-master”暗示这是一个使用Node.js和Express.js框架构建的个人网站后端项目。Node.js是一个基于Chrome V8引擎的JavaScript运行环境,它允许开发者在服务器端使用JavaScript进行...
此项目不再维护,因为它现在是提供此API以及更多内容的一部分。 后端API 这种Rack中间件的灵感来自CouchDB API。 我们希望创建一个中间件,该中间件提供您构建CMS所需的每个URL,而仅专注于界面。 所有数据库交互均...
节点CRUD API-后端 使用快递 RESTful CRUD API执行CRUD操作。 它使用Express框架和MongoDB使用Nodejs开发。 这些API与使用ReactJs开发的前端应用程序集成在一起。 您可以在以下链接找到前端应用程序。 早熟 节点v10 ...
数据库设计-backend-1.12.0-20220613.vsdx
标题 "mobile-app-backend-mocha-nodejs" 暗示了这是一个关于使用 Mocha 测试框架与 Node.js 配合开发移动应用后端的项目。在这个项目中,开发者将学习如何构建一个可测试的、可靠的服务器端逻辑,以支持移动应用...
资源分类:Python库 所属语言:Python 资源全名:django_minio_backend-3.0.0-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
标题中的"TA-AC-BACKEND-express-CRUD-TNaaae"和描述中的"TA-C后端表达CRUD-TNaaae"都指向一个关于后端开发的主题,特别是使用Express框架进行CRUD操作的教学或项目。Express是Node.js中最受欢迎的Web应用框架,而...
2. **版本控制**:随着功能的迭代,API可能需要更改,因此应实施版本控制策略,如使用版本号(如/v1,/v2)来区分不同版本的API。 3. **错误处理**:良好的API应该提供明确的错误信息,帮助开发者快速定位问题。 4. ...
Api-http-fake-backend.zip,通过可配置的路由提供json文件或javascript对象的内容来构建假后端。http-fake-backend,一个api可以被认为是多个软件设备之间通信的指导手册。例如,api可用于web应用程序之间的数据库...
《PyPI官网下载:深入解析karp-backend-5-5.26.1.tar.gz》 在Python的世界里,PyPI(Python Package Index)是最重要的软件仓库,它为开发者提供了无数的第三方库和工具,方便他们构建和分享自己的项目。今天我们要...
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
2. **Web框架**:后端开发往往使用特定的框架来加速开发,如Django、Flask(Python)、Express.js(Node.js)等。这些框架提供了基础架构,使得开发者可以专注于业务逻辑。 3. **数据库**:后端通常需要与数据库...
总结来说,这个"backend-architecture-nodejs-mysql-源码.rar"项目涵盖了Node.js后端开发的基础知识,包括使用Express框架构建API、通过mysql2或sequelize库与MySQL数据库交互,以及常见的项目结构和组织方式。...
Api-appy-backend.zip,启动应用程序的用户系统。利用rest hapi启动应用程序的用户系统。,一个api可以被认为是多个软件设备之间通信的指导手册。例如,api可用于web应用程序之间的数据库通信。通过提取实现并将数据...
综上所述,"Node-Express-MongoDB-Backend-API"项目是一个使用Node.js、Express和MongoDB构建的公司管理后端API。它涵盖了后端开发的核心技术,包括数据库设计、API接口开发以及团队协作流程。通过学习和实践这个...
6. **Python 3**: 这个版本的`django_minio_backend`是针对Python 3编写的,不支持Python 2。Python 3是Python编程语言的最新主要分支,具有许多改进和现代化的特性。 7. **Python库的使用**: 在Python项目中,通过...
Apache Flink 是一个流行的开源流处理框架,其在1.13版本中对State Backend进行了多项优化和改进,以提高性能、稳定性和易用性。State Backend是Flink存储和管理状态的关键组件,用于持久化和恢复计算过程中的中间...