- 浏览: 2552534 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
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 476NodeJS12 and Zlib It works as ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 337Traefik 2020(1)Introduction and ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 436Private Registry 2020(1)No auth ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 385Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 479NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 424Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 337Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 248GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 452GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 328GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 314Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 319Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 294Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 312Serverless with NodeJS and Tenc ... -
NodeJS MySQL Library and npmjs
2020-02-07 06:21 288NodeJS MySQL Library and npmjs ... -
Python Library 2019(1)requests and aiohttp
2019-12-18 01:12 261Python Library 2019(1)requests ... -
MongoDB 2019(3)Security and Auth
2019-11-16 06:48 241MongoDB 2019(3)Security and Aut ... -
NodeJS Installation 2019
2019-10-20 02:57 574NodeJS Installation 2019 Insta ... -
Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts
2019-10-18 10:57 266Monitor Tool 2019(2)Monit on Mu ... -
Sqlite Database 2019(1)Sqlite3 Installation and Docker phpsqliteadmin
2019-09-05 11:24 368Sqlite Database 2019(1)Sqlite3 ...
相关推荐
Node.js 基于 mssql 模块连接 SQL Server 数据库的简单封装操作示例 Node.js 是一个基于 JavaScript 的服务器端运行环境,使用 Node.js 可以轻松地连接各种数据库,包括 SQL Server。在本文中,我们将介绍如何使用...
【描述】提到的“包含nodejs-服务器-nodejs-server-wechat-landLordGame”意味着这个游戏的后端服务是用Node.js构建的。Node.js是一个开放源代码、跨平台的JavaScript运行环境,用于在服务器端执行JavaScript代码。...
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
这个压缩包"mockServer+nodejs+express.zip"包含了一套基于MockServer、Node.js和Express搭建的模拟服务器环境。 MockServer允许你定义HTTP响应,包括状态码、头信息以及响应体。这样,当你的前端应用向后端发送...
本文实例讲述了nodejs基于mssql模块连接sqlserver数据库的简单封装操作。分享给大家供大家参考,具体如下: 注意:开启sqlserver服务器允许远程连接的步骤,自行百度,很多经验,nodejs连接sqlserver,最好把防火墙的入站...
标题中的“node.js windows 2008可安装 x64”表明了本文将讨论如何在Windows Server 2008 R2操作系统(x64架构)上安装Node.js。Node.js是一个开源、跨平台的JavaScript运行环境,它允许开发者在服务器端执行...
结合mssql模块,我们可以利用Node.js来与Microsoft SQL Server数据库进行交互,实现数据的增删改查操作。下面我们将详细介绍这个过程。 首先,我们需要安装必要的依赖。在Node.js环境中,可以通过npm(Node包管理器...
NodeJS入门项目案例(Express+Mysql)是一个适合初学者的教程,旨在引导你进入Node.js服务端开发的世界。在这个项目中,我们将使用Express框架,一个简洁且强大的Web应用开发框架,以及Mysql,一个流行的开源关系型...
51单片机socket通信,Nodejs作为server,iOS APP 通过socket通信远控单片机,操作日志存储到MySQL数据库!智能车已经实现 单片机使用ESP8266模块,使单片机联网,nodejs写的一个socket server,iOS手机APP通过socket...
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用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, ...
一个用NodeJS实现的Ftp Servce
【作品名称】:基于 nodejs+SQL server 实现的学生-教师评价系统【课程设计】 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。 【项目...
在本文中,我们将深入探讨如何使用Node.js构建一个简单的推送通知服务器,特别是在提及的项目"nodejs-push-notification-server"中。这个项目利用了Node.js的灵活性和Socket.IO的强大功能,以便实现实时、双向的通信...
nodejs11安装文件,解决win7操作系统nodeJs环境搭建失败问题:Node.js is only supported on Windows 8.1, Windows Server 2012 R2, or higher