Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
histhub
api
Commits
0f07d656
Commit
0f07d656
authored
Nov 26, 2019
by
tobinski
Browse files
Merge branch '11-rename-api-v-1-1-to-v2'
parents
0f95769c
a653b5dd
Pipeline
#4147
passed with stages
in 2 minutes and 6 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/controller/api.ts
View file @
0f07d656
...
...
@@ -165,7 +165,7 @@ export class ApiController {
// flag to check if we already answered
let
answered
=
false
;
const
responseData
=
new
ResponseCollector
(
req
.
config
,
language
);
const
responseData
=
new
ResponseCollector
(
req
.
config
);
// if kafka is not answering give a fuck
const
kafkaTimeout
=
setTimeout
(()
=>
{
// check if we already answered
...
...
src/utils/response-collector.ts
View file @
0f07d656
import
{
InterfaceStreamAppResponse
}
from
'
../controller/api
'
;
import
UrlResolver
from
'
./url-resolver
'
;
/**
...
...
@@ -29,49 +28,23 @@ export class ResponseCollector {
*/
private
config
:
string
[];
/**
* Language oif the provider
*/
private
language
:
string
;
/**
* The config is a simple array with the names of the kafka streming apps
* @param config
* @param language
*/
constructor
(
config
:
string
[]
,
language
=
'
de
'
)
{
constructor
(
config
:
string
[])
{
this
.
config
=
config
;
this
.
language
=
language
;
}
/**
* Add a data to the final result
* @param {InterfaceStreamAppResponse} data
*/
async
add
(
data
:
InterfaceStreamAppResponse
):
Promise
<
void
>
{
add
(
data
:
InterfaceStreamAppResponse
):
void
{
// should always be the same
this
.
finalData
.
id
=
data
.
id
;
// find key and add data
console
.
log
(
'
config
'
+
this
.
config
);
console
.
log
(
'
name
'
+
data
.
name
);
if
(
this
.
config
.
indexOf
(
data
.
name
)
>
-
1
){
// check if array
if
(
Array
.
isArray
(
data
.
data
.
links
))
{
console
.
log
(
'
links
'
);
data
.
data
.
links
=
await
Promise
.
all
(
data
.
data
.
links
.
map
(
async
(
d
)
=>
{
const
a
=
{};
try
{
const
provider
=
await
UrlResolver
.
getProvider
(
d
,
this
.
language
);
a
[
provider
]
=
d
;
return
a
;
}
catch
(
error
)
{
console
.
log
(
`error getting provider`
+
error
);
a
[
'
unknown
'
]
=
d
;
return
a
;
}
}));
console
.
log
(
data
.
data
.
links
);
}
if
(
Array
.
isArray
(
this
.
finalData
.
data
[
data
.
name
]))
{
// perhaps wrong
this
.
finalData
.
data
[
data
.
name
].
push
(
data
.
data
);
...
...
@@ -114,6 +87,3 @@ export class ResponseCollector {
return
this
.
finalData
;
}
}
export
class
InterfaceResponseConfig
{
}
\ No newline at end of file
Write
Preview
Supports
Markdown
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