Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
ui-middleware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
OX App Suite
Core
ui-middleware
Commits
0131ccb5
Commit
0131ccb5
authored
2 years ago
by
richard.petersen
Browse files
Options
Downloads
Patches
Plain Diff
fixed: OXUIB-1621 /meta does not work with disabled redis
parent
18f0711f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
spec/meta_test.js
+33
-0
33 additions, 0 deletions
spec/meta_test.js
src/cache.js
+6
-0
6 additions, 0 deletions
src/cache.js
src/meta.js
+3
-3
3 additions, 3 deletions
src/meta.js
with
42 additions
and
3 deletions
spec/meta_test.js
+
33
−
0
View file @
0131ccb5
...
...
@@ -73,6 +73,7 @@ describe('Responses contain custom headers', function () {
})
it
(
'
does not have metadata from ui service when unavailable
'
,
async
function
()
{
await
import
(
'
../src/cache.js
'
).
then
(({
clear
})
=>
clear
())
const
response
=
await
request
(
app
).
get
(
'
/meta
'
)
expect
(
response
.
statusCode
).
to
.
equal
(
200
)
expect
(
response
.
body
).
to
.
not
.
deep
.
contain
({
...
...
@@ -81,4 +82,36 @@ describe('Responses contain custom headers', function () {
})
})
})
describe
(
'
without redis disabled
'
,
function
()
{
let
prevConfig
beforeEach
(
async
function
()
{
td
.
reset
()
mockConfig
({
urls
:
[
'
http://ui-server/
'
]
})
mockFetch
(
fetchConfig
=
{
'
http://ui-server
'
:
{
'
/manifest.json
'
:
generateSimpleViteManifest
({
'
example.js
'
:
{}
}),
'
/example.js
'
:
()
=>
new
Response
(
'
this is example
'
,
{
headers
:
{
'
content-type
'
:
'
application/javascript
'
}
}),
'
/meta.json
'
:
{
name
:
'
sample-service
'
,
version
:
'
1.0
'
}
}
})
app
=
await
mockApp
()
})
afterEach
(
function
()
{
fetchConfig
[
'
http://ui-server
'
]
=
prevConfig
})
it
(
'
has metadata
'
,
async
function
()
{
const
response
=
await
request
(
app
).
get
(
'
/meta
'
)
expect
(
response
.
statusCode
).
to
.
equal
(
200
)
expect
(
response
.
body
).
to
.
deep
.
contain
({
name
:
'
sample-service
'
,
version
:
'
1.0
'
})
})
})
})
This diff is collapsed.
Click to expand it.
src/cache.js
+
6
−
0
View file @
0131ccb5
...
...
@@ -14,6 +14,12 @@ export async function getBuffer (key) {
return
get
(
key
,
{
method
:
'
getBuffer
'
})
}
export
async
function
clear
()
{
for
(
const
prop
of
Object
.
getOwnPropertyNames
(
cache
))
{
delete
cache
[
prop
]
}
}
export
async
function
get
(
key
,
{
method
=
'
get
'
}
=
{})
{
if
(
cache
[
key
])
return
cache
[
key
]
...
...
This diff is collapsed.
Click to expand it.
src/meta.js
+
3
−
3
View file @
0131ccb5
import
{
config
}
from
'
./config.js
'
import
fetch
from
'
node-fetch
'
import
{
client
}
from
'
./
redis
.js
'
import
*
as
cache
from
'
./
cache
.js
'
import
{
getRedisKey
}
from
'
./util.js
'
export
async
function
getMergedMetadata
({
version
})
{
const
metadata
=
await
c
lient
.
get
(
getRedisKey
({
version
,
name
:
'
mergedMetadata
'
}))
const
metadata
=
await
c
ache
.
get
(
getRedisKey
({
version
,
name
:
'
mergedMetadata
'
}))
if
(
metadata
)
return
JSON
.
parse
(
metadata
)
await
config
.
load
()
...
...
@@ -29,6 +29,6 @@ export async function getMergedMetadata ({ version }) {
// only return when contains data
const
filtered
=
newMetadata
.
filter
(
Boolean
)
await
c
lient
.
set
(
getRedisKey
({
version
,
name
:
'
mergedMetadata
'
}),
JSON
.
stringify
(
filtered
))
await
c
ache
.
set
(
getRedisKey
({
version
,
name
:
'
mergedMetadata
'
}),
JSON
.
stringify
(
filtered
))
return
filtered
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment