Creation of Catalog

#1

Hi all,

I have developed one repository for nodes, For that, I also wanted to allow the user to install via palette manager in Node-RED. To Do so I followed below link to add catalog.

But I do not have any Idea about one point mensioned in this:
"Another use case is to provide a catalogue of nodes from an alternative npm repository. In that instance, the catalogue must also provide sufficient information to allow the runtime to target that repo when running the npm install. The runtime api will need to be updated to support this case."

How to create runtime api?
What all information I need to provide?
What will be the format of Req/Res?

Thanks

0 Likes

#2

Hi @Devbrat

none of the work under the "Further Considerations" section you link to has been done as it is not needed.

You can configure npm to use different repositories for different module scopes via its .npmrc file - that way Node-RED doesn't need to know about them, it can just run npm install as normal and npm figures out what to do.

Here are the docs for configuring npm - https://docs.npmjs.com/misc/scope#associating-a-scope-with-a-registry

0 Likes

#3

I that case I did all the config for catalog but the nodes are not showing up in palette manager.
settings.js:

{
        editable: true, // Enable/disable the Palette Manager
        catalogues: [   // Alternative palette manager catalogues
            'https://catalogue.nodered.org/catalogue.json',
			'http://localhost:5500/api/files/catalogue.json'
        ],
        theme: [ // Override node colours - rules test against category/type by RegExp.
            { category: ".*", type: ".*", color: "#f0f" }
        ]
    }

and catalogue.json:

{
    "name": "My-Node-RED Catalogue",
    "updated_at": "2019-04-01T8:37:50.673Z",
    "modules": [
        {
            "description": "Node Desc",
            "keywords": [
                "node-red"
            ],
            "types": [
                "node-type",
            ],
            "updated_at": "2019-04-01T05:31:43.820Z",
            "id": "@myco/node-red-node-name1",
            "version": "0.2.0",
            "url": "http://my-repositry.com:4876/"
        },
		{
            "description": "Node Desc",
            "keywords": [
                "node-red"
            ],
            "types": [
                "node-type"
            ],
            "updated_at": "2019-04-01T05:31:43.820Z",
            "id": "@myco/node-red-node-name2",
            "version": "1.1.3",
            "url": "http://my-repositry.com:4876/"
        }
    ]
}
0 Likes

#4

Have you checked the browser console for any errors?

There are two issues:

  1. The catalog you've shown isn't valid JSON - there is an extra , on line 11.

  2. You're probably hitting a CORS error. Something like:

Access to XMLHttpRequest at 'http://localhost:5500/api/files/catalogue.json?_=1554367286896' from origin 'http://localhost:1880' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

In order to load the catalog, the server hosting it must set the Access-Control-Allow-Origin to allow the browser to load it.

0 Likes

#5

1st issue I fixed and 2nd I have already added CORS allow in server side.
And also I am not getting any error in console.
As I observed request itself not going to load this "http://localhost:5500/api/files/catalogue.json".

0 Likes

#6

Can any one help on this?

0 Likes

#7

Do you mean you don't see the request being made to the URL at all?

If properly configured, the requests will be sent when you open the palette manager.

Have you verified you have edited the right settings file? Node-RED logs the settings file it's using when it starts up.

0 Likes

#8

Yeah, Its not going. I have all the necessary changes..

0 Likes

#9

Open the JavaScript console in your browser and tell me what RED.settings.editorTheme.palette.catalogues returns.

0 Likes

#10

0 Likes

#11

That tells me you have not edited your settings file, or you have edited the wrong file.

Which file did you edit? What drugs file dues node-red log when it starts up?

0 Likes

#12

Pretty sure that last sentence should be:

What settings file does Node-RED log when it starts up

4 Likes

#13

Please see the below screenshots

0 Likes

#15

@knolleary Is this correct or wrong?

0 Likes

#16

What does RED.settings.editorTheme return when you run it in the developer console of the browser with the Editor open in it?

I see you have set a custom node color scheme - is that working as you expect?

0 Likes

#17

p5

"I see you have set a custom node color scheme - is that working as you expect?": No

0 Likes

#18

Then you have definitely got something wrong with how you are trying to configure it.

I see you have a custom deployButton set - so you must have editorTheme set properly somewhere.

Can you share the complete editorTheme property you have in your settings file? A screenshot is not helpful - please copy and paste the text.

0 Likes

#19

I removed that, but then also its not working.

/**
 * Copyright JS Foundation and other contributors, http://js.foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/

// The `https` setting requires the `fs` module. Uncomment the following
// to make it available:
//var fs = require("fs");

module.exports = {
    // the tcp port that the Node-RED web server is listening on
    uiPort: process.env.PORT || 1880,

    // By default, the Node-RED UI accepts connections on all IPv4 interfaces.
    // To listen on all IPv6 addresses, set uiHost to "::",
    // The following property can be used to listen on a specific interface. For
    // example, the following would only allow connections from the local machine.
    //uiHost: "127.0.0.1",

    // Retry time in milliseconds for MQTT connections
    mqttReconnectTime: 15000,

    // Retry time in milliseconds for Serial port connections
    serialReconnectTime: 15000,

    // Retry time in milliseconds for TCP socket connections
    //socketReconnectTime: 10000,

    // Timeout in milliseconds for TCP server socket connections
    //  defaults to no timeout
    //socketTimeout: 120000,

    // Maximum number of messages to wait in queue while attempting to connect to TCP socket
    //  defaults to 1000
    //tcpMsgQueueSize: 2000,

    // Timeout in milliseconds for HTTP request connections
    //  defaults to 120 seconds
    //httpRequestTimeout: 120000,

    // The maximum length, in characters, of any message sent to the debug sidebar tab
    debugMaxLength: 1000,

    // The maximum number of messages nodes will buffer internally as part of their
    // operation. This applies across a range of nodes that operate on message sequences.
    //  defaults to no limit. A value of 0 also means no limit is applied.
    //nodeMaxMessageBufferLength: 0,

    // To disable the option for using local files for storing keys and certificates in the TLS configuration
    //  node, set this to true
    //tlsConfigDisableLocalFiles: true,

    // Colourise the console output of the debug node
    //debugUseColors: true,

    // The file containing the flows. If not set, it defaults to flows_<hostname>.json
    //flowFile: 'flows.json',

    // To enabled pretty-printing of the flow within the flow file, set the following
    //  property to true:
    //flowFilePretty: true,

    // By default, credentials are encrypted in storage using a generated key. To
    // specify your own secret, set the following property.
    // If you want to disable encryption of credentials, set this property to false.
    // Note: once you set this property, do not change it - doing so will prevent
    // node-red from being able to decrypt your existing credentials and they will be
    // lost.
    //credentialSecret: "a-secret-key",

    // By default, all user data is stored in the Node-RED install directory. To
    // use a different location, the following property can be used
    //userDir: '/home/nol/.node-red/',

    // Node-RED scans the `nodes` directory in the install directory to find nodes.
    // The following property can be used to specify an additional directory to scan.
    //nodesDir: '/home/nol/.node-red/nodes',

    // By default, the Node-RED UI is available at http://localhost:1880/
    // The following property can be used to specify a different root path.
    // If set to false, this is disabled.
    //httpAdminRoot: '/admin',

    // Some nodes, such as HTTP In, can be used to listen for incoming http requests.
    // By default, these are served relative to '/'. The following property
    // can be used to specifiy a different root path. If set to false, this is
    // disabled.
    //httpNodeRoot: '/red-nodes',

    // The following property can be used in place of 'httpAdminRoot' and 'httpNodeRoot',
    // to apply the same root to both parts.
    //httpRoot: '/red',

    // When httpAdminRoot is used to move the UI to a different root path, the
    // following property can be used to identify a directory of static content
    // that should be served at http://localhost:1880/.
    httpStatic: 'node-red-static/',

    // The maximum size of HTTP request that will be accepted by the runtime api.
    // Default: 5mb
    //apiMaxLength: '5mb',

    // If you installed the optional node-red-dashboard you can set it's path
    // relative to httpRoot
    //ui: { path: "ui" },

    // Securing Node-RED
    // -----------------
    // To password protect the Node-RED editor and admin API, the following
    // property can be used. See http://nodered.org/docs/security.html for details.
    //adminAuth: {
    //    type: "credentials",
    //    users: [{
    //        username: "admin",
    //        password: "$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN.",
    //        permissions: "*"
    //    }]
    //},

    // To password protect the node-defined HTTP endpoints (httpNodeRoot), or
    // the static content (httpStatic), the following properties can be used.
    // The pass field is a bcrypt hash of the password.
    // See http://nodered.org/docs/security.html#generating-the-password-hash
    //httpNodeAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},
    //httpStaticAuth: {user:"user",pass:"$2a$08$zZWtXTja0fB1pzD4sHCMyOCMYz2Z6dNbM6tl8sJogENOMcxWV9DN."},

    // The following property can be used to enable HTTPS
    // See http://nodejs.org/api/https.html#https_https_createserver_options_requestlistener
    // for details on its contents.
    // See the comment at the top of this file on how to load the `fs` module used by
    // this setting.
    //
    //https: {
    //    key: fs.readFileSync('privatekey.pem'),
    //    cert: fs.readFileSync('certificate.pem')
    //},

    // The following property can be used to cause insecure HTTP connections to
    // be redirected to HTTPS.
    //requireHttps: true,

    // The following property can be used to disable the editor. The admin API
    // is not affected by this option. To disable both the editor and the admin
    // API, use either the httpRoot or httpAdminRoot properties
    //disableEditor: false,

    // The following property can be used to configure cross-origin resource sharing
    // in the HTTP nodes.
    // See https://github.com/troygoode/node-cors#configuration-options for
    // details on its contents. The following is a basic permissive set of options:
    //httpNodeCors: {
    //    origin: "*",
    //    methods: "GET,PUT,POST,DELETE"
    //},

    // If you need to set an http proxy please set an environment variable
    // called http_proxy (or HTTP_PROXY) outside of Node-RED in the operating system.
    // For example - http_proxy=http://myproxy.com:8080
    // (Setting it here will have no effect)
    // You may also specify no_proxy (or NO_PROXY) to supply a comma separated
    // list of domains to not proxy, eg - no_proxy=.acme.co,.acme.co.uk

    // The following property can be used to add a custom middleware function
    // in front of all http in nodes. This allows custom authentication to be
    // applied to all http in nodes, or any other sort of common request processing.
    //httpNodeMiddleware: function(req,res,next) {
    //    // Handle/reject the request, or pass it on to the http in node by calling next();
    //    // Optionally skip our rawBodyParser by setting this to true;
    //    //req.skipRawBodyParser = true;
    //    next();
    //},

    // The following property can be used to verify websocket connection attempts.
    // This allows, for example, the HTTP request headers to be checked to ensure
    // they include valid authentication information.
    //webSocketNodeVerifyClient: function(info) {
    //    // 'info' has three properties:
    //    //   - origin : the value in the Origin header
    //    //   - req : the HTTP request
    //    //   - secure : true if req.connection.authorized or req.connection.encrypted is set
    //    //
    //    // The function should return true if the connection should be accepted, false otherwise.
    //    //
    //    // Alternatively, if this function is defined to accept a second argument, callback,
    //    // it can be used to verify the client asynchronously.
    //    // The callback takes three arguments:
    //    //   - result : boolean, whether to accept the connection or not
    //    //   - code : if result is false, the HTTP error status to return
    //    //   - reason: if result is false, the HTTP reason string to return
    //},

    // Anything in this hash is globally available to all functions.
    // It is accessed as context.global.
    // eg:
    //    functionGlobalContext: { os:require('os') }
    // can be accessed in a function block as:
    //    context.global.os

    functionGlobalContext: {
        // os:require('os'),
        // jfive:require("johnny-five"),
        // j5board:require("johnny-five").Board({repl:false})
    },

    // Context Storage
    // The following property can be used to enable context storage. The configuration
    // provided here will enable file-based context that flushes to disk every 30 seconds.
    // Refer to the documentation for further options: https://nodered.org/docs/api/context/
    //
    //contextStorage: {
    //    default: {
    //        module:"localfilesystem"
    //    },
    //},

    // The following property can be used to order the categories in the editor
    // palette. If a node's category is not in the list, the category will get
    // added to the end of the palette.
    // If not set, the following default order is used:
    // paletteCategories: ['subflows', 'input', 'output', 'function', 'social', 'mobile', 'storage', 'analysis', 'advanced'],
	palette: {
        editable: true, // Enable/disable the Palette Manager
        catalogues: [   // Alternative palette manager catalogues
			'http://localhost:5500/api/files/catalogue.json'
        ],
        theme: [ // Override node colours - rules test against category/type by RegExp.
            { category: ".*", type: ".*", color: "#f0f" }
        ]
    },

    // Configure the logging output
    logging: {
        // Only console logging is currently supported
        console: {
            // Level of logging to be recorded. Options are:
            // fatal - only those errors which make the application unusable should be recorded
            // error - record errors which are deemed fatal for a particular request + fatal errors
            // warn - record problems which are non fatal + errors + fatal errors
            // info - record information about the general running of the application + warn + error + fatal errors
            // debug - record information which is more verbose than info + info + warn + error + fatal errors
            // trace - record very detailed logging + debug + info + warn + error + fatal errors
            // off - turn off all logging (doesn't affect metrics or audit)
            level: "info",
            // Whether or not to include metric events in the log output
            metrics: false,
            // Whether or not to include audit events in the log output
            audit: false
        }
    },

    // Customising the editor
editorTheme :{
	"projects": {
		"enabled": false
	}
}
}













0 Likes

#20

Your palette setting is not inside the editorTheme block.

0 Likes

#21

Thanks, After adding in editorTheme packages are coming now. Will try to install tomorrow. And let you know.

0 Likes