The core logic is implemented in packages/create-mvc/src/index.ts
and provides an interactive way to scaffold a new MVC server for your project.
The tool supports the following configuration options:
-
Server Framework
- Express
- Hono (PostgreSQL only)
-
Database
- PostgreSQL
- MongoDB
- MySQL
- SQLite
-
Language
- JavaScript
- TypeScript
You can use the tool in two ways:
- Interactive Mode
npx create-mvc-server
- Template Mode
npx create-mvc-server --template <template-name>
Usage: create-mvc-server [options] [project-name]
Options:
-t, --template NAME Use a specific template
-h, --help Display this help message
The following templates are available:
pg-ts
: Express + PostgreSQL + TypeScriptpg
: Express + PostgreSQL + JavaScriptmongo-ts
: Express + MongoDB + TypeScriptmongo
: Express + MongoDB + JavaScriptmysql-ts
: Express + MySQL + TypeScriptmysql
: Express + MySQL + JavaScriptsqlite-ts
: Express + SQLite + TypeScriptsqlite
: Express + SQLite + JavaScripthono-pg-ts
: Hono + PostgreSQL + TypeScripthono-pg
: Hono + PostgreSQL + JavaScript
- Interactive CLI prompts for project configuration
- Git repository initialization option
- Automatic package name validation
- Smart template selection based on chosen options
- Support for multiple package managers (npm, yarn)
- Directory conflict resolution
- Automatic file renaming (e.g., _gitignore → .gitignore)
The generated project will include:
- Basic server setup with chosen framework
- Database configuration
- Type definitions (for TypeScript projects)
- Basic routing structure
- Error handling middleware
- Environment configuration
- Testing setup
# Create a new project with interactive prompts
npx create-mvc-server my-server
# Create a new project using a specific template
npx create-mvc-server my-server --template pg-ts
After project creation, follow the printed instructions to:
- Navigate to the project directory
- Install dependencies
- Start the development server
Depending on your chosen database, you'll need to:
- Install PostgreSQL locally or use a cloud service (e.g., AWS RDS, DigitalOcean)
- Set up connection details in your
.env
file:DATABASE_URL=postgresql://user:password@localhost:5432/dbname
- Install MongoDB locally or use MongoDB Atlas
- Set up connection details in your
.env
file:MONGODB_URI=mongodb://localhost:27017/dbname
- Install MySQL locally or use a cloud service
- Set up connection details in your
.env
file:DATABASE_URL=mysql://user:password@localhost:3306/dbname
- No additional installation required
- Set up database path in your
.env
file:DATABASE_URL=file:./dev.db
The generated server can be deployed to various platforms:
- Supabase: Supports PostgreSQL, MongoDB, MySQL, and SQLite
- Heroku: Supports all database options
- Vercel: Works well with Serverless deployment (especially Hono)
- DigitalOcean: Supports all database options
- AWS: Can be deployed to EC2, ECS, or Lambda
- Railway: Excellent for both application and database hosting
Remember to:
- Set up appropriate environment variables
- Configure your database connection string
- Set up proper security measures (e.g., SSL, firewalls)