SUBID Express App CLI is a command-line tool that helps developers quickly initialize a modern, scalable backend project using Express.js, MongoDB, and Bun.js. This template includes file-based routing, Docker integration, ESLint, Prettier, TypeScript, and Mongoose to jumpstart your development process.
- Express.js: Lightweight, fast, and flexible web framework.
- MongoDB + Mongoose: Integrated schema-based data modeling and NoSQL database.
- Bun.js: Ultra-fast JavaScript runtime for improved performance.
- File-based Routing: Automatically map routes from the file system.
- Docker: Ready-to-use Docker configuration for development and production.
- TypeScript: Static typing for safer and more maintainable code.
- ESLint + Prettier: Enforce code quality and consistent formatting.
You can use bunx
to initialize the project in seconds:
bunx subid-express-app init <project-name>
Or install it globally:
bun install -g subid-express-app
subid-express-app init <project-name>
-
Run the CLI tool to initialize a new project:
bunx subid-express-app init my-project
-
Navigate to the project directory:
cd my-project
-
Start the development server with Bun:
bun run dev
-
Build the project for production:
bun run build
-
Run the production build:
bun run start
- Place route files in the
src/routes/
directory. - Automatically loaded based on file structure.
- Mongoose ORM is pre-configured for seamless database operations.
- Define your database models in
src/models/
.
- All TypeScript configurations are included for better code quality and maintainability.
- Pre-configured
tsconfig.json
for a smooth development experience.
- ESLint: Ensures code quality and enforces best practices.
- Prettier: Automatically formats your code for consistency.
- Ready-to-use
Dockerfile
anddocker-compose.yml
for running your app in a containerized environment.
my-project/
├── src/
│ ├── config/ # Configuration files for different environments
│ ├── controllers/ # Define your controller logic
│ ├── data/ # Seed data and database initialization scripts
│ ├── middlewares/ # Custom middleware functions
│ ├── models/ # Mongoose models for MongoDB
│ ├── routes/ # File-based routing (automatically loaded)
│ ├── services/ # Business logic and services
│ ├── types/ # TypeScript type definitions and interfaces
│ ├── utils/ # Utility functions
│ └── app.ts # Entry point of the application
├── .env # Environment variables
├── .eslint.config.js # ESLint configuration
├── .prettierrc # Prettier configuration
├── bun.build.js # Bun.js build configuration
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Dockerfile for containerization
├── package.json # Project dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # Project documentation
- config/: Configuration files for different environments.
- data/: Seed data and database initialization scripts.
- middlewares/: Custom middleware functions (e.g., loggers, authentication).
- scripts/: Database scripts for migrations and seeding.
- types/: TypeScript type definitions and interfaces.
-
Build and run the application using Docker:
docker-compose up -d --build
-
Stop the containers:
docker-compose down
bun run dev
: Start the development server.bun run build
: Build the application for production.bun run start
: Run the production build.bun run lint
: Lint the codebase using ESLint.bun run format
: Format the code using Prettier.
This project is licensed under the MIT License. See the LICENSE file for more details.
Feel free to reach out or open an issue on the GitHub repository if you have any questions or suggestions!