create-express-boiler
v1.0.0
Published
A CLI tool to generate production-ready Express.js backends
Downloads
3
Readme
Create Express Boiler
A powerful CLI tool to generate production-ready Express.js backend boilerplates with customizable options for JavaScript or TypeScript, authentication, database integration, and more.
Overview
create-express-boiler is a command-line tool designed to scaffold professional, production-ready Express.js backend projects. With a simple command (npx express-pro --name <project-name>), it prompts you to configure your project with options for:
- Language: JavaScript or TypeScript
- API Type: Authentication (with JWT-based login/register) or public APIs
- Database: None, MongoDB, PostgreSQL, or MySQL
- Package Manager: npm, yarn, or pnpm
- Development Tool: nodemon (JavaScript) or ts-node-dev (TypeScript)
- Port Number: Customizable (default: 3000)
- Dependency Installation: Install dependencies automatically or skip
The generated project includes a modular structure, security middleware, error handling, logging, and example APIs, making it ready for production or development.
Installation
To use create-express-boiler, you need Node.js (LTS version recommended, e.g., 18.x or 20.x) installed. Run the following command to generate a new project:
npx express-pro --name <project-name>This will start the interactive CLI, prompting you to configure your project.
Usage
Run the CLI:
npx express-pro --name my-appFollow the prompts to select your preferences:
? Select language: (JavaScript/TypeScript) ? API type: (Authentication/Public API) ? Database type: (None/MongoDB/PostgreSQL/MySQL) ? Package manager: (npm/yarn/pnpm) ? Development tool: (nodemon/ts-node-dev) ? Port number: (default: 3000) ? Install dependencies now? (Yes/No)Navigate to the Project:
cd my-appSet Up Environment:
- Copy
.env.exampleto.envand update values (e.g.,PORT,DB_URI,JWT_SECRETif applicable).
cp .env.example .env- Copy
Run the Project:
- Development mode:
npm run dev - Production mode:
npm run start
- Development mode:
Test APIs: Use tools like Postman or
curlto test the generated APIs:GET /api/examples: Fetch example resourcesPOST /api/examples: Create an example resource- If authentication is enabled:
POST /api/auth/register: Register a userPOST /api/auth/login: Login and get a JWTGET /api/auth/protected: Access a protected route (requires JWT)
Features
- Customizable Boilerplate: Choose between JavaScript or TypeScript, with or without authentication, and optional database integration.
- Production-Ready:
- Security: Includes
helmet,cors, andexpress-rate-limit. - Error Handling: Global error-handling middleware.
- Logging: Configured with
winstonormorgan. - Environment Variables: Managed with
dotenv.
- Security: Includes
- Authentication: Optional JWT-based authentication with login/register APIs and protected routes.
- Database Support:
- MongoDB: Uses
mongoosewith sample schemas. - PostgreSQL/MySQL: Uses
sequelizewith sample models.
- MongoDB: Uses
- Modular Structure: Organized with MVC pattern (
src/controllers,src/routes,src/models, etc.). - Developer Tools:
- Linting and formatting with
eslintandprettier. - Hot-reloading with
nodemon(JavaScript) orts-node-dev(TypeScript).
- Linting and formatting with
- Git-Ready: Initializes a Git repository with a
.gitignorefile. - Comprehensive Documentation: Generated
README.mdwith setup instructions and API details.
Generated Project Structure
my-app/
├── src/
│ ├── controllers/
│ │ └── exampleController.js (or .ts)
│ ├── routes/
│ │ └── exampleRoutes.js (or .ts)
│ ├── middleware/ (if authentication)
│ │ └── auth.js (or .ts)
│ ├── config/ (if database)
│ │ └── db.js (or .ts)
│ ├── utils/
│ │ └── logger.js (or .ts)
│ └── app.js (or app.ts)
├── .env
├── .env.example
├── .gitignore
├── package.json
├── README.md
├── nodemon.json
└── tsconfig.json (TypeScript only)Example APIs
Public APIs:
GET /api/examples: Returns a list of example resources.POST /api/examples: Creates a new example resource.
Authentication APIs (if enabled):
POST /api/auth/register: Register a user (e.g.,{ "username": "user", "password": "pass" }).POST /api/auth/login: Login and receive a JWT.GET /api/auth/protected: Access a protected route (include JWT inAuthorization: Bearer <token>).
Prerequisites
- Node.js (LTS version, e.g., 18.x or 20.x)
- npm, yarn, or pnpm (based on your choice)
- MongoDB, PostgreSQL, or MySQL (if database integration is selected)
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository: https://github.com/fshrabon151/create-express-app
- Create a feature branch:
git checkout -b feature/your-feature - Commit your changes:
git commit -m "Add your feature" - Push to the branch:
git push origin feature/your-feature - Open a pull request.
Issues
Found a bug or have a feature request? Open an issue at https://github.com/fshrabon151/create-express-app/issues.
License
This project is licensed under the MIT License.
Author
Created by F Shrabon.
