File tree Expand file tree Collapse file tree 4 files changed +24
-17
lines changed Expand file tree Collapse file tree 4 files changed +24
-17
lines changed Original file line number Diff line number Diff line change 2
2
import { Readable , Transform } from 'stream'
3
3
import getContent from './get-content'
4
4
5
+ function isStream ( models ) {
6
+ return (
7
+ models ?. length > 0 &&
8
+ ( models [ 0 ] instanceof Readable || models [ 0 ] instanceof Transform )
9
+ )
10
+ }
11
+
5
12
/**
6
13
*
7
14
* @param {import("../use-cases/list-models").listModels } listModels
@@ -17,13 +24,7 @@ export default function getModelsFactory (listModels) {
17
24
writable : httpRequest . res
18
25
} )
19
26
20
- if (
21
- models ?. length > 0 &&
22
- ( models [ 0 ] instanceof Readable || models [ 0 ] instanceof Transform )
23
- ) {
24
- httpRequest . stream = true
25
- return
26
- }
27
+ if ( isStream ( ) ) return
27
28
28
29
const { content, contentType } = getContent ( httpRequest , models )
29
30
Original file line number Diff line number Diff line change 16
16
/**
17
17
* @param {httpController } controller
18
18
*/
19
- export default function buildCallback ( controller ) {
19
+ export default function buildCallback ( controller ) {
20
20
/**
21
21
*/
22
22
return async ( req , res ) => {
@@ -29,7 +29,7 @@ export default function buildCallback(controller) {
29
29
path : req . path ,
30
30
res : res ,
31
31
headers : req . headers ,
32
- log ( func ) {
32
+ log ( func ) {
33
33
console . info ( {
34
34
function : func ,
35
35
ip : httpRequest . ip ,
@@ -44,7 +44,6 @@ export default function buildCallback(controller) {
44
44
45
45
return controller ( httpRequest )
46
46
. then ( httpResponse => {
47
- if ( httpRequest . stream ) return
48
47
if ( httpResponse . headers ) {
49
48
res . set ( httpResponse . headers )
50
49
}
@@ -55,4 +54,4 @@ export default function buildCallback(controller) {
55
54
res . status ( 500 ) . send ( { error : 'An unkown error occurred.' , e } )
56
55
)
57
56
}
58
- }
57
+ }
Original file line number Diff line number Diff line change @@ -171,10 +171,10 @@ const DsCoreExtensions = superclass =>
171
171
*/
172
172
async list ( options ) {
173
173
try {
174
- if ( options ?. query . __count ) return this . count ( )
175
- if ( options ?. query . __cached ) return this . listSync ( options . query )
174
+ if ( options ?. query ? .__count ) return this . count ( )
175
+ if ( options ?. query ? .__cached ) return this . listSync ( options . query )
176
176
177
- const opts = { ...options , streamRequested : options . writable }
177
+ const opts = { ...options , streamRequested : options ? .writable }
178
178
const list = [ await super . list ( opts ) ] . flat ( )
179
179
180
180
if ( list . length < 1 ) return [ ]
Original file line number Diff line number Diff line change @@ -25,20 +25,27 @@ export default function listConfigsFactory ({
25
25
const poolName =
26
26
typeof query . poolName === 'string' ? query . poolName . toUpperCase ( ) : null
27
27
28
+ const domain = models . getModelSpec ( modelName ) ?. domain
29
+
28
30
const configTypes = {
29
31
data : async ( ) =>
30
32
modelName && isMainThread
31
33
? threadpools
32
34
. getThreadPool ( modelName )
33
35
. runJob ( listConfigs . name , query , modelName )
34
36
: modelName && poolName
35
- ? await datasources . getSharedDataSource ( poolName ) . list ( )
37
+ ? await datasources . getSharedDataSource ( poolName , domain ) . list ( )
36
38
: modelName
37
- ? await datasources . getSharedDataSource ( modelName ) . list ( )
39
+ ? await datasources . getSharedDataSource ( modelName , domain ) . list ( )
38
40
: await Promise . all (
39
41
datasources . listDataSources ( ) . map ( async dsName => ( {
40
42
dsName,
41
- ...( await datasources . getSharedDataSource ( dsName ) . count ( ) )
43
+ ...( await datasources
44
+ . getSharedDataSource (
45
+ dsName ,
46
+ models . getModelSpec ( modelName ) ?. domain
47
+ )
48
+ . count ( ) )
42
49
} ) )
43
50
) ,
44
51
You can’t perform that action at this time.
0 commit comments