npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-red-contrib-url-routing

v1.0.4

Published

A Node-RED custom node for routing HTTP requests based on conditions.

Downloads

15

Readme

Node-RED Routing Node

GitHub

Overview

The Node-RED Routing URL Node allows you to define multiple conditions for routing messages based on HTTP request methods and URL paths. This node helps you manage complex routing logic with ease by supporting dynamic reordering of conditions and validation of inputs.

Features

  • Supports HTTP methods: GET, POST, PUT, DELETE, PATCH
  • Allows multiple conditions to be added and configured
  • Conditions can be reordered via drag-and-drop
  • Validates condition paths to ensure no empty conditions are saved

Installation

To install the node, navigate to your Node-RED user directory (typically ~/.node-red) and run:

npm install node-red-contrib-url-routing

Example Flow

This example demonstrates how to use the Routing Node to handle different HTTP GET requests and route them to different outputs based on the request path.

Flow JSON

[
    {
        "id": "1",
        "type": "http in",
        "z": "3e6acde817e88f81",
        "name": "",
        "url": "/api/*",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 500,
        "y": 700,
        "wires": [
            [
                "2"
            ]
        ]
    },
    {
        "id": "2",
        "type": "routing",
        "z": "3e6acde817e88f81",
        "name": "Route API Requests",
        "outputs": 4,
        "conditions": [
            {
                "path": "/api/",
                "method": "GET"
            },
            {
                "path": "/api/courses",
                "method": "GET"
            },
            {
                "path": "/api/courses/:id",
                "method": "GET"
            },
            {
                "path": "/api/*",
                "method": "GET"
            }
        ],
        "x": 720,
        "y": 700,
        "wires": [
            [
                "8f9f24f73b7cbf35"
            ],
            [
                "9e62412792545305"
            ],
            [
                "dcfee9a547f90414"
            ],
            [
                "da197d5e7999fb0f"
            ]
        ]
    },
    {
        "id": "8f9f24f73b7cbf35",
        "type": "template",
        "z": "3e6acde817e88f81",
        "name": "root response",
        "field": "payload",
        "fieldType": "msg",
        "format": "json",
        "syntax": "mustache",
        "template": "{\n    \"path\": \"root\"\n}",
        "output": "str",
        "x": 980,
        "y": 600,
        "wires": [
            [
                "4ed8662d40737792"
            ]
        ]
    },
    {
        "id": "9e62412792545305",
        "type": "template",
        "z": "3e6acde817e88f81",
        "name": "courses response",
        "field": "payload",
        "fieldType": "msg",
        "format": "json",
        "syntax": "mustache",
        "template": "{\n    \"path\": \"/api/courses\"\n}",
        "output": "str",
        "x": 990,
        "y": 660,
        "wires": [
            [
                "4ed8662d40737792"
            ]
        ]
    },
    {
        "id": "dcfee9a547f90414",
        "type": "template",
        "z": "3e6acde817e88f81",
        "name": "courses id response",
        "field": "payload",
        "fieldType": "msg",
        "format": "json",
        "syntax": "mustache",
        "template": "{\n    \"path\": \"/courses/:id\"\n}",
        "output": "str",
        "x": 1000,
        "y": 720,
        "wires": [
            [
                "4ed8662d40737792"
            ]
        ]
    },
    {
        "id": "4ed8662d40737792",
        "type": "http response",
        "z": "3e6acde817e88f81",
        "name": "response",
        "statusCode": "200",
        "headers": {
            "Content-Type": "applications/json"
        },
        "x": 1260,
        "y": 680,
        "wires": []
    },
    {
        "id": "da197d5e7999fb0f",
        "type": "template",
        "z": "3e6acde817e88f81",
        "name": "wildcard response",
        "field": "payload",
        "fieldType": "msg",
        "format": "json",
        "syntax": "mustache",
        "template": "{\n    \"path\": \"/*\"\n}",
        "output": "str",
        "x": 990,
        "y": 780,
        "wires": [
            [
                "4ed8662d40737792"
            ]
        ]
    }
]

Github

You can find the source code and contribute to the project on GitHub: GitHub Repository

License

This project is licensed under the MIT License. See the LICENSE file for details.