Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow upstream registry to be on HTTPS #1

Merged
merged 11 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules/
temp/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The container takes the following Environment variables:

- PORT - Which port to listen on (defaults to `3000`)
- HOST - Which local IP Address to bind to (defaults to `0.0.0.0`)
- REGISTRY - A host and optional port number to connect to the NPM registry (defaults to `registry:4873`)
- REGISTRY - A host and optional port number to connect to the NPM registry (defaults to `http:https://registry:4873`)
- KEYWORD - The npm keyword to filter on (defaults to `node-red`)

It presents 2 HTTP endpoints
Expand Down Expand Up @@ -68,4 +68,4 @@ $ docker push private.example.com/catalogue
env:
- name: REGISTRY
value: 'registry:4873'
```
```
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const nodeRedModule = require('node-red-module-parser')

const port = (process.env.PORT || 80)
const listenHost = (process.env.HOST || '0.0.0.0')
const registryHost = (process.env.REGISTRY || 'registry:4873')
const registryHost = (process.env.REGISTRY || 'http:https://registry:4873')
const keyword = (process.env.KEYWORD || "node-red")

const url = "http:https://" + registryHost + "/-/all"
const url = registryHost + "/-/all"

const catalogue = {
"name":"Ben's custom catalogue",
Expand Down Expand Up @@ -60,12 +60,13 @@ function update() {
let latest = details.body['dist-tags'].latest
let version = details.body.versions[latest]
let tar = version.dist.tarball
fs.mkdirSync(path.dirname(path.join("temp", nodeNames[node])))
let tarPath = path.join('temp', nodeNames[node] + ".tgz")
let tarDir = path.join("temp", nodeNames[node])
fs.mkdirSync(tarDir,{recursive: true})
let tarPath = path.join(tarDir, nodeNames[node].split('/').slice(-1) + ".tgz")
let tarRes = await superagent.get(tar).responseType('blob')
fs.writeFileSync(tarPath, tarRes.body)
let moduleDetails = nodeRedModule.examinTar(tarPath, "temp")
fs.rmSync(tarPath)
let moduleDetails = nodeRedModule.examinTar(tarPath, tarDir)
fs.rmSync(tarDir, {force: true, recursive: true})

var entry = {
id: n.name,
Expand All @@ -76,7 +77,7 @@ function update() {
url: "http:https://" + registryHost + "/-/web/details/" + n.name
}

if (moduleDetails.types) {
if (moduleDetails.types.length) {
entry.types = moduleDetails.types
}
if (moduleDetails["node-red"]) {
Expand Down
Loading