https://github.com/duckymomo20012/node-red-template
A Node-RED embedded to ExpressJS
https://github.com/duckymomo20012/node-red-template
expressjs iot node-red template
Last synced: 9 months ago
JSON representation
A Node-RED embedded to ExpressJS
- Host: GitHub
- URL: https://github.com/duckymomo20012/node-red-template
- Owner: DuckyMomo20012
- License: mit
- Created: 2022-05-26T16:22:29.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-09-08T16:27:26.000Z (almost 3 years ago)
- Last Synced: 2023-09-08T17:54:03.457Z (almost 3 years ago)
- Topics: expressjs, iot, node-red, template
- Language: JavaScript
- Homepage: https://nodered-template.onrender.com/red/
- Size: 333 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Node-RED Template
A Node-RED embedded into ExpressJS template
View Demo
·
Documentation
·
Report Bug
·
Request Feature
# :notebook_with_decorative_cover: Table of Contents
- [About the Project](#star2-about-the-project)
- [Screenshots](#camera-screenshots)
- [Tech Stack](#space_invader-tech-stack)
- [Features](#dart-features)
- [Color Reference](#art-color-reference)
- [Environment Variables](#key-environment-variables)
- [Getting Started](#toolbox-getting-started)
- [Prerequisites](#bangbang-prerequisites)
- [Run Locally](#running-run-locally)
- [Running Tests](#test_tube-running-tests)
- [Deployment](#triangular_flag_on_post-deployment)
- [Usage](#eyes-usage)
- [Customize Node-RED](#gear-customize-node-red)
- [Access Node-RED editor](#fast_forward-access-node-red-editor)
- [Import flow](#inbox_tray-import-flow)
- [Node-RED dashboard first setups](#one-node-red-dashboard-first-setups)
- [Deploy flow](#rocket-deploy-flow)
- [Roadmap](#compass-roadmap)
- [Contributing](#wave-contributing)
- [Code of Conduct](#scroll-code-of-conduct)
- [FAQ](#grey_question-faq)
- [License](#warning-license)
- [Contact](#handshake-contact)
- [Acknowledgements](#gem-acknowledgements)
## :star2: About the Project
### :camera: Screenshots
### :space_invader: Tech Stack
Client
Server
### :dart: Features
- Feature 1.
- Feature 2.
- Feature 3.
### :art: Color Reference
| Color | Hex |
| --------------- | ---------------------------------------------------------------- |
| Primary Color |  #222831 |
| Secondary Color |  #393E46 |
| Accent Color |  #00ADB5 |
| Text Color |  #EEEEEE |
### :key: Environment Variables
To run this project, you will need to add the following environment variables to
your `.env` file:
- **Node-RED configs:**
`NODERED_USERNAME`: Username to log in to Node-RED editor.
`NODERED_PASSWORD`: Password to login to Node-RED editor.
E.g:
```
# .env
NODERED_USERNAME=admin
NODERED_PASSWORD=password
```
> **Note**: `NODERED_USERNAME` and `NODERED_PASSWORD` is **used for admin
> user**. You can add other users in the file `bin/www`.
Read more about customizing users and other ways to generate passwords:
[Securing Node-RED](https://nodered.org/docs/user-guide/runtime/securing-node-red#editor--admin-api-security).
> **Note**: You change tweak Node-RED settings in file `bin/www`.
You can also check out the file `.env.example` to see all required environment
variables.
## :toolbox: Getting Started
### :bangbang: Prerequisites
This project uses [pnpm](https://pnpm.io/) as package manager:
```bash
npm install --global pnpm
```
### :running: Run Locally
Clone the project:
```bash
git clone https://github.com/DuckyMomo20012/node-red-template.git
```
Go to the project directory:
```bash
cd node-red-template
```
Install dependencies:
```bash
pnpm install
```
Start the server:
```bash
pnpm start
```
OR:
Run with `nodemon`:
```bash
pnpm dev
```
---
Access server:
The server will run on: http://localhost:3000/red/
### :test_tube: Running Tests
To run tests, run the following command:
```bash
pnpm test
```
### :triangular_flag_on_post: Deployment
To deploy this project to Render:
[](https://render.com/deploy?repo=https://github.com/DuckyMomo20012/node-red-template)
## :eyes: Usage
### :gear: Customize Node-RED
- You can custom your Node-RED configuration in file `nodered-settings.ts`.
- `httpAdminRoot`: the root URL for the editor UI. If set to false, all admin
endpoints are disabled. This includes both API endpoints and the editor UI. To
disable just the editor UI, see the disableEditor property below. Default:
`/`.
- `httpNodeRoot`: the root URL for nodes that provide HTTP endpoints. If set to
false, all node-based HTTP endpoints are disabled. Default: `/`.
- `userDir`: the directory to store all user data, such as flow and credential
files and all library data. Default: `$HOME/.node-red`.
- `flowFile`: the file used to store the flows. Default:
`flows_.json`.
- `functionGlobalContext`: Function Nodes - a collection of objects to attach
to the global function context. For example,
```javascript
functionGlobalContext: {
osModule: require('os');
}
```
can be accessed in a function node as:
```javascript
var myos = global.get('osModule');
```
- `adminAuth`: enables user-level security in the editor and admin API. See
[Securing
Node-RED](https://nodered.org/docs/user-guide/runtime/securing-node-red) for
more information.
- This template configure these settings:
```javascript
// nodered-settings.ts
const settings = {
httpAdminRoot: '/red',
httpNodeRoot: '/api',
userDir: './.node-red/',
flowFile: 'flows.json',
functionGlobalContext: {}, // enables global context
adminAuth: {
type: 'credentials',
users: [
// This is admin user credentials
{
username: process.env.NODERED_USERNAME || 'admin',
password: bcryptjs.hashSync(
process.env.NODERED_PASSWORD || 'password',
8,
),
permissions: '*',
},
],
},
};
```
> **Note**: Read more about Node-RED configuration: [Runtime
> Configuration](https://nodered.org/docs/user-guide/runtime/configuration).
### :fast_forward: Access Node-RED editor
- Go to `http://localhost:3000/red/` to view the Node-RED editor.
- Go to `http://localhost:3000/api/ui/` to view web UI (from
node-red-dashboard node).
> **Note**: Remember to deploy your flow before accessing node routes.
### :inbox_tray: Import flow
- Go to the hamburger button on the top right of the editor.
- Click the `Import` button.
- Then import file `flows.json` from folder `data`.
### :one: Node-RED dashboard first setups
- Change the web title in the `dashboard/site` tab (on the right-side panel).
- Change the web main color theme in the `dashboard/theme` tab.
### :rocket: Deploy flow
- Click the `Deploy` button in the Node-RED editor to deploy flow.
- After deploying, your flow will be saved in the `.node-red` folder.
> **Note**: File `flow.json` in the `.node-red` folder will be loaded for the
> next server run. So you can push this `.node-red` folder to your repo to save
> your work, instead of importing the file `flow.json` manually.
## :compass: Roadmap
- [x] Todo 1.
- [ ] Todo 2.
## :wave: Contributing
Contributions are always welcome!
### :scroll: Code of Conduct
Please read the [Code of Conduct](https://github.com/DuckyMomo20012/node-red-template/blob/main/CODE_OF_CONDUCT.md).
## :grey_question: FAQ
- Question 1
- Answer 1.
- Question 2
- Answer 2.
## :warning: License
Distributed under MIT license. See
[LICENSE](https://github.com/DuckyMomo20012/node-red-template/blob/main/LICENSE)
for more information.
## :handshake: Contact
Duong Vinh - [@duckymomo20012](https://twitter.com/duckymomo20012) -
tienvinh.duong4@gmail.com
Project Link: [https://github.com/DuckyMomo20012/node-red-template](https://github.com/DuckyMomo20012/node-red-template).
## :gem: Acknowledgements
Here are useful resources and libraries that we have used in our projects:
- [Node-RED](https://nodered.org/): A powerful tool to build IoT applications.
- [Awesome Readme Template](https://github.com/Louis3797/awesome-readme-template):
A detailed template to bootstrap your README file quickly.