-
Notifications
You must be signed in to change notification settings - Fork 10
Home
msdlisper edited this page Dec 9, 2015
·
1 revision
- 将front-end和server-end分离的工具,让fe在本地测试前端的页面但用远程的服务器接口,bird在中间搭一个node服务器请求转发远程服务器。
- 很多时候server-end的接口需要用户登录后才能调,所以配制好用户名和密码后bird自动登录,保存cookie,然后南转发请求。当然有登录有验证码的只能手动配制cookie
- 可以同时启动多个node服务器,他们的端口不能相同,每个端口对应的配制也不一样,可以在浏览器里切换端口达到切换配制(用户、server-end)的目的
- 当cookie失效后能自动再次获取cookie,当然后手动配制的cookie失效后还要手动配制
- 切换用户时,可以使用在项目目录下执行npm use zhangpeng 来切换用户。或在浏览器的console里执行bird.use('zhangpeng')
- 做一个项目时,前后端进度往往不统一,万一后端没跟上进度,但定义好了要返回数据格式,就可以利用bird伪造请求返回数据:将请求拦截,返回本地的数据。
- 目前在node v0.12.7环境下测试,
[{
name: 'project-zhangpeng',
bird_port: 3000,
staticFileRootDirPath: '/project/path',
server: 'http://test.project.com:8901/project/',
uuap_server: 'http://uuap.test.com:8100',
username: 'zhangpeng',
password: 'zhangpeng'
}, {
name: 'project-zhangjia',
bird_port: 3001,
staticFileRootDirPath: '/project/path',
server: 'http://test2.project.com:8901/project/',
uuap_server: 'http://uuap2.test.com:8100',
username: 'zhangjia',
password: 'zhangjia'
}, {
name: 'project2',
bird_port: 3003,
staticFileRootDirPath: '/project/path',
server: 'http://test.project.com:8901/project/',
cookie: 'JESSIONID=xxxxxxxxxxxxxxxxxxx'
}]
- 在gulp的流程的可以加上 var bird = require('birdv2'); var configObj = [..] //完整你自己的配置 bird(configObj)
- 在命令行里面可以直接 node require('birdv2')([{..},{..}]) //补充完配置