A Laravel-inspired Node.js framework built with Express.js and MongoDB.
- Full documentation: Bush.js Docs README
- GitHub repository: SaadMajeed565/BushJS
- π Express.js HTTP server with middleware support
- π MongoDB integration with Mongoose ODM
- π£οΈ Laravel-style routing with controllers
- π Authentication system with guards and middleware
- β Request validation with custom rules
- π Database schemas and seeders
- π― Service container for dependency injection
- π₯οΈ CLI commands for scaffolding
- π Laravel-like folder structure
- π Comprehensive documentation with examples in
docs/
- Node.js 22+
- MongoDB 4.0+
- npm or yarn
Project scaffolding is handled by the CLI package, not by the framework core.
Install the CLI package and use:
npx bushjs-cli new project-nameThen install dependencies and run:
cd project-name
npm install
npm run devOnce your project is created, you can scaffold common pieces with:
npx bush make:controller MyController
npx bush make:model User
npx bush make:middleware AuthMiddleware
npx bush make:request RegisterRequest
npx bush make:policy UserPolicy
npx bush make:route users
npx bush make:command SampleCommand-
Install MongoDB:
# Ubuntu/Debian sudo apt-get install mongodb # macOS with Homebrew brew install mongodb-community # Or use Docker docker run -d -p 27017:27017 --name mongodb mongo:latest
-
Clone and install:
git clone <repository> cd bush-js npm install
-
Environment setup:
cp .env.example .env # Edit .env with your MongoDB connection string -
Start MongoDB:
# If installed locally sudo systemctl start mongodb # Or with Docker docker start mongodb
Read the full framework docs in docs/README.md, including guides for:
- routing and controllers
- middleware and validation
- authentication and authorization
- database models and schema files
- GraphQL and realtime WebSockets
- CLI-generated app basics and advanced custom architecture with
bushjs
-
Build the project:
npm run build
-
Start the development server:
npm run dev # Uses nodemon for auto-restart on file changes # or npm start # Production build
-
Run schemas:
npm run cli make:schema create_users npm run cli schema
-
Run seeders:
npm run cli make:seeder initial_users npm run cli seed
-
Test the API:
curl http://localhost:3000/ # Returns: "Welcome to bush.js β your Node.js framework"
bush-js/
βββ app/ # Application code
β βββ Http/
β β βββ Controllers/ # Controller classes
β β βββ Middleware/ # Custom middleware
β βββ Models/ # Mongoose models
βββ routes/ # Route definitions
β βββ api.ts # REST routes
β βββ graphql.ts # GraphQL registration
β βββ websocket.ts # WebSocket registration
βββ config/ # Configuration files
βββ database/ # Database related files
β βββ schemas/ # Schema files
βββ src/ # Framework core
βββ storage/ # File storage
βββ tests/ # Test files
βββ .env # Environment variables
βββ package.json
# Register a user
curl -X POST http://localhost:3000/users \
-H "Content-Type: application/json" \
-d '{"name": "John Doe", "email": "admin@bushjs.com"}'
# Login
curl -X POST http://localhost:3000/login \
-H "Content-Type: application/json" \
-d '{"email": "admin@bushjs.com", "password": "password"}'
# Get profile (requires authentication)
curl http://localhost:3000/profile \
-H "Authorization: Bearer <token>"// app/Models/User.ts
import { Model } from '@framework/Database/Model';
export class User extends Model {
static collection = 'users';
static initialize(): void {
this.schema = new Schema<IUser>({
name: { type: String, required: true },
email: { type: String, required: true, unique: true },
password: { type: String },
});
}
}
// Usage
const users = await User.all();
const user = await User.find('user_id');// routes/api.ts
import { Application } from '@framework';
export function registerRoutes(app: Application) {
app.get('/', [WelcomeController, 'index']);
app.post('/users', [UserController, 'store']).middleware([AuthMiddleware]);
}
// routes/graphql.ts
import { Application } from '@framework';
export function registerRoutes(app: Application) {
app.graphql('/graphql', schema, rootValue);
}
// routes/websocket.ts
import { Application } from '@framework';
export function registerRoutes(app: Application) {
app.socket('/chat', ChatSocketHandler);
}// In a controller
const data = await this.validate(request, {
name: [rules.required(), rules.min(2), rules.max(50)],
email: [rules.required(), rules.email()],
});# Create a new controller
npm run cli make:controller UserController
# Create a new model
npm run cli make:model User
# Create a new schema
npm run cli make:schema create_users
# Run schema files
npm run cli schema- Language: TypeScript instead of PHP
- Database: MongoDB with Mongoose instead of SQL with Eloquent
- HTTP Server: Express.js instead of built-in PHP server
- Package Manager: npm instead of Composer
- Syntax: JavaScript/TypeScript syntax while maintaining Laravel-like patterns
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License