Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
Koishi Nestjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
3rdeye
Koishi Nestjs
Commits
fa70be2f
Commit
fa70be2f
authored
Oct 08, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix inject and add isGlobal
parent
860b1e6e
Pipeline
#6160
passed with stages
in 1 minute and 21 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
4 deletions
+16
-4
README.md
README.md
+2
-0
package.json
package.json
+1
-1
src/koishi.interfaces.ts
src/koishi.interfaces.ts
+7
-2
src/koishi.module.ts
src/koishi.module.ts
+6
-1
No files found.
README.md
View file @
fa70be2f
...
...
@@ -83,6 +83,8 @@ Koishi-Nest 的配置项和 Koishi 配置项一致,参照 [Koishi 文档](http
*
`options`
Koishi 插件配置。等同于
`ctx.plugin(plugin, options)`
。
*
`select`
插件选择器,定义插件的作用上下文。定义参照
[
Koishi 文档
](
https://koishi.js.org/v4/guide/plugin/context.html#%E5%9C%A8%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E4%B8%AD%E4%BD%BF%E7%94%A8%E9%80%89%E6%8B%A9%E5%99%A8
)
的写法。
*
`isGlobal`
:
`boolean`
默认
`false`
。指示 Koishi-Nest 模块是否应被注册为全局模块。
**异步配置该项应写入异步配置项中。**
关于全局模块请参考
[
Nest.js 文档
](
https://docs.nestjs.cn/8/modules?id=%e5%85%a8%e5%b1%80%e6%a8%a1%e5%9d%97
)
。
插件的使用可以参考
[
Koishi 文档
](
https://koishi.js.org/v4/guide/plugin/plugin.html
)
。
## 注入 Koishi 实例
...
...
package.json
View file @
fa70be2f
{
"name"
:
"koishi-nestjs"
,
"version"
:
"1.0.3
3
"
,
"version"
:
"1.0.3
4
"
,
"description"
:
"Koishi.js as Nest.js Module"
,
"main"
:
"dist/index.js"
,
"typings"
:
"dist/index.d.ts"
,
...
...
src/koishi.interfaces.ts
View file @
fa70be2f
...
...
@@ -34,7 +34,11 @@ export function PluginDef<T extends Plugin>(
return
{
plugin
,
options
,
select
};
}
export
interface
KoishiModuleOptions
extends
App
.
Config
{
export
interface
WhetherGlobalOption
{
isGlobal
?:
boolean
;
}
export
interface
KoishiModuleOptions
extends
App
.
Config
,
WhetherGlobalOption
{
usePlugins
?:
KoishiModulePlugin
<
Plugin
>
[];
loggerPrefix
?:
string
;
}
...
...
@@ -44,7 +48,8 @@ export interface KoishiModuleOptionsFactory {
}
export
interface
KoishiModuleAsyncOptions
extends
Pick
<
ModuleMetadata
,
'
imports
'
>
{
extends
Pick
<
ModuleMetadata
,
'
imports
'
>
,
WhetherGlobalOption
{
useExisting
?:
Type
<
KoishiModuleOptionsFactory
>
;
useClass
?:
Type
<
KoishiModuleOptionsFactory
>
;
useFactory
?:
(
...
...
src/koishi.module.ts
View file @
fa70be2f
...
...
@@ -99,6 +99,7 @@ export class KoishiModule implements NestModule {
return
{
module
:
KoishiModule
,
providers
:
[{
provide
:
KOISHI_MODULE_OPTIONS
,
useValue
:
options
}],
global
:
options
.
isGlobal
,
};
}
...
...
@@ -106,7 +107,11 @@ export class KoishiModule implements NestModule {
return
{
module
:
KoishiModule
,
imports
:
options
.
imports
,
providers
:
this
.
createAsyncProviders
(
options
),
providers
:
[
...
this
.
createAsyncProviders
(
options
),
...(
options
.
extraProviders
||
[]),
],
global
:
options
.
isGlobal
,
};
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment