bendjs
v1.0.8
Published
Bend CLI - Production-ready backend scaffolder (Global CLI wrapper)
Maintainers
Readme
bendjs
Global CLI for Bend - Production-ready backend scaffolder with enterprise-grade security and logging.
Installation
npm install -g bendjsUsage
# Interactive mode
bend
# With project name
bend my-backend
# Skip dependency installation
bend my-backend --no-installWhat is bendjs?
bendjs is a global CLI wrapper around bend-core. It provides a convenient bend command for users who prefer global installation.
When to use bendjs?
Use bendjs if you:
- Prefer global CLI tools
- Want a short command (
bendinstead ofnpx bend-core) - Create Bend projects frequently
Use create-bend if you:
- Prefer not installing global packages
- Want to always use the latest version
- Follow npm create/init conventions
# Using bendjs (global)
npm install -g bendjs
bend my-project
# Using create-bend (recommended)
npm create bend@latest my-projectFeatures
Every Bend project includes production-ready features:
Security
- helmet() - Security HTTP headers (prevents XSS, clickjacking, etc.)
- cors() - Configurable cross-origin resource sharing
- rateLimit() - DDoS protection (100 requests per 15 minutes per IP)
- hpp() - HTTP parameter pollution prevention
- compression() - Response compression
- Body limits - Prevents memory exhaustion (10MB default)
Logging & Monitoring
- Winston - Enterprise-grade structured logging
- Daily rotation - Automatic log archival (30-day retention)
- Separate logs - error.log, combined.log, exceptions.log
- HTTP logging - Morgan middleware integration
- JSON format - Compatible with DataDog, Splunk, ELK, CloudWatch
Error Handling
- Async error handling - express-async-errors (no try/catch needed)
- Centralized middleware - Single error handler
- Graceful shutdown - Proper cleanup on SIGTERM/SIGINT
- Unhandled rejections - No silent crashes
Stack Options
Choose from 8 production-tested combinations:
- Runtimes: Node.js or Bun (auto-detected)
- Languages: TypeScript or JavaScript
- Frameworks: Express or Fastify
- ORMs: Mongoose (MongoDB) or Prisma (SQL)
Commands
# Create new project
bend my-backend
# Skip installation
bend my-backend --no-install
# Help
bend --help
# Version
bend --versionGenerated Project Structure
my-backend/
├── src/
│ ├── config/
│ │ ├── database.ts # Database connection with retry
│ │ └── logger.ts # Winston + daily rotation
│ ├── controllers/ # Route controllers
│ ├── models/ # Database models
│ │ └── User.model.ts # Example user model
│ ├── routes/ # API routes
│ │ └── health.routes.ts
│ ├── services/ # Business logic
│ ├── middlewares/ # Custom middlewares
│ ├── utils/ # Utility functions
│ ├── app.ts # App + security setup
│ └── server.ts # Entry point + graceful shutdown
├── logs/ # Auto-generated logs
├── .env # Environment variables
├── .gitignore
├── package.json
├── tsconfig.json # (TypeScript projects)
└── README.mdExample Output
// app.ts - Security already configured!
import helmet from 'helmet';
import cors from 'cors';
import rateLimit from 'express-rate-limit';
import hpp from 'hpp';
import compression from 'compression';
import logger from './config/logger';
const app = express();
// Security middlewares
app.use(helmet());
app.use(cors({ origin: process.env.CORS_ORIGIN || '*' }));
app.use(hpp());
// Rate limiting (DDoS protection)
const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // 100 requests per IP
});
app.use('/api/', limiter);
// Compression
app.use(compression());
// HTTP request logging
app.use(morgan('combined', {
stream: { write: (msg) => logger.info(msg.trim()) }
}));Package Ecosystem
Bend provides three packages:
1. create-bend (Recommended for most users)
npm create bend@latestAdvantages:
- No installation needed
- Always uses latest version
- Standard npm create pattern
2. bend-core (For direct usage)
npx bend-coreAdvantages:
- Direct access to core library
- Can be used programmatically
- No global installation
3. bendjs (This package - for global CLI)
npm install -g bendjs
bendAdvantages:
- Short command (
bend) - Installed once, use anywhere
- Traditional CLI feel
Environment Variables
Configure your generated project:
# Server
PORT=3000
NODE_ENV=development
# Database (MongoDB)
MONGODB_URI=mongodb://localhost:27017/myapp
# Database (Prisma - PostgreSQL)
DATABASE_URL="postgresql://user:password@localhost:5432/mydb"
# Security
CORS_ORIGIN=https://yourdomain.com
# Logging
LOG_LEVEL=info # error | warn | info | debugDevelopment Workflow
After generating a project:
# Install dependencies (if skipped)
npm install
# Development mode (auto-reload)
npm run dev
# Production mode
npm start
# Build (TypeScript only)
npm run build
# Linting
npm run lint
npm run lint:fix
# Formatting
npm run formatUpdating
# Update to latest version
npm update -g bendjs
# Check current version
bend --versionUninstalling
npm uninstall -g bendjsWhy Global CLI?
Some developers prefer global CLIs because:
- Shorter commands:
bendvsnpm create bend - Faster execution: No download on each run
- Familiar pattern: Like
create-react-app,vue create, etc. - Offline usage: Works without internet (after installation)
Links
- Main Project: https://github.com/bendhq/bend
- npm (bendjs): https://www.npmjs.com/package/bendjs
- npm (bend-core): https://www.npmjs.com/package/bend-core
- npm (create-bend): https://www.npmjs.com/package/create-bend
- Website: https://bendhq.org
- Documentation: https://bendhq.org/docs
- Issues: https://github.com/bendhq/bend/issues
License
MIT © Bend
Part of Bend - Production-ready backends in seconds.
