4bnode
v4.0.3
Published
A professional tool to generate a Node.js app by 4Brains Technologies
Downloads
167
Maintainers
Readme
4bnode
██╗ ██╗██████╗ ███╗ ██╗ ██████╗ ██████╗ ███████╗
██║ ██║██╔══██╗████╗ ██║██╔═══██╗██╔══██╗██╔════╝
███████║██████╔╝██╔██╗ ██║██║ ██║██║ ██║█████╗
╚════██║██╔══██╗██║╚██╗██║██║ ██║██║ ██║██╔══╝
██║██████╔╝██║ ╚████║╚██████╔╝██████╔╝███████╗
╚═╝╚═════╝ ╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚══════╝A professional CLI tool and visual dashboard to generate, manage, and test Node.js/Express applications.
Built by 4Brains Technologies.
Quick Start
npx 4bnode init my-app
cd my-app
npm run devYour app runs at http://localhost:3000 with a built-in visual dashboard at http://localhost:3000/_dev.
CLI Commands
Create a Project
npx 4bnode init <name>Scaffolds a new Express project with:
- ES Module syntax
- Environment config (
.env.development,.env.production) - CORS, JSON body parser (50MB limit)
- Static file serving from
public/ - Built-in dev dashboard at
/_dev
Add Features
Use the interactive menu:
npx 4bnode addOr add directly:
| Command | Description |
|---------|-------------|
| 4bnode add api <name> | Create a new API endpoint |
| 4bnode add mongo | Configure MongoDB connection |
| 4bnode add crud | Add CRUD operations to a route |
| 4bnode add login | Add JWT authentication & login |
| 4bnode add socket | Integrate Socket.IO |
| 4bnode add websocket | Add native WebSocket support |
| 4bnode add serialport | Serial port communication |
API Endpoint Creation
4bnode add api usersWhen creating an API endpoint:
- Select HTTP method (GET, POST, PUT, DELETE, PATCH)
- Choose fields from existing model (if available)
- Add custom fields received from client
- File fields auto-configure
multerfor multipart uploads - All routes use
/api/prefix
Schema Management
4bnode schema # Interactive create/view/edit
4bnode schema user # Create or edit 'user' schemaSupported field types: String, Number, Boolean, Date, Array, ObjectId, Mixed, Buffer
Field constraints: required, unique, default
Presets available: user, product, post
List Project Info
4bnode list # Show all models, routes & config
4bnode list models # List models only
4bnode list routes # List routes onlyDashboard Passkey
During npx 4bnode init, you'll be prompted to set a 6-digit passkey to protect the dev dashboard.
To change the passkey later, run inside your project:
4bnode passkeyStart Dev Dashboard
4bnode uiRuns npm run dev and opens the visual dashboard. Must be run inside a 4bnode project.
Visual Dashboard
Access at http://localhost:3000/_dev when running npm run dev.
Dashboard Features
Overview - Project status, configured features, quick stats
Database - MongoDB connection setup, URI management
Schemas - Create, view, edit MongoDB schemas with field management. Add/remove fields, toggle required/unique, set defaults.
API Routes - Full route management:
- Create new routes (Methods, CRUD, Login, Register)
- Add methods to existing routes with field selection
- Select fields from models or add custom fields
- File upload fields auto-configure multer
- View route source code, edit inline
- Share endpoint docs with frontend team (Markdown format)
- Delete routes (removes file + index.js registration)
API Tester - Built-in Postman-like API testing tool:
- REST API, Socket.IO, and WebSocket testing
- Body types: JSON, Form Data, URL Encoded, Raw, Binary
- File uploads: Choose file, send as File or Base64
- Auto-detect fields: Matches URL to route and pre-fills body/form fields from route code
- Path variables: Auto-detects
:idparams, shows editable fields - Query params: Key-value editor, auto-fills from
req.query - Headers: Key-value editor with quick presets (Bearer Auth, JSON, Form Data, URL Encoded, Accept)
- Response viewer: Body + Headers tabs, copy response, save responses
- Collection management: Save requests, organize with responses, delete with confirmation
- Share collection: Generate shareable API documentation page with:
- Endpoint details, headers, body fields
- Code examples (cURL, Fetch, Axios) with copy button
- Form data / file upload code generation
- Saved response examples
- Search/filter endpoints
- Persistent URL (updates on re-share)
- Import from routes: One-click import endpoints from your project routes
- All data persisted in
.4bnode/JSON files (not localStorage)
Real-time - Socket.IO and WebSocket configuration
SerialPort - Serial port setup with path and baud rate config
Environment - View and edit .env.development and .env.production
Generated Project Structure
my-app/
├── index.js # Express app entry point
├── dev-api.js # Dev dashboard API (auto-included)
├── package.json
├── .env.development # Dev environment variables
├── .env.production # Production environment variables
├── .4bnode/ # Dashboard data (tester, shared collections)
├── public/ # Static files
│ ├── index.html # Dashboard UI
│ ├── fonts/
│ └── images/
├── uploads/ # File uploads (when using multer)
└── src/
├── db.js # MongoDB connection (after `add mongo`)
├── models/ # Mongoose schemas
├── routes/ # API route files
└── middleware/
└── auth.js # JWT auth middleware (after `add login`)Real-time Communication
Socket.IO
4bnode add socketAccess in routes via req.io:
router.get('/notify', (req, res) => {
req.io.emit('message', 'Hello from server');
res.json({ sent: true });
});WebSocket
4bnode add websocketAccess in routes via req.wss:
router.get('/broadcast', (req, res) => {
req.wss.clients.forEach(client => {
if (client.readyState === WebSocket.OPEN) {
client.send('Hello from server');
}
});
res.json({ sent: true });
});Help
4bnode -h
4bnode --helpLicense
Proprietary License
(c) 2025 4Brains Technologies. All rights reserved.
Unauthorized copying, distribution, modification, or use of this code is strictly prohibited.
For licensing or commercial use: [email protected]
