Skip to content

Commit 0e57c00

Browse files
Merge pull request #1429 from opencomponents/add-meta
add meta query for components
2 parents 6ecde5c + 93c14d2 commit 0e57c00

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/registry/routes/index.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export default function (repository: Repository) {
106106
);
107107
} else {
108108
const state = req.query['state'] || '';
109+
const meta = req.query['meta'] === 'true' && res.conf.discovery.ui;
109110
let list = componentResults;
110111
if (!res.conf.discovery.experimental) {
111112
list = list.filter(
@@ -118,9 +119,20 @@ export default function (repository: Repository) {
118119

119120
res.status(200).json(
120121
Object.assign(baseResponse, {
121-
components: list.map((component) =>
122-
urlBuilder.component(component.name, res.conf.baseUrl)
123-
)
122+
components: list.map((component) => {
123+
const href = urlBuilder.component(component.name, res.conf.baseUrl);
124+
125+
return meta
126+
? {
127+
href,
128+
name: component.name,
129+
version: component.version,
130+
description: component.description,
131+
state: component.oc.state,
132+
publishDate: new Date(component.oc.date).toISOString()
133+
}
134+
: href;
135+
})
124136
})
125137
);
126138
}

0 commit comments

Comments
 (0)