Gathering detailed insights and metrics for @bg-dev/node-red-unstorage
Gathering detailed insights and metrics for @bg-dev/node-red-unstorage
Gathering detailed insights and metrics for @bg-dev/node-red-unstorage
Gathering detailed insights and metrics for @bg-dev/node-red-unstorage
npm install @bg-dev/node-red-unstorage
Typescript
Module System
Node Version
NPM Version
61.6
Supply Chain
95.8
Quality
74.5
Maintenance
100
Vulnerability
100
License
TypeScript (95.87%)
Dockerfile (4.13%)
Total Downloads
641
Last Day
1
Last Week
1
Last Month
12
Last Year
219
72 Commits
1 Watching
6 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
0.1.7
Package Id
@bg-dev/node-red-unstorage@0.1.7
Unpacked Size
22.20 kB
Size
4.23 kB
File Count
13
NPM Version
9.5.1
Node Version
18.16.0
Publised On
24 May 2023
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-75%
1
Compared to previous week
Last month
33.3%
12
Compared to previous month
Last year
-48.1%
219
Compared to previous year
1
4
Node-RED is a programming tool for wiring together hardware devices, APIs and online services via a browser-based editor.
Unstorage is a universal key-value storage library. It supports multiple storage platform: filesystem, database, localStorage and more.
This package is a Node-RED storage plugin that enables the integration with unstorage
. It implements a storageModule
for storing flows, settings, sessions and library content. Plus a contextStorage
for storing context data. Ultimately, the goal is to create a platform agnostic storage layer for Node RED.
Make sure to install the dependency:
1npm i @bg-dev/node-red-unstorage
Below, a Node-Red instance is embedded in a node.js application. Mongo DB is used for storage layer.
1// Supports ESM and CJS 2import storage from "@bg-dev/node-red-unstorage"; 3 4import * as dotenv from "dotenv"; 5import express from "express"; 6import { createServer } from "http"; 7import nodered from "node-red"; 8import { dirname, resolve } from "path"; 9import { fileURLToPath } from "url"; 10import mongodbDriver from "unstorage/drivers/mongodb"; 11 12dotenv.config(); 13 14const { contextStore, storageModule } = storage({ 15 // A namespace for the storage layer 16 // Allows creating multiple projects with isolated data access 17 app: process.env.APP_NAME || "default", 18 19 // Unstorage instance options, for storageModule (required) 20 storageOptions: { 21 driver: mongodbDriver({ 22 connectionString: process.env.MONGO_DB_URL, 23 databaseName: "nodeRed", 24 collectionName: "storage", 25 }), 26 }, 27 28 // Unstorage instance options, for contextStore (optional) 29 contextOptions: { 30 driver: mongodbDriver({ 31 connectionString: process.env.MONGO_DB_URL, 32 databaseName: "nodeRed", 33 collectionName: "context", 34 }), 35 }, 36}); 37 38const cwd = dirname(fileURLToPath(import.meta.url)); 39 40const settings = { 41 httpAdminRoot: "/", 42 httpNodeRoot: "/api", 43 // The userDir contains the external libraries 44 // Should be at the project root 45 userDir: cwd, 46 nodesDir: resolve(cwd, "nodes"), 47 uiHost: "0.0.0.0", 48 uiPort: parseInt(process.env.PORT) || 8080, 49 credentialSecret: process.env.CREDENTIAL_SECRET || "secret", 50 51 storageModule: storageModule, 52 53 contextStorage: { 54 unstorage: { 55 module: contextStore, 56 }, 57 }, 58}; 59 60// Express is used as suggested in Node-Red docs 61const app = express(); 62 63const server = createServer(app); 64 65app.use("/", express.static("public")); 66 67nodered.init(server, settings); 68 69app.use(settings.httpAdminRoot, nodered.httpAdmin); 70 71app.use(settings.httpNodeRoot, nodered.httpNode); 72 73server.listen(settings.uiPort); 74 75nodered.start();
No vulnerabilities found.
No security vulnerabilities found.