{"id":49292498,"url":"https://github.com/bonsaedev/nrg","last_synced_at":"2026-05-11T01:29:02.389Z","repository":{"id":353239649,"uuid":"1216540914","full_name":"bonsaedev/nrg","owner":"bonsaedev","description":"Build fully typed Node-RED nodes","archived":false,"fork":false,"pushed_at":"2026-05-02T00:56:21.000Z","size":291,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-02T02:34:39.760Z","etag":null,"topics":["framework","node-red","nrg"],"latest_commit_sha":null,"homepage":"https://bonsaedev.github.io/nrg/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bonsaedev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-21T02:22:53.000Z","updated_at":"2026-05-02T00:56:23.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bonsaedev/nrg","commit_stats":null,"previous_names":["bonsaedev/nrg"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/bonsaedev/nrg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonsaedev%2Fnrg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonsaedev%2Fnrg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonsaedev%2Fnrg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonsaedev%2Fnrg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bonsaedev","download_url":"https://codeload.github.com/bonsaedev/nrg/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bonsaedev%2Fnrg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32592720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["framework","node-red","nrg"],"created_at":"2026-04-26T01:04:40.215Z","updated_at":"2026-05-08T03:17:07.569Z","avatar_url":"https://github.com/bonsaedev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"nrg-icon\" src=\"https://gist.githubusercontent.com/AllanOricil/84412df273de46b28c5d6945b391afd4/raw/0c9cdb994c40ab3d7b7ad06dcee162145d77d531/nrg-icon.svg\" style=\"width: 200px\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/@bonsae/nrg\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/@bonsae/nrg.svg\" alt=\"npm package\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/bonsaedev/nrg/actions/workflows/ci.yaml\"\u003e\u003cimg src=\"https://github.com/bonsaedev/nrg/actions/workflows/ci.yaml/badge.svg?branch=main\" alt=\"build status\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://socket.dev/npm/package/@bonsae/nrg\"\u003e\u003cimg src=\"https://badge.socket.dev/npm/package/@bonsae/nrg?v=1\" alt=\"Socket Badge\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# nrg\n\nBuild Node-RED nodes with Vue 3, TypeScript, and JSON Schema validation.\n\n## Install\n\n```bash\npnpm add @bonsae/nrg\npnpm add -D vite vue\n```\n\n\u003e `vite` and `vue` are dev dependencies because they are only needed at build time. The Vue runtime is bundled by nrg and served automatically — your published package does not need them at runtime.\n\n## Package Exports\n\n| Export | Description |\n| --- | --- |\n| `@bonsae/nrg` | Root entry — `defineRuntimeSettings` |\n| `@bonsae/nrg/server` | Server node classes, schema utilities, validation (`IONode`, `ConfigNode`, `defineIONode`, `defineConfigNode`, `defineModule`, `SchemaType`, `defineSchema`, `Infer`) |\n| `@bonsae/nrg/client` | Client-side registration (`registerTypes`, `defineNode`) |\n| `@bonsae/nrg/vite` | Vite plugin for building and developing Node-RED packages |\n| `@bonsae/nrg/tsconfig/*` | Shared TypeScript configurations for consumers |\n\n## Quick Start\n\n```bash\n# In your Node-RED package project\npnpm add @bonsae/nrg\npnpm add -D vite vue\n```\n\n**vite.config.ts**\n\n```typescript\nimport { defineConfig } from \"vite\";\nimport { nodeRed } from \"@bonsae/nrg/vite\";\n\nexport default defineConfig({\n  plugins: [nodeRed()],\n});\n```\n\n**src/server/schemas/my-node.ts**\n\n```typescript\nimport { defineSchema, SchemaType } from \"@bonsae/nrg/server\";\n\nexport const ConfigsSchema = defineSchema(\n  {\n    name: SchemaType.String({ default: \"\" }),\n    prefix: SchemaType.String({ default: \"hello\" }),\n  },\n  { $id: \"my-node:configs\" }\n);\n```\n\n**src/server/nodes/my-node.ts**\n\nNRG supports two ways to define nodes:\n\n\u003ctable\u003e\n\u003ctr\u003e\u003cth\u003eFunctional API\u003c/th\u003e\u003cth\u003eClass API\u003c/th\u003e\u003c/tr\u003e\n\u003ctr\u003e\u003ctd\u003e\n\n```typescript\nimport { defineIONode } from \"@bonsae/nrg/server\";\nimport { ConfigsSchema } from \"../schemas/my-node\";\n\nexport default defineIONode({\n  type: \"my-node\",\n  color: \"#ffffff\",\n  inputs: 1,\n  outputs: 1,\n  configSchema: ConfigsSchema,\n\n  async input(msg) {\n    msg.payload = `${this.config.prefix}: ${msg.payload}`;\n    this.send(msg);\n  },\n});\n```\n\n\u003c/td\u003e\u003ctd\u003e\n\n```typescript\nimport { IONode, type Schema, type Infer } from \"@bonsae/nrg/server\";\nimport { ConfigsSchema } from \"../schemas/my-node\";\n\ntype Config = Infer\u003ctypeof ConfigsSchema\u003e;\n\nexport default class MyNode extends IONode\u003cConfig\u003e {\n  static readonly type = \"my-node\";\n  static readonly category = \"function\";\n  static readonly color: `#${string}` = \"#ffffff\";\n  static readonly inputs = 1;\n  static readonly outputs = 1;\n  static readonly configSchema: Schema = ConfigsSchema;\n\n  async input(msg: any) {\n    msg.payload = `${this.config.prefix}: ${msg.payload}`;\n    this.send(msg);\n  }\n}\n```\n\n\u003c/td\u003e\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003eAutomatic type inference, less boilerplate\u003c/td\u003e\n\u003ctd\u003eCustom methods, inheritance, mixins\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/table\u003e\n\n**src/server/index.ts**\n\n```typescript\nimport { defineModule } from \"@bonsae/nrg/server\";\nimport MyNode from \"./nodes/my-node\";\n\nexport default defineModule({\n  nodes: [MyNode],\n});\n```\n\nSee the [consumer template](https://github.com/AllanOricil/node-red-vue-template) for a complete example.\n\n## Project Structure\n\n```\nsrc/\n├── core/                        # Runtime framework\n│   ├── client/                  # Vue 3 editor components\n│   │   ├── app.vue              # Root form wrapper (validation, toggles)\n│   │   ├── components/          # Reusable form inputs\n│   │   │   ├── node-red-input.vue\n│   │   │   ├── node-red-typed-input.vue\n│   │   │   ├── node-red-config-input.vue\n│   │   │   ├── node-red-select-input.vue\n│   │   │   ├── node-red-editor-input.vue\n│   │   │   └── node-red-json-schema-form.vue\n│   │   └── index.ts             # registerType, defineNode\n│   ├── server/                  # Node.js server runtime\n│   │   ├── nodes/               # Node, IONode, ConfigNode classes\n│   │   ├── schemas/             # TypeBox schema system\n│   │   ├── types/               # RED, context store types\n│   │   └── index.ts             # registerTypes, exports\n│   ├── constants.ts\n│   └── validator.ts             # AJV-based validation\n├── test/                        # Test utilities for consumers\n│   ├── index.ts                 # createNode, receive, close, reset\n│   └── mocks.ts                 # RED and Node-RED node mocks\n├── vite/                        # Build tooling\n│   ├── plugin.ts                # Vite plugin factory\n│   ├── plugins/                 # Dev server, build orchestration\n│   ├── server/                  # Server build (CJS/ESM + bridge)\n│   ├── client/                  # Client build (Vue + auto-wiring)\n│   └── index.ts                 # nodeRed(), defineRuntimeSettings()\n└── tsconfig/                    # Shared configs for consumers\n    ├── base.json\n    ├── client.json\n    └── server.json\n```\n\n## Testing\n\nTest your nodes' server-side logic with `@bonsae/nrg/test`:\n\n```bash\npnpm add -D vitest\n```\n\n```typescript\n// tests/my-node.test.ts\nimport { describe, it, expect } from \"vitest\";\nimport { createNode } from \"@bonsae/nrg/test\";\nimport MyNode from \"../src/server/nodes/my-node\";\n\ndescribe(\"my-node\", () =\u003e {\n  it(\"should process messages\", async () =\u003e {\n    const { node } = await createNode(MyNode, {\n      config: { greeting: \"hello\" },\n    });\n\n    await node.receive({ payload: \"world\" });\n\n    expect(node.sent(0)).toEqual([{ payload: \"hello world\" }]);\n  });\n});\n```\n\n```bash\nnpx vitest run\n```\n\n## Development\n\n```bash\npnpm install\npnpm build          # build all (server CJS, client ESM, vite plugin)\npnpm typecheck      # type-check server and client\npnpm lint           # eslint\npnpm format         # prettier\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbonsaedev%2Fnrg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbonsaedev%2Fnrg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbonsaedev%2Fnrg/lists"}