Production-ready backend scaffolder for Node.js and Bun - Core library
npm install bend-core
bash
npx bend-core
`
$3
`bash
npm install -g bend-core
bend-core
`
$3
`bash
npm install bend-core
`
Usage
$3
`bash
Interactive mode
npx bend-core
With project name
npx bend-core my-backend
Skip dependency installation
npx bend-core my-backend --no-install
`
$3
`javascript
import { createProject } from 'bend-core';
await createProject({
projectName: 'my-backend',
runtime: 'nodejs', // or 'bun'
language: 'ts', // or 'js'
framework: 'express', // or 'fastify'
orm: 'mongoose', // or 'prisma'
packageManager: 'npm', // or 'pnpm', 'yarn', 'bun'
skipInstall: false,
});
`
What You Get
Every generated project includes:
$3
- helmet - Security HTTP headers
- cors - Cross-origin resource sharing
- rate-limit - DDoS protection (100 req/15min)
- hpp - HTTP parameter pollution prevention
- compression - Response compression
- body limits - Prevents memory exhaustion
$3
- Winston - Enterprise-grade logging
- Daily rotation - Automatic log archival
- Structured metadata - JSON format
- HTTP logging - Morgan middleware integration
- Separate logs - error, combined, exceptions
$3
- Async error handling - express-async-errors
- Centralized middleware - Single error handler
- Graceful shutdown - Proper cleanup
- Unhandled rejection handlers - No silent crashes
Templates
All 8 template combinations are included:
| Language | Framework | ORM | Status |
|----------|-----------|-----|--------|
| TypeScript | Express | Mongoose | ✅ |
| TypeScript | Express | Prisma | ✅ |
| TypeScript | Fastify | Mongoose | ✅ |
| TypeScript | Fastify | Prisma | ✅ |
| JavaScript | Express | Mongoose | ✅ |
| JavaScript | Express | Prisma | ✅ |
| JavaScript | Fastify | Mongoose | ✅ |
| JavaScript | Fastify | Prisma | ✅ |
Project Structure
Generated projects have this structure:
`
my-backend/
├── src/
│ ├── config/
│ │ ├── database.ts # DB connection
│ │ └── logger.ts # Winston config
│ ├── controllers/ # Controllers
│ ├── models/ # DB models
│ ├── routes/ # API routes
│ ├── services/ # Business logic
│ ├── middlewares/ # Custom middleware
│ ├── utils/ # Utilities
│ ├── app.ts # App setup
│ └── server.ts # Entry point
├── logs/ # Auto-generated logs
├── .env # Environment vars
├── .gitignore
├── package.json
├── tsconfig.json # (TypeScript)
└── README.md
`
API Reference
$3
Creates a new backend project.
Parameters:
`typescript
interface CLIOptions {
projectName?: string; // Project directory name
runtime?: 'nodejs' | 'bun'; // Runtime (auto-detected)
language?: 'ts' | 'js'; // Language
framework?: 'express' | 'fastify'; // Framework
orm?: 'mongoose' | 'prisma'; // ORM
packageManager?: 'npm' | 'pnpm' | 'yarn' | 'bun'; // PM (auto-detected)
skipInstall?: boolean; // Skip npm install
noInstall?: boolean; // Alias for skipInstall
}
`
Returns: Promise
Example:
`typescript
import { createProject } from 'bend-core';
await createProject({
projectName: 'my-api',
language: 'ts',
framework: 'fastify',
orm: 'prisma',
});
`
Environment Variables
Generated projects support these environment variables:
`bash
Server
PORT=3000
NODE_ENV=development
Database (MongoDB)
MONGODB_URI=mongodb://localhost:27017/myapp
Database (Prisma)
DATABASE_URL="postgresql://user:pass@localhost:5432/mydb"
Security
CORS_ORIGIN=https://yourdomain.com
Logging
LOG_LEVEL=info # error | warn | info | debug
`
Dependencies
Core Dependencies:
- @clack/prompts - Interactive CLI prompts
- commander - CLI framework
- ejs - Template engine
- picocolors - Terminal colors
Template Dependencies (included in generated projects):
- express | fastify - Web framework
- mongoose | prisma - ORM
- helmet - Security headers
- cors - CORS handling
- express-rate-limit - Rate limiting
- hpp - Parameter pollution prevention
- winston - Logging
- winston-daily-rotate-file - Log rotation
- morgan - HTTP logging
- compression - Response compression
- dotenv - Environment variables
Development
This is part of the Bend monorepo. See the main README for development instructions.
$3
`bash
pnpm build
`
$3
`bash
node dist/cli/index.js my-test-project
``