Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nayacco/yapi-socketio-mock
https://github.com/nayacco/yapi-socketio-mock
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nayacco/yapi-socketio-mock
- Owner: Nayacco
- Created: 2019-07-29T07:10:25.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T11:41:28.000Z (11 months ago)
- Last Synced: 2024-10-13T18:32:04.884Z (about 1 month ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# yapi-socketio-mock
## 简介
基于 yapi,实现 socket.io 的数据 mock
## 内网部署
环境要求:
- nodejs(7.6+)
- yarn or npm安装:
```bash
git clone https://github.com/GoldSubmarine/yapi-socketio-mock.git
cd yapi-socketio-mock
yarn install
node ./index.js
```## docker 部署
环境要求:
- docker
安装:
```bash
git clone https://github.com/GoldSubmarine/yapi-socketio-mock.git
cd yapi-socketio-mock
docker build -t yapi-socketio-mock .
docker run --rm -d --network host --name ysm yapi-socketio-mock
```## 测试
服务启动后访问 `http://yourip:3001/`,从页面中连接 yapi,测试一个接口,如能成功,则部署成功。
## 防火墙
如果遇到服务无法访问,`http://yourip:3001/`页面打不开,尝试从防火墙开启端口
```bash
# centos 7
firewall-cmd --zone=public --add-port=3001/tcp --permanent
systemctl restart firewalld
```## 使用
```js
const socket = io("http://localhost:3001", {
query: {
mockUrl: "http://192.168.1.1:3000/mock/23/"
}
});
```创建 socket 连接时,添加 `mockUrl` 参数,值为当前项目的 yapi mock 地址,在生产环境时需要注释掉。