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
c3799f8c
Commit
c3799f8c
authored
Nov 12, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small fix of service inject
parent
02a7d509
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
15 deletions
+16
-15
src/providers/koishi-metascan.service.ts
src/providers/koishi-metascan.service.ts
+12
-13
src/utility/koishi.decorators.ts
src/utility/koishi.decorators.ts
+4
-2
No files found.
src/providers/koishi-metascan.service.ts
View file @
c3799f8c
...
...
@@ -217,19 +217,18 @@ export class KoishiMetascanService {
ctx
:
Context
,
instance
:
any
,
property
:
string
,
name
:
string
,
name
:
keyof
Context
.
Services
,
)
{
const
preObject
=
ctx
[
name
];
if
(
preObject
)
{
instance
[
property
]
=
preObject
;
}
ctx
.
on
(
<
EventName
>
`service/
${
name
}
`
,
()
=>
{
instance
[
property
]
=
ctx
[
name
];
Object
.
defineProperty
(
instance
,
property
,
{
enumerable
:
true
,
configurable
:
true
,
get
()
{
return
ctx
[
name
];
},
true
,
);
set
(
val
:
any
)
{
ctx
[
name
]
=
val
;
},
});
}
private
scanInstanceForProvidingContextService
(
ctx
:
Context
,
instance
:
any
)
{
...
...
@@ -252,7 +251,7 @@ export class KoishiMetascanService {
return
;
}
for
(
const
property
of
properties
)
{
const
serviceName
=
Reflect
.
getMetadata
(
const
serviceName
:
keyof
Context
.
Services
=
Reflect
.
getMetadata
(
KoishiServiceWireProperty
,
instanceClass
,
property
,
...
...
@@ -281,7 +280,6 @@ export class KoishiMetascanService {
instance
.
constructor
,
);
this
.
scanInstanceForWireContextService
(
providerCtx
,
instance
);
this
.
scanInstanceForProvidingContextService
(
providerCtx
,
instance
);
}
}
}
...
...
@@ -300,6 +298,7 @@ export class KoishiMetascanService {
moduleCtx
,
instance
.
constructor
,
);
this
.
scanInstanceForProvidingContextService
(
providerCtx
,
instance
);
return
this
.
metadataScanner
.
scanFromPrototype
(
instance
,
prototype
,
...
...
src/utility/koishi.decorators.ts
View file @
c3799f8c
...
...
@@ -54,7 +54,7 @@ export const InjectContextUser = (...values: string[]) =>
export
function
TransformMetadata
<
K
extends
MetadataKey
,
VM
extends
Partial
<
MetadataGenericMap
>
=
MetadataGenericMap
,
VM
extends
Partial
<
MetadataGenericMap
>
=
MetadataGenericMap
>
(
metadataKey
:
K
,
metadataValueFun
:
(
oldValue
:
VM
[
K
])
=>
VM
[
K
],
...
...
@@ -253,7 +253,9 @@ export const PutBot = () => PutSession('bot');
// Service
export
function
WireContextService
(
name
?:
string
):
PropertyDecorator
{
export
function
WireContextService
(
name
?:
keyof
Context
.
Services
,
):
PropertyDecorator
{
return
(
obj
,
key
)
=>
{
const
objClass
=
obj
.
constructor
;
const
properties
:
string
[]
=
...
...
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