express-laravel-scaffold
Version:
A CLI to scaffold a secure, feature-rich Express.js project with a Laravel-like structure, including an artisan-like CLI.
120 lines (87 loc) • 3.87 kB
Markdown
# Express Laravel Scaffold
[](https://www.npmjs.com/package/express-laravel-scaffold)
A powerful, secure, and feature-rich CLI tool to scaffold a new Express.js project with a structure and feature set inspired by Laravel.
Stop writing boilerplate! `create-express-app` generates a project with everything you need to be productive from day one, including an MVC architecture, an ORM, a templating engine, a queue system, and an `artisan`-like CLI for code generation.
## Features
- **MVC Architecture:** Clean, organized, and scalable project structure.
- **Eloquent-like ORM:** Uses `@adonisjs/lucid` with Knex.js for beautiful and powerful database interactions.
- **Blade-like Templating:** Leverages `@edge/simple` for elegant and component-based views.
- **Artisan-like CLI:** Includes a `craft.js` script to generate controllers, models, and migrations (`npm run craft -- make:controller ...`).
- **Advanced Routing:** A fluent, chainable route builder for creating groups, prefixes, and applying middleware.
- **Built-in Queue System:** A MySQL-based queue using `oxen-queue` for background job processing.
- **Security-First:** Comes with `helmet` and `express-rate-limit` pre-configured.
- **Modern Tooling:** Uses ES6+, DotENV for environment management, and `nodemon` for hot-reloading.
## Installation
Install the CLI globally using npm:
```bash
npm install -g express-laravel-scaffold
```
## Quick Start
1. **Create a new project:**
```bash
create-express-app my-awesome-project
```
2. **Navigate to your project directory:**
```bash
cd my-awesome-project
```
3. **Install dependencies:**
```bash
npm install
```
4. **Configure your environment:**
- Copy the `.env.example` file to a new file named `.env`.
- Update the `.env` file with your MySQL database credentials.
```bash
cp .env.example .env
# Now, open .env and edit your DB_HOST, DB_USER, DB_PASS, etc.
```
5. **Run database migrations:**
This will create the `users` and `oxen_queue` tables.
```bash
npx knex migrate:latest
```
6. **Start the development server:**
```bash
npm start
```
Your application is now running at `http://localhost:3000`.
## The `craft` CLI
The generated project includes a powerful command-line tool to speed up your workflow. Use it to create common files without writing boilerplate.
- **Create a Controller:**
```bash
npm run craft -- make:controller PostController
```
- **Create a Model:**
```bash
npm run craft -- make:model Post
```
- **Create a Migration:**
```bash
npm run craft -- make:migration create_posts_table
```
- **Create a Middleware:**
```bash
npm run craft -- make:middleware CheckAdmin
```
## Project Structure
```
my-awesome-project/
├── config/ # Configuration files (app, database, security)
├── controllers/ # Route handling logic
├── database/
│ └── migrations/ # Database migration files
├── lib/ # Core application libraries (e.g., RouteBuilder)
├── middleware/ # Custom middleware
├── models/ # Lucid ORM models
├── public/ # Static assets (CSS, JS, images)
├── queues/ # Job definitions for the queue system
├── routes/ # Application routes (web.js, api.js)
├── stubs/ # Templates for the 'craft' CLI
├── views/ # Edge templates, layouts, and components
├── .env.example # Example environment file
├── craft.js # The artisan-like CLI tool
├── index.js # Application entry point
└── package.json
```
"# express-laravel-scaffold"