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
25a06f04
Commit
25a06f04
authored
Oct 08, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change logic of http adapter scan
parent
98405ccc
Pipeline
#6154
passed with stages
in 38 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
package.json
package.json
+1
-1
src/koishi-metascan.service.ts
src/koishi-metascan.service.ts
+22
-5
No files found.
package.json
View file @
25a06f04
{
"name"
:
"koishi-nestjs"
,
"version"
:
"1.0.3
0
"
,
"version"
:
"1.0.3
1
"
,
"description"
:
"Koishi.js as Nest.js Module"
,
"main"
:
"dist/index.js"
,
"typings"
:
"dist/index.d.ts"
,
...
...
src/koishi-metascan.service.ts
View file @
25a06f04
...
...
@@ -33,14 +33,30 @@ export class KoishiMetascanService {
)
{}
getHttpAdapter
():
AbstractHttpAdapter
{
const
possibleHttpAdapters
:
AbstractHttpAdapter
[]
=
[];
for
(
const
module
of
this
.
moduleContainer
.
values
())
{
const
adapterHost
=
module
.
providers
.
get
(
HttpAdapterHost
);
if
(
adapterHost
)
{
return
(
adapterHost
as
InstanceWrapper
<
HttpAdapterHost
>
).
instance
.
httpAdapter
;
const
httpAdapter
=
(
adapterHost
as
InstanceWrapper
<
HttpAdapterHost
>
)
.
instance
.
httpAdapter
;
possibleHttpAdapters
.
push
(
httpAdapter
);
}
}
return
null
;
if
(
!
possibleHttpAdapters
.
length
)
{
return
null
;
}
// Try those adapters one by one
const
adapterTypesToTry
=
[
'
express
'
,
'
fastify
'
,
'
koa
'
];
for
(
const
adapterType
of
adapterTypesToTry
)
{
const
foundAdapter
=
possibleHttpAdapters
.
find
(
(
adapter
)
=>
adapter
.
getType
()
===
adapterType
,
);
if
(
foundAdapter
)
{
return
foundAdapter
;
}
}
// Fallback to first adapter
return
possibleHttpAdapters
[
0
];
}
private
async
handleInstance
(
...
...
@@ -83,8 +99,9 @@ export class KoishiMetascanService {
);
break
;
case
'
onevent
'
:
const
{
data
:
eventData
}
=
regData
as
DoRegisterConfig
<
EventNameAndPrepend
>
;
const
{
data
:
eventData
,
}
=
regData
as
DoRegisterConfig
<
EventNameAndPrepend
>
;
baseContext
.
on
(
eventData
.
name
,
(...
args
:
any
[])
=>
methodFun
.
call
(
instance
,
...
args
),
);
...
...
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