- 浏览: 2486262 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
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
NODEJS(19)Generate Docs and Stubby Server and forever Server
1. Docs
In package.json
"gulp-jsdoc" : "0.1.4",
gulp config file gulpfile.js
var jsdoc = require("gulp-jsdoc");
//run app using nodemon
gulp.task('docs', [], function(){
return gulp.src(paths.sources)
.pipe(jsdoc("./docs"));
});
Comments example
/**
* @desc authutil is a nice tool
* @author sillycat
* @module authutil
*/
/**
* @desc decode the token we get from Authorization header
* @param {string} token - token string from the header
* @return {HashMap} - key value pairs about auth info
*/
2. forever
Install forever on small server
> npm install forever -g
Verify the installation
> forever -h
Command to start the app.js
> forever start --minUptime 10000 --spinSleepTime 10000 -a -l forever.log -o out.log -e err.log app.js
Command to list the apps
> forever list
Stop the first process
> forever stop 0
3. Stubby Server
That is really amazing server.
Create a json file there named tasks.json
- request:
url: ^/tasks$
response:
latency: 8000
headers:
content-type: application/json
status: 200
body: >
[{
"title": "nodejs project",
"desc": "I love nodejs"
},{
"title": "scala project",
"desc": "I used scala for long time"
},{
"title": "golang project",
"desc": "it is fastest language I used"
}
]
- request:
url: ^/tasks/query$
query:
type1: value1
type2: value2
response:
latency: 1000
headers:
content-type: application/json
status: 200
body: >
[{
"title": "nodejs project",
"desc": "I love nodejs"
}]
- request:
url: ^/tasks$
method: post
headers:
content-type: application/json
response:
status: 204
The command to install the server
> sudo npm install -g stubby
The command to start the server
> stubby -d test/mock_server/tasks.json -w -l 0.0.0.0 -s 5000
Which is using YAML style to define the request and response.
Integrate that with gulp, I am using the JSON style.
[
{
"request": {
"url": "^/tasks$"
},
"response": {
"latency": 8000,
"headers": {
"content-type": "application/json"
},
"status": 200,
"body": [{
"title": "nodejs project",
"desc": "I love nodejs"
},{
"title": "scala project",
"desc": "I used scala for long time"
},{
"title": "golang project",
"desc": "it is fastest language I used"
}]
}
},
{
"request": {
"url": "^/tasks/query$",
"query": {
"type1": "value1",
"type2": "value2"
}
},
"response": {
"latency": 1000,
"headers": {
"content-type": "application/json"
},
"status": 200,
"body": [{
"title": "nodejs project",
"desc": "I love nodejs"
}]
}
},
{
"request": {
"url": "^/tasks$",
"method": "post",
"headers": {
"content-type": "application/json"
}
},
"response": {
"status": 204
}
}
]
Integrate with gulp.
"gulp-stubby-server": "^0.1.3",
var stubby = require('gulp-stubby-server');
//mock server
gulp.task('mock', function(cb) {
var options = {
files: [
'test/mock/*.{json,yaml,js}'
],
stubs: 5000,
location: '0.0.0.0'
};
stubby(options, cb);
});
References:
http://usejsdoc.org/about-getting-started.html
https://github.com/jsdoc3/jsdoc
https://www.npmjs.com/package/gulp-jsdoc
http://www.jianshu.com/p/6c49e2a0cebe
http://www.qttc.net/201308361.html
http://ctripcruise.github.io/2014/12/16/FHY-jsdoc.html
stubby server
https://github.com/mrak/stubby4node
https://github.com/felixzapata/gulp-stubby-server
1. Docs
In package.json
"gulp-jsdoc" : "0.1.4",
gulp config file gulpfile.js
var jsdoc = require("gulp-jsdoc");
//run app using nodemon
gulp.task('docs', [], function(){
return gulp.src(paths.sources)
.pipe(jsdoc("./docs"));
});
Comments example
/**
* @desc authutil is a nice tool
* @author sillycat
* @module authutil
*/
/**
* @desc decode the token we get from Authorization header
* @param {string} token - token string from the header
* @return {HashMap} - key value pairs about auth info
*/
2. forever
Install forever on small server
> npm install forever -g
Verify the installation
> forever -h
Command to start the app.js
> forever start --minUptime 10000 --spinSleepTime 10000 -a -l forever.log -o out.log -e err.log app.js
Command to list the apps
> forever list
Stop the first process
> forever stop 0
3. Stubby Server
That is really amazing server.
Create a json file there named tasks.json
- request:
url: ^/tasks$
response:
latency: 8000
headers:
content-type: application/json
status: 200
body: >
[{
"title": "nodejs project",
"desc": "I love nodejs"
},{
"title": "scala project",
"desc": "I used scala for long time"
},{
"title": "golang project",
"desc": "it is fastest language I used"
}
]
- request:
url: ^/tasks/query$
query:
type1: value1
type2: value2
response:
latency: 1000
headers:
content-type: application/json
status: 200
body: >
[{
"title": "nodejs project",
"desc": "I love nodejs"
}]
- request:
url: ^/tasks$
method: post
headers:
content-type: application/json
response:
status: 204
The command to install the server
> sudo npm install -g stubby
The command to start the server
> stubby -d test/mock_server/tasks.json -w -l 0.0.0.0 -s 5000
Which is using YAML style to define the request and response.
Integrate that with gulp, I am using the JSON style.
[
{
"request": {
"url": "^/tasks$"
},
"response": {
"latency": 8000,
"headers": {
"content-type": "application/json"
},
"status": 200,
"body": [{
"title": "nodejs project",
"desc": "I love nodejs"
},{
"title": "scala project",
"desc": "I used scala for long time"
},{
"title": "golang project",
"desc": "it is fastest language I used"
}]
}
},
{
"request": {
"url": "^/tasks/query$",
"query": {
"type1": "value1",
"type2": "value2"
}
},
"response": {
"latency": 1000,
"headers": {
"content-type": "application/json"
},
"status": 200,
"body": [{
"title": "nodejs project",
"desc": "I love nodejs"
}]
}
},
{
"request": {
"url": "^/tasks$",
"method": "post",
"headers": {
"content-type": "application/json"
}
},
"response": {
"status": 204
}
}
]
Integrate with gulp.
"gulp-stubby-server": "^0.1.3",
var stubby = require('gulp-stubby-server');
//mock server
gulp.task('mock', function(cb) {
var options = {
files: [
'test/mock/*.{json,yaml,js}'
],
stubs: 5000,
location: '0.0.0.0'
};
stubby(options, cb);
});
References:
http://usejsdoc.org/about-getting-started.html
https://github.com/jsdoc3/jsdoc
https://www.npmjs.com/package/gulp-jsdoc
http://www.jianshu.com/p/6c49e2a0cebe
http://www.qttc.net/201308361.html
http://ctripcruise.github.io/2014/12/16/FHY-jsdoc.html
stubby server
https://github.com/mrak/stubby4node
https://github.com/felixzapata/gulp-stubby-server
发表评论
-
NodeJS12 and Zlib
2020-04-01 07:44 429NodeJS12 and Zlib It works as ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 291Traefik 2020(1)Introduction and ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 373Private Registry 2020(1)No auth ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 334Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 415NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 359Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 290Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 207GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 390GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 274GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 263Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 259Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 250Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 233Serverless with NodeJS and Tenc ... -
NodeJS MySQL Library and npmjs
2020-02-07 06:21 233NodeJS MySQL Library and npmjs ... -
Python Library 2019(1)requests and aiohttp
2019-12-18 01:12 225Python Library 2019(1)requests ... -
MongoDB 2019(3)Security and Auth
2019-11-16 06:48 202MongoDB 2019(3)Security and Aut ... -
NodeJS Installation 2019
2019-10-20 02:57 517NodeJS Installation 2019 Insta ... -
Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts
2019-10-18 10:57 229Monitor Tool 2019(2)Monit on Mu ... -
Sqlite Database 2019(1)Sqlite3 Installation and Docker phpsqliteadmin
2019-09-05 11:24 319Sqlite Database 2019(1)Sqlite3 ...
相关推荐
nodejs基于mssql模块连接sqlserver数据库的简单封装操作示例.docx
微信小游戏-斗地主,包含nodejs-服务器-nodejs-server-wechat-landLordGame
将nodejs操作SQL Server简单化
用nodejs+mssql+SQL Server实现增删改查
nodejs 创建的http server与https server,用于调式https双向认证使用
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
based on nodejs as server and return a web
初识NodeJS服务端开发(Express+Mysql)
mockServer模拟服务器请求,方便移动端优先开发,需要配合nodejs启动服务,只需要本地配置好json格式的数据格式即可,使用起来很方便
主要介绍了nodejs基于mssql模块连接sqlserver数据库的简单封装操作,结合实例形式分析了nodejs中mssql模块的安装与操作sqlserver数据库相关使用技巧,需要的朋友可以参考下
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
https证书文件,nodejs http-server开启https的证书,可以直接在本地启动https的协议,方便部署和使用。
It then moves on to show you how to use controllers and view models to generate reusable code that will reduce development time. Toward the end of the book, we will cover tests to properly execute ...
微信小游戏斗地主小游戏源码,前端加nodejs-服务器nodejs-server-wechat-landLordGame-master.zip
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
下载node.exe之后,放到c盘nodejs文件下,在环境变量path里面加上 c:\nodejs\node.exe,在nodejs目录下建立server.js,文件里面写上这些 var http = require('http'); http.createServer(function (request, ...