Commit 1a3e9d87 authored by nanahira's avatar nanahira

adapt ws

parent 2e062606
/dist
\ No newline at end of file
......@@ -92,8 +92,21 @@ Koishi-Nest 的配置项和 Koishi 配置项一致,参照 [Koishi 文档](http
插件的使用可以参考 [Koishi 文档](https://koishi.js.org/v4/guide/plugin/plugin.html)`moduleSelection` 的使用见本文 **复用性** 部分。
* `useWs`: `boolean` 默认 `false` 。是否启用 WebSocket 。**异步配置该项应写入异步配置项中。** 详见本文的 **WebSocket** 部分。
* `isGlobal`: `boolean` 默认 `true` 。指示 Koishi-Nest 模块是否应被注册为全局模块,建议开启。当安装了其他模块的情况下,需要将 Koishi-Nest 注册为全局模块使得其他模块可以正常注入 Koishi-Nest 作为依赖项。 **异步配置该项应写入异步配置项中。** 关于全局模块请参考 [Nest.js 文档](https://docs.nestjs.cn/8/modules?id=%e5%85%a8%e5%b1%80%e6%a8%a1%e5%9d%97)
## WebSocket
Koishi-Nest 针对 Koishi 的 WebSocket 功能进行了针对 Nest.js 的适配。
若要使用 Koishi 的与 WebSocket 服务器相关的插件或功能,需要在 Koishi-Nest 配置项中,把 `useWs` 设置为 `true` ,并在 `main.ts` 修改下列部分。
```ts
const app = await NestFactory.create(AppModule);
app.useWebSocketAdapter(new KoishiWsAdapter(app));
```
## 注入 Koishi 实例
可以直接注入 Koishi 实例或上下文进行注册操作。这种情况下,建议让 Nest 提供者实现 `OnModuleInit` 接口,并在该事件方法中进行 Koishi 指令注册操作。
......
......@@ -3,3 +3,4 @@ export * from './src/koishi.interfaces';
export * from './src/koishi.service';
export * from './src/koishi.module';
export * from './src/koishi-context.factory';
export * from './src/koishi.ws-adapter';
......@@ -9,16 +9,18 @@
"version": "1.3.3",
"license": "MIT",
"dependencies": {
"@koa/router": "^10.1.1",
"@nestjs/platform-ws": "^8.1.2",
"@nestjs/websockets": "^8.1.2",
"@types/ws": "^8.2.0",
"koa": "^2.13.3",
"koa-bodyparser": "^4.3.0",
"lodash": "^4.17.21"
"lodash": "^4.17.21",
"ws": "^8.2.3"
},
"devDependencies": {
"@nestjs/common": "^8.0.9",
"@nestjs/core": "^8.0.9",
"@types/koa": "^2.13.4",
"@types/koa__router": "^8.0.8",
"@types/koa-bodyparser": "^4.3.3",
"@types/lodash": "^4.14.175",
"@types/node": "^16.10.2",
......@@ -28,18 +30,18 @@
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.1",
"express": "^4.17.1",
"koishi": "^4.0.0-alpha.11",
"koishi": "^4.0.0-alpha.12",
"prettier": "^2.4.1",
"proxy-agent": "^5.0.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.4.0",
"typescript": "^4.4.3"
},
"peerDependencies": {
"@nestjs/common": "^8.0.0",
"@nestjs/core": "^8.0.0",
"koishi": "^4.0.0-alpha.11",
"proxy-agent": "^5.0.0",
"reflect-metadata": "^0.1.13"
"koishi": "^4.0.0-alpha.12",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.4.0"
}
},
"node_modules/@babel/code-frame": {
......@@ -198,6 +200,7 @@
"version": "10.1.1",
"resolved": "https://registry.npmjs.org/@koa/router/-/router-10.1.1.tgz",
"integrity": "sha512-ORNjq5z4EmQPriKbR0ER3k4Gh7YGNhWDL7JBW+8wXDrHLbWYKYSJaOJ9aN06npF5tbTxe2JBOsurpJDAvjiXKw==",
"dev": true,
"dependencies": {
"debug": "^4.1.1",
"http-errors": "^1.7.3",
......@@ -212,15 +215,16 @@
"node_modules/@koa/router/node_modules/path-to-regexp": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.0.tgz",
"integrity": "sha512-f66KywYG6+43afgE/8j/GoiNyygk/bnoCbps++3ErRKsIYkGGupyv07R2Ok5m9i67Iqc+T2g1eAUGUPzWhYTyg=="
"integrity": "sha512-f66KywYG6+43afgE/8j/GoiNyygk/bnoCbps++3ErRKsIYkGGupyv07R2Ok5m9i67Iqc+T2g1eAUGUPzWhYTyg==",
"dev": true
},
"node_modules/@koishijs/core": {
"version": "4.0.0-alpha.10",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.0.0-alpha.10.tgz",
"integrity": "sha512-VoCRV2pGyFsqxvvZnUz7a0/rvzwNoS4c61cdyKX05K3fjiHuzBWezk5vNwkgE5pvtCGmMXaOmMwSfazSZ/rLLQ==",
"version": "4.0.0-alpha.11",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.0.0-alpha.11.tgz",
"integrity": "sha512-nN9NJi83/vcfX0w20C1CulBMImhAgrts7YwYPivHDKORq7zq+c76fVPVx5IoTsmavqGpaQ75hHDlua70ZOl7BA==",
"dev": true,
"dependencies": {
"@koishijs/utils": "^5.0.0-alpha.6",
"@koishijs/utils": "^5.0.0-alpha.7",
"fastest-levenshtein": "^1.0.12"
},
"engines": {
......@@ -228,15 +232,15 @@
}
},
"node_modules/@koishijs/plugin-cache-lru": {
"version": "1.0.0-alpha.1",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-cache-lru/-/plugin-cache-lru-1.0.0-alpha.1.tgz",
"integrity": "sha512-GaLkOMMOy7djNSOT/eGHSUEu4kikmUjmxJIvOrAA/Y7oJAdXaTcY4gcZi5Vtie6NWXUIBssqqJmcJBgF/Bwwvw==",
"version": "1.0.0-alpha.2",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-cache-lru/-/plugin-cache-lru-1.0.0-alpha.2.tgz",
"integrity": "sha512-OthEMPDLEvFeJ7KPj8Wv/FlZUzAhDUMxb8rSZhZdLlLfSavK7q0HcjiTxCdLgmv7Er7Qg5Zb14YFH6ym9XIe3Q==",
"dev": true,
"dependencies": {
"lru-cache": "^6.0.0"
},
"peerDependencies": {
"koishi": "^4.0.0-alpha.10"
"koishi": "^4.0.0-alpha.12"
}
},
"node_modules/@koishijs/utils": {
......@@ -267,7 +271,6 @@
"version": "8.0.9",
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-8.0.9.tgz",
"integrity": "sha512-Y3DQxOD57suyvMURpgqX0IBFliMZZNvp1bhvjzjU376Igh33NIz18xhxV9EKe+F0EHHawyM3cv1ZEGYi0yGrtQ==",
"dev": true,
"dependencies": {
"axios": "0.21.4",
"iterare": "1.2.1",
......@@ -300,14 +303,12 @@
"node_modules/@nestjs/common/node_modules/tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
"dev": true
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
},
"node_modules/@nestjs/core": {
"version": "8.0.9",
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-8.0.9.tgz",
"integrity": "sha512-Q8bge+yuFzcuW9iY5fiMz3gydyB3D25dO9/YFGEtHexw2ipQA1QCt94XfIxGqFe1C07k5IDSK/C/l+R33CHrGg==",
"dev": true,
"hasInstallScript": true,
"dependencies": {
"@nuxtjs/opencollective": "0.3.2",
......@@ -345,8 +346,77 @@
"node_modules/@nestjs/core/node_modules/tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
"dev": true
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
},
"node_modules/@nestjs/platform-ws": {
"version": "8.1.2",
"resolved": "https://registry.npmjs.org/@nestjs/platform-ws/-/platform-ws-8.1.2.tgz",
"integrity": "sha512-l/zaB6DT1hHz7AGfvn63V2/EwJqw5C5eLiMgAS9g5TYoEomz4IxGZ8NxeU+cZ1SxCWzcxgvgxqPcfM+LnkQ81g==",
"dependencies": {
"tslib": "2.3.1",
"ws": "7.5.5"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/nest"
},
"peerDependencies": {
"@nestjs/common": "^8.0.0",
"@nestjs/websockets": "^8.0.0",
"rxjs": "^7.1.0"
}
},
"node_modules/@nestjs/platform-ws/node_modules/tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
},
"node_modules/@nestjs/platform-ws/node_modules/ws": {
"version": "7.5.5",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.5.tgz",
"integrity": "sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w==",
"engines": {
"node": ">=8.3.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
},
"node_modules/@nestjs/websockets": {
"version": "8.1.2",
"resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-8.1.2.tgz",
"integrity": "sha512-pt/VmM2VJ3UMfo6Fr3ghZFjDF3UlngsYKsjYThFMLmq6kltqLkp5JrvxrZceHMtbywWTcybTKRRL2WCBjgFbmg==",
"dependencies": {
"iterare": "1.2.1",
"object-hash": "2.2.0",
"tslib": "2.3.1"
},
"peerDependencies": {
"@nestjs/common": "^8.0.0",
"@nestjs/core": "^8.0.0",
"@nestjs/platform-socket.io": "^8.0.0",
"reflect-metadata": "^0.1.12",
"rxjs": "^7.1.0"
},
"peerDependenciesMeta": {
"@nestjs/platform-socket.io": {
"optional": true
}
}
},
"node_modules/@nestjs/websockets/node_modules/tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
},
"node_modules/@nodelib/fs.scandir": {
"version": "2.1.5",
......@@ -387,7 +457,6 @@
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz",
"integrity": "sha512-um0xL3fO7Mf4fDxcqx9KryrB7zgRM5JSlvGN5AGkP6JLM5XEKyjeAiPbNxdXVXQ16isuAhYpvP88NgL2BGd6aA==",
"dev": true,
"dependencies": {
"chalk": "^4.1.0",
"consola": "^2.15.0",
......@@ -561,8 +630,7 @@
"node_modules/@types/node": {
"version": "16.10.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.10.2.tgz",
"integrity": "sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ==",
"dev": true
"integrity": "sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ=="
},
"node_modules/@types/qs": {
"version": "6.9.7",
......@@ -587,10 +655,9 @@
}
},
"node_modules/@types/ws": {
"version": "7.4.7",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz",
"integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==",
"dev": true,
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.0.tgz",
"integrity": "sha512-cyeefcUCgJlEk+hk2h3N+MqKKsPViQgF5boi9TTHSK+PoR9KWBb/C5ccPcDyAqgsbAYHTwulch725DV84+pSpg==",
"dependencies": {
"@types/node": "*"
}
......@@ -835,7 +902,6 @@
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"dependencies": {
"color-convert": "^2.0.1"
},
......@@ -901,7 +967,6 @@
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"dev": true,
"dependencies": {
"follow-redirects": "^1.14.0"
}
......@@ -1067,7 +1132,6 @@
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
......@@ -1103,7 +1167,6 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"dependencies": {
"color-name": "~1.1.4"
},
......@@ -1114,8 +1177,7 @@
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/concat-map": {
"version": "0.0.1",
......@@ -1126,8 +1188,7 @@
"node_modules/consola": {
"version": "2.15.3",
"resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz",
"integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==",
"dev": true
"integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw=="
},
"node_modules/content-disposition": {
"version": "0.5.3",
......@@ -1810,8 +1871,7 @@
"node_modules/fast-safe-stringify": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz",
"integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==",
"dev": true
"integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA=="
},
"node_modules/fastest-levenshtein": {
"version": "1.0.12",
......@@ -1917,7 +1977,6 @@
"version": "1.14.4",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz",
"integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==",
"dev": true,
"funding": [
{
"type": "individual",
......@@ -2112,7 +2171,6 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"engines": {
"node": ">=8"
}
......@@ -2348,7 +2406,6 @@
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/iterare/-/iterare-1.2.1.tgz",
"integrity": "sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==",
"dev": true,
"engines": {
"node": ">=6"
}
......@@ -2475,14 +2532,14 @@
}
},
"node_modules/koishi": {
"version": "4.0.0-alpha.11",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.0.0-alpha.11.tgz",
"integrity": "sha512-gohzZ2IbMA21Z+f+MF6DpioGpaf0N3iXFcGXxOjcB/rwRZkT4nXvJsur3Id+O85xfsGpSoSnITRbxFU3CEz//w==",
"version": "4.0.0-alpha.12",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.0.0-alpha.12.tgz",
"integrity": "sha512-MT2avgFNrjScgAZhTVbmxZHQ38y6Vs3ibJ2nDuopfl04D9+GTRSoeUiBIxJXOFjauUkLGpJRaSrlX8uOatHFOA==",
"dev": true,
"dependencies": {
"@koa/router": "^10.1.1",
"@koishijs/core": "^4.0.0-alpha.10",
"@koishijs/plugin-cache-lru": "^1.0.0-alpha.1",
"@koishijs/core": "^4.0.0-alpha.11",
"@koishijs/plugin-cache-lru": "^1.0.0-alpha.2",
"@koishijs/utils": "^5.0.0-alpha.7",
"@types/koa": "*",
"@types/koa__router": "*",
......@@ -2490,12 +2547,29 @@
"axios": "^0.21.4",
"koa": "^2.13.1",
"koa-bodyparser": "^4.3.0",
"parseurl": "^1.3.3",
"path-to-regexp": "^6.2.0",
"proxy-agent": "^5.0.0"
},
"engines": {
"node": ">=12.0.0"
}
},
"node_modules/koishi/node_modules/@types/ws": {
"version": "7.4.7",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz",
"integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/koishi/node_modules/path-to-regexp": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.0.tgz",
"integrity": "sha512-f66KywYG6+43afgE/8j/GoiNyygk/bnoCbps++3ErRKsIYkGGupyv07R2Ok5m9i67Iqc+T2g1eAUGUPzWhYTyg==",
"dev": true
},
"node_modules/levn": {
"version": "0.4.1",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
......@@ -2571,6 +2645,7 @@
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=",
"dev": true,
"engines": {
"node": ">= 0.6"
}
......@@ -2663,7 +2738,6 @@
"version": "2.6.5",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz",
"integrity": "sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==",
"dev": true,
"dependencies": {
"whatwg-url": "^5.0.0"
},
......@@ -2675,7 +2749,6 @@
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.2.0.tgz",
"integrity": "sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw==",
"dev": true,
"engines": {
"node": ">= 6"
}
......@@ -2805,8 +2878,7 @@
"node_modules/path-to-regexp": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.2.0.tgz",
"integrity": "sha512-jczvQbCUS7XmS7o+y1aEO9OBVFeZBQ1MDSEqmO7xSoPgOPoowY/SxLpZ6Vh97/8qHZOteiCKb7gkG9gA2ZUxJA==",
"dev": true
"integrity": "sha512-jczvQbCUS7XmS7o+y1aEO9OBVFeZBQ1MDSEqmO7xSoPgOPoowY/SxLpZ6Vh97/8qHZOteiCKb7gkG9gA2ZUxJA=="
},
"node_modules/path-type": {
"version": "4.0.0",
......@@ -3025,8 +3097,7 @@
"node_modules/reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==",
"dev": true
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg=="
},
"node_modules/regexpp": {
"version": "3.2.0",
......@@ -3107,11 +3178,9 @@
}
},
"node_modules/rxjs": {
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.3.1.tgz",
"integrity": "sha512-vNenx7gqjPyeKpRnM6S5Ksm/oFTRijWWzYlRON04KaehZ3YjDwEmVjGUGo0TKWVjeNXOujVRlh0K1drUbcdPkw==",
"dev": true,
"peer": true,
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.4.0.tgz",
"integrity": "sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w==",
"dependencies": {
"tslib": "~2.1.0"
}
......@@ -3119,9 +3188,7 @@
"node_modules/rxjs/node_modules/tslib": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz",
"integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==",
"dev": true,
"peer": true
"integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A=="
},
"node_modules/safe-buffer": {
"version": "5.1.2",
......@@ -3405,7 +3472,6 @@
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"dependencies": {
"has-flag": "^4.0.0"
},
......@@ -3481,8 +3547,7 @@
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=",
"dev": true
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
},
"node_modules/tslib": {
"version": "1.14.1",
......@@ -3601,7 +3666,6 @@
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"dev": true,
"bin": {
"uuid": "dist/bin/uuid"
}
......@@ -3635,14 +3699,12 @@
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=",
"dev": true
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
"dev": true,
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
......@@ -3678,6 +3740,26 @@
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
},
"node_modules/ws": {
"version": "8.2.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz",
"integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==",
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
},
"node_modules/xregexp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz",
......@@ -3833,6 +3915,7 @@
"version": "10.1.1",
"resolved": "https://registry.npmjs.org/@koa/router/-/router-10.1.1.tgz",
"integrity": "sha512-ORNjq5z4EmQPriKbR0ER3k4Gh7YGNhWDL7JBW+8wXDrHLbWYKYSJaOJ9aN06npF5tbTxe2JBOsurpJDAvjiXKw==",
"dev": true,
"requires": {
"debug": "^4.1.1",
"http-errors": "^1.7.3",
......@@ -3844,24 +3927,25 @@
"path-to-regexp": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.0.tgz",
"integrity": "sha512-f66KywYG6+43afgE/8j/GoiNyygk/bnoCbps++3ErRKsIYkGGupyv07R2Ok5m9i67Iqc+T2g1eAUGUPzWhYTyg=="
"integrity": "sha512-f66KywYG6+43afgE/8j/GoiNyygk/bnoCbps++3ErRKsIYkGGupyv07R2Ok5m9i67Iqc+T2g1eAUGUPzWhYTyg==",
"dev": true
}
}
},
"@koishijs/core": {
"version": "4.0.0-alpha.10",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.0.0-alpha.10.tgz",
"integrity": "sha512-VoCRV2pGyFsqxvvZnUz7a0/rvzwNoS4c61cdyKX05K3fjiHuzBWezk5vNwkgE5pvtCGmMXaOmMwSfazSZ/rLLQ==",
"version": "4.0.0-alpha.11",
"resolved": "https://registry.npmjs.org/@koishijs/core/-/core-4.0.0-alpha.11.tgz",
"integrity": "sha512-nN9NJi83/vcfX0w20C1CulBMImhAgrts7YwYPivHDKORq7zq+c76fVPVx5IoTsmavqGpaQ75hHDlua70ZOl7BA==",
"dev": true,
"requires": {
"@koishijs/utils": "^5.0.0-alpha.6",
"@koishijs/utils": "^5.0.0-alpha.7",
"fastest-levenshtein": "^1.0.12"
}
},
"@koishijs/plugin-cache-lru": {
"version": "1.0.0-alpha.1",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-cache-lru/-/plugin-cache-lru-1.0.0-alpha.1.tgz",
"integrity": "sha512-GaLkOMMOy7djNSOT/eGHSUEu4kikmUjmxJIvOrAA/Y7oJAdXaTcY4gcZi5Vtie6NWXUIBssqqJmcJBgF/Bwwvw==",
"version": "1.0.0-alpha.2",
"resolved": "https://registry.npmjs.org/@koishijs/plugin-cache-lru/-/plugin-cache-lru-1.0.0-alpha.2.tgz",
"integrity": "sha512-OthEMPDLEvFeJ7KPj8Wv/FlZUzAhDUMxb8rSZhZdLlLfSavK7q0HcjiTxCdLgmv7Er7Qg5Zb14YFH6ym9XIe3Q==",
"dev": true,
"requires": {
"lru-cache": "^6.0.0"
......@@ -3891,7 +3975,6 @@
"version": "8.0.9",
"resolved": "https://registry.npmjs.org/@nestjs/common/-/common-8.0.9.tgz",
"integrity": "sha512-Y3DQxOD57suyvMURpgqX0IBFliMZZNvp1bhvjzjU376Igh33NIz18xhxV9EKe+F0EHHawyM3cv1ZEGYi0yGrtQ==",
"dev": true,
"requires": {
"axios": "0.21.4",
"iterare": "1.2.1",
......@@ -3902,8 +3985,7 @@
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
"dev": true
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
}
}
},
......@@ -3911,7 +3993,6 @@
"version": "8.0.9",
"resolved": "https://registry.npmjs.org/@nestjs/core/-/core-8.0.9.tgz",
"integrity": "sha512-Q8bge+yuFzcuW9iY5fiMz3gydyB3D25dO9/YFGEtHexw2ipQA1QCt94XfIxGqFe1C07k5IDSK/C/l+R33CHrGg==",
"dev": true,
"requires": {
"@nuxtjs/opencollective": "0.3.2",
"fast-safe-stringify": "2.1.1",
......@@ -3925,8 +4006,46 @@
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
"dev": true
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
}
}
},
"@nestjs/platform-ws": {
"version": "8.1.2",
"resolved": "https://registry.npmjs.org/@nestjs/platform-ws/-/platform-ws-8.1.2.tgz",
"integrity": "sha512-l/zaB6DT1hHz7AGfvn63V2/EwJqw5C5eLiMgAS9g5TYoEomz4IxGZ8NxeU+cZ1SxCWzcxgvgxqPcfM+LnkQ81g==",
"requires": {
"tslib": "2.3.1",
"ws": "7.5.5"
},
"dependencies": {
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
},
"ws": {
"version": "7.5.5",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.5.tgz",
"integrity": "sha512-BAkMFcAzl8as1G/hArkxOxq3G7pjUqQ3gzYbLL0/5zNkph70e+lCoxBGnm6AW1+/aiNeV4fnKqZ8m4GZewmH2w==",
"requires": {}
}
}
},
"@nestjs/websockets": {
"version": "8.1.2",
"resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-8.1.2.tgz",
"integrity": "sha512-pt/VmM2VJ3UMfo6Fr3ghZFjDF3UlngsYKsjYThFMLmq6kltqLkp5JrvxrZceHMtbywWTcybTKRRL2WCBjgFbmg==",
"requires": {
"iterare": "1.2.1",
"object-hash": "2.2.0",
"tslib": "2.3.1"
},
"dependencies": {
"tslib": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
}
}
},
......@@ -3960,7 +4079,6 @@
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz",
"integrity": "sha512-um0xL3fO7Mf4fDxcqx9KryrB7zgRM5JSlvGN5AGkP6JLM5XEKyjeAiPbNxdXVXQ16isuAhYpvP88NgL2BGd6aA==",
"dev": true,
"requires": {
"chalk": "^4.1.0",
"consola": "^2.15.0",
......@@ -4124,8 +4242,7 @@
"@types/node": {
"version": "16.10.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.10.2.tgz",
"integrity": "sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ==",
"dev": true
"integrity": "sha512-zCclL4/rx+W5SQTzFs9wyvvyCwoK9QtBpratqz2IYJ3O8Umrn0m3nsTv0wQBk9sRGpvUe9CwPDrQFB10f1FIjQ=="
},
"@types/qs": {
"version": "6.9.7",
......@@ -4150,10 +4267,9 @@
}
},
"@types/ws": {
"version": "7.4.7",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz",
"integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==",
"dev": true,
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.2.0.tgz",
"integrity": "sha512-cyeefcUCgJlEk+hk2h3N+MqKKsPViQgF5boi9TTHSK+PoR9KWBb/C5ccPcDyAqgsbAYHTwulch725DV84+pSpg==",
"requires": {
"@types/node": "*"
}
......@@ -4300,7 +4416,6 @@
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"requires": {
"color-convert": "^2.0.1"
}
......@@ -4353,7 +4468,6 @@
"version": "0.21.4",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.21.4.tgz",
"integrity": "sha512-ut5vewkiu8jjGBdqpM44XxjuCjq9LAKeHVmoVfHVzy8eHgxxq8SbAVQNovDA8mVi05kP0Ea/n/UzcSHcTJQfNg==",
"dev": true,
"requires": {
"follow-redirects": "^1.14.0"
}
......@@ -4494,7 +4608,6 @@
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
......@@ -4520,7 +4633,6 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"requires": {
"color-name": "~1.1.4"
}
......@@ -4528,8 +4640,7 @@
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"concat-map": {
"version": "0.0.1",
......@@ -4540,8 +4651,7 @@
"consola": {
"version": "2.15.3",
"resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz",
"integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==",
"dev": true
"integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw=="
},
"content-disposition": {
"version": "0.5.3",
......@@ -5070,8 +5180,7 @@
"fast-safe-stringify": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz",
"integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==",
"dev": true
"integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA=="
},
"fastest-levenshtein": {
"version": "1.0.12",
......@@ -5163,8 +5272,7 @@
"follow-redirects": {
"version": "1.14.4",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.4.tgz",
"integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g==",
"dev": true
"integrity": "sha512-zwGkiSXC1MUJG/qmeIFH2HBJx9u0V46QGUe3YR1fXG8bXQxq7fLj0RjLZQ5nubr9qNJUZrH+xUcwXEoXNpfS+g=="
},
"forwarded": {
"version": "0.2.0",
......@@ -5302,8 +5410,7 @@
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
},
"has-symbols": {
"version": "1.0.2",
......@@ -5472,8 +5579,7 @@
"iterare": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/iterare/-/iterare-1.2.1.tgz",
"integrity": "sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==",
"dev": true
"integrity": "sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q=="
},
"js-tokens": {
"version": "4.0.0",
......@@ -5581,14 +5687,14 @@
}
},
"koishi": {
"version": "4.0.0-alpha.11",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.0.0-alpha.11.tgz",
"integrity": "sha512-gohzZ2IbMA21Z+f+MF6DpioGpaf0N3iXFcGXxOjcB/rwRZkT4nXvJsur3Id+O85xfsGpSoSnITRbxFU3CEz//w==",
"version": "4.0.0-alpha.12",
"resolved": "https://registry.npmjs.org/koishi/-/koishi-4.0.0-alpha.12.tgz",
"integrity": "sha512-MT2avgFNrjScgAZhTVbmxZHQ38y6Vs3ibJ2nDuopfl04D9+GTRSoeUiBIxJXOFjauUkLGpJRaSrlX8uOatHFOA==",
"dev": true,
"requires": {
"@koa/router": "^10.1.1",
"@koishijs/core": "^4.0.0-alpha.10",
"@koishijs/plugin-cache-lru": "^1.0.0-alpha.1",
"@koishijs/core": "^4.0.0-alpha.11",
"@koishijs/plugin-cache-lru": "^1.0.0-alpha.2",
"@koishijs/utils": "^5.0.0-alpha.7",
"@types/koa": "*",
"@types/koa__router": "*",
......@@ -5596,7 +5702,26 @@
"axios": "^0.21.4",
"koa": "^2.13.1",
"koa-bodyparser": "^4.3.0",
"parseurl": "^1.3.3",
"path-to-regexp": "^6.2.0",
"proxy-agent": "^5.0.0"
},
"dependencies": {
"@types/ws": {
"version": "7.4.7",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz",
"integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"path-to-regexp": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.0.tgz",
"integrity": "sha512-f66KywYG6+43afgE/8j/GoiNyygk/bnoCbps++3ErRKsIYkGGupyv07R2Ok5m9i67Iqc+T2g1eAUGUPzWhYTyg==",
"dev": true
}
}
},
"levn": {
......@@ -5661,7 +5786,8 @@
"methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=",
"dev": true
},
"micromatch": {
"version": "4.0.4",
......@@ -5727,7 +5853,6 @@
"version": "2.6.5",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz",
"integrity": "sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==",
"dev": true,
"requires": {
"whatwg-url": "^5.0.0"
}
......@@ -5735,8 +5860,7 @@
"object-hash": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-2.2.0.tgz",
"integrity": "sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw==",
"dev": true
"integrity": "sha512-gScRMn0bS5fH+IuwyIFgnh9zBdo4DV+6GhygmWM9HyNJSgS0hScp1f5vjtm7oIIOiT9trXrShAkLFSc2IqKNgw=="
},
"object-inspect": {
"version": "1.11.0",
......@@ -5836,8 +5960,7 @@
"path-to-regexp": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.2.0.tgz",
"integrity": "sha512-jczvQbCUS7XmS7o+y1aEO9OBVFeZBQ1MDSEqmO7xSoPgOPoowY/SxLpZ6Vh97/8qHZOteiCKb7gkG9gA2ZUxJA==",
"dev": true
"integrity": "sha512-jczvQbCUS7XmS7o+y1aEO9OBVFeZBQ1MDSEqmO7xSoPgOPoowY/SxLpZ6Vh97/8qHZOteiCKb7gkG9gA2ZUxJA=="
},
"path-type": {
"version": "4.0.0",
......@@ -5998,8 +6121,7 @@
"reflect-metadata": {
"version": "0.1.13",
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==",
"dev": true
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg=="
},
"regexpp": {
"version": "3.2.0",
......@@ -6044,11 +6166,9 @@
}
},
"rxjs": {
"version": "7.3.1",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.3.1.tgz",
"integrity": "sha512-vNenx7gqjPyeKpRnM6S5Ksm/oFTRijWWzYlRON04KaehZ3YjDwEmVjGUGo0TKWVjeNXOujVRlh0K1drUbcdPkw==",
"dev": true,
"peer": true,
"version": "7.4.0",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.4.0.tgz",
"integrity": "sha512-7SQDi7xeTMCJpqViXh8gL/lebcwlp3d831F05+9B44A4B0WfsEwUQHR64gsH1kvJ+Ep/J9K2+n1hVl1CsGN23w==",
"requires": {
"tslib": "~2.1.0"
},
......@@ -6056,9 +6176,7 @@
"tslib": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz",
"integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==",
"dev": true,
"peer": true
"integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A=="
}
}
},
......@@ -6286,7 +6404,6 @@
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"requires": {
"has-flag": "^4.0.0"
}
......@@ -6348,8 +6465,7 @@
"tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=",
"dev": true
"integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o="
},
"tslib": {
"version": "1.14.1",
......@@ -6430,8 +6546,7 @@
"uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"dev": true
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
},
"v8-compile-cache": {
"version": "2.3.0",
......@@ -6453,14 +6568,12 @@
"webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=",
"dev": true
"integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE="
},
"whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=",
"dev": true,
"requires": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
......@@ -6487,6 +6600,12 @@
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true
},
"ws": {
"version": "8.2.3",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz",
"integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==",
"requires": {}
},
"xregexp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz",
......
import { Injectable } from '@nestjs/common';
import { AbstractHttpAdapter, HttpAdapterHost, ModuleRef } from '@nestjs/core';
import { AbstractWsAdapter } from '@nestjs/websockets';
@Injectable()
export class KoishiHttpDiscoveryService {
constructor(private readonly moduleRef: ModuleRef) {}
getHttpAdapter(): AbstractHttpAdapter {
const apdaterHost = this.moduleRef.get(HttpAdapterHost, { strict: false });
if (apdaterHost) {
return apdaterHost.httpAdapter;
} else {
return null;
}
}
}
......@@ -52,11 +52,14 @@ export interface KoishiModuleSelection extends ContextSelector {
module: Type<any>;
}
export interface WhetherGlobalOption {
export interface KoishiModuleTopOptions {
isGlobal?: boolean;
useWs?: boolean;
}
export interface KoishiModuleOptions extends App.Config, WhetherGlobalOption {
export interface KoishiModuleOptions
extends App.Config,
KoishiModuleTopOptions {
usePlugins?: KoishiModulePlugin<Plugin>[];
loggerPrefix?: string;
loggerColor?: number;
......@@ -69,7 +72,7 @@ export interface KoishiModuleOptionsFactory {
export interface KoishiModuleAsyncOptions
extends Pick<ModuleMetadata, 'imports'>,
WhetherGlobalOption {
KoishiModuleTopOptions {
useExisting?: Type<KoishiModuleOptionsFactory>;
useClass?: Type<KoishiModuleOptionsFactory>;
useFactory?: (
......
......@@ -26,6 +26,8 @@ import { Context } from 'koishi';
import { defaultContextContainer } from './koishi-context.factory';
import { KoishiInjectionService } from './providers/koishi-injection.service';
import { KoishiContextService } from './providers/koishi-context.service';
import { KoishiHttpDiscoveryService } from './koishi-http-discovery/koishi-http-discovery.service';
import { KoishiWebsocketGateway } from './providers/koishi-websocket.gateway';
const koishiContextProvider: Provider<Context> = {
provide: KOISHI_CONTEXT,
......@@ -44,6 +46,7 @@ const koishiContextProvider: Provider<Context> = {
koishiContextProvider,
KoishiContextService,
KoishiInjectionService,
KoishiHttpDiscoveryService,
],
exports: [KoishiService, koishiContextProvider],
})
......@@ -58,6 +61,7 @@ export class KoishiModule implements NestModule {
providers: [
{ provide: KOISHI_MODULE_OPTIONS, useValue: options },
...defaultContextContainer.contextsToProvide,
...(options.useWs ? [KoishiWebsocketGateway] : []),
],
exports: defaultContextContainer.contextsToProvide,
global: options.isGlobal != null ? options.isGlobal : true,
......@@ -72,6 +76,7 @@ export class KoishiModule implements NestModule {
...this.createAsyncProviders(options),
...defaultContextContainer.contextsToProvide,
...(options.extraProviders || []),
...(options.useWs ? [KoishiWebsocketGateway] : []),
],
exports: defaultContextContainer.contextsToProvide,
global: options.isGlobal != null ? options.isGlobal : true,
......
import { App } from 'koishi';
import { App, Router } from 'koishi';
import {
Inject,
Injectable,
......@@ -9,38 +9,40 @@ import {
import { KoishiModuleOptions } from './koishi.interfaces';
import { Server } from 'http';
import Koa from 'koa';
import KoaRouter from '@koa/router';
import KoaBodyParser from 'koa-bodyparser';
import { KoishiMetascanService } from './providers/koishi-metascan.service';
import { applySelector } from './utility/koishi.utility';
import { KOISHI_MODULE_OPTIONS } from './utility/koishi.constants';
import { KoishiLoggerService } from './providers/koishi-logger.service';
import { KoishiHttpDiscoveryService } from './koishi-http-discovery/koishi-http-discovery.service';
@Injectable()
export class KoishiService
extends App
implements OnModuleInit, OnApplicationBootstrap, OnModuleDestroy {
implements OnModuleInit, OnApplicationBootstrap, OnModuleDestroy
{
constructor(
@Inject(KOISHI_MODULE_OPTIONS)
private readonly koishiModuleOptions: KoishiModuleOptions,
private readonly metascan: KoishiMetascanService,
private readonly httpDiscovery: KoishiHttpDiscoveryService,
private readonly koishiLogger: KoishiLoggerService,
) {
super({
...koishiModuleOptions,
port: 0,
});
this.router = new KoaRouter();
this.router = new Router();
this._nestKoaTmpInstance.use(KoaBodyParser());
this._nestKoaTmpInstance.use(this.router.routes());
this._nestKoaTmpInstance.use(this.router.allowedMethods());
this._nestKoaTmpInstance.use(KoaBodyParser());
this.options.port = 1;
}
readonly _nestKoaTmpInstance = new Koa();
private async setHttpServer() {
const httpAdapter = this.metascan.getHttpAdapter();
const httpAdapter = this.httpDiscovery.getHttpAdapter();
if (!httpAdapter) {
return;
}
......
import { WsAdapter } from '@nestjs/platform-ws';
import { INestApplicationContext } from '@nestjs/common';
import * as http from 'http';
export class KoishiWsAdapter extends WsAdapter {
constructor(appOrHttpServer?: INestApplicationContext | any) {
super(appOrHttpServer);
}
override ensureHttpServerExists(
port: number,
httpServer = http.createServer(),
) {
if (this.httpServersRegistry.has(port)) {
return;
}
this.httpServersRegistry.set(port, httpServer);
httpServer.on('upgrade', (request, socket, head) => {
const baseUrl = 'ws://' + request.headers.host + '/';
const pathname = new URL(request.url, baseUrl).pathname;
const wsServersCollection = this.wsServersRegistry.get(port);
let isRequestDelegated = false;
let fallbackWsServer: any;
for (const wsServer of wsServersCollection) {
if (pathname === wsServer.path) {
wsServer.handleUpgrade(request, socket, head, (ws: unknown) => {
wsServer.emit('connection', ws, request);
});
isRequestDelegated = true;
break;
}
if (wsServer.path === '__koishi_fallback') {
fallbackWsServer = wsServer;
}
}
if (!isRequestDelegated && fallbackWsServer) {
const wsServer = fallbackWsServer;
wsServer.handleUpgrade(request, socket, head, (ws: unknown) => {
wsServer.emit('connection', ws, request);
});
isRequestDelegated = true;
}
if (!isRequestDelegated) {
socket.destroy();
}
});
return httpServer;
}
}
......@@ -40,15 +40,6 @@ export class KoishiMetascanService {
private readonly ctxService: KoishiContextService,
) {}
getHttpAdapter(): AbstractHttpAdapter {
const apdaterHost = this.moduleRef.get(HttpAdapterHost, { strict: false });
if (apdaterHost) {
return apdaterHost.httpAdapter;
} else {
return null;
}
}
private preRegisterCommandActionArg(config: CommandPutConfig, cmd: Command) {
if (!config) {
return;
......
import {
OnGatewayConnection,
OnGatewayInit,
WebSocketGateway,
WebSocketServer,
} from '@nestjs/websockets';
import { KoishiService } from '../koishi.service';
import type WebSocket from 'ws';
import type { Server } from 'ws';
import { IncomingMessage } from 'http';
@WebSocketGateway()
export class KoishiWebsocketGateway
implements OnGatewayInit, OnGatewayConnection {
constructor(private readonly koishi: KoishiService) {}
@WebSocketServer()
wsServer: Server;
afterInit(server: any): any {
// console.log('Init ws server', server, server === this.wsServer);
this.wsServer.path = '__koishi_fallback';
this.koishi._wsServer = this.wsServer;
}
handleConnection(socket: WebSocket, request: IncomingMessage) {
// console.log(socket);
for (const manager of this.koishi.router.wsStack) {
if (manager.accept(socket, request)) return;
}
socket.close();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment