Skip to content

Commit

Permalink
Fix for new search API
Browse files Browse the repository at this point in the history
  • Loading branch information
hardillb committed Sep 29, 2023
1 parent 70c67b0 commit 08ca40d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:12-alpine
FROM node:18-alpine

WORKDIR /usr/src/app
COPY package*.json ./
Expand Down
17 changes: 9 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const listenHost = (process.env.HOST || '0.0.0.0')
const registryHost = (process.env.REGISTRY || 'http:https://registry:4873')
const keyword = (process.env.KEYWORD || "node-red")

const url = registryHost + "/-/all"
// const url = registryHost + "/-/all"
const url = registryHost + "/-/v1/search"

const catalogue = {
"name":"Ben's custom catalogue",
Expand Down Expand Up @@ -42,20 +43,20 @@ function update() {
superagent.get(url)
.end(async (err, res) => {
if (!err) {
const nodes = res.body;
const nodes = res.body.objects;
var nodeNames = Object.keys(nodes);
const index = nodeNames.indexOf("_updated");
if (index > -1) {
nodeNames.splice(index, 1);
}

for (const node in nodeNames) {
var n = nodes[nodeNames[node]];
// var n = nodes[nodeNames[node]];
if (node === undefined) {
continue;
}
var n = nodes[node].package;
if (n.keywords) {
if (n.keywords.indexOf(keyword) != -1) {
try {
let details = await superagent
.get("http:https://" + registryHost + "/" + nodeNames[node])
.get(registryHost + "/" + n.name)
.set('accept', 'json')
let latest = details.body['dist-tags'].latest
let version = details.body.versions[latest]
Expand Down

0 comments on commit 08ca40d

Please sign in to comment.