A CLI tool to quickly create Express TypeScript applications by pulling from the official template repository and customizing it for your needs.
- π Quick project setup with interactive prompts
- π Well-organized project structure
- π§ Pre-configured with essential middleware and utilities
- π TypeScript support out of the box
- π‘οΈ Built-in security features (rate limiting, XSS protection)
- π Logging with Winston
- π Hot reload for development
- π― Dependency injection container
- β‘ Error handling middleware
npm install -g node-typescript-gennpx node-typescript-gen my-appnode-typescript-gen my-appThis will prompt you for:
- Project name (defaults to the provided name)
- Project description
- Author name
- Version number
- Whether to install dependencies automatically
You can specify a custom template repository URL:
node-typescript-gen my-app --template https://github.com/yourusername/your-template.gitIf you don't provide a project name, the CLI will guide you through all options:
node-typescript-genThe CLI pulls the latest template from the official express-typescript-template repository, removes unnecessary files (LICENSE, .env.example, etc.), and customizes it for your project.
The CLI creates a complete Express TypeScript application with the following structure:
my-app/
βββ src/
β βββ app.factory.ts # Application factory
β βββ config/ # Configuration files
β β βββ app.config.ts
β β βββ database.config.ts
β βββ container/ # Dependency injection container
β β βββ di.container.ts
β βββ lib/ # Utility libraries
β β βββ app-assert.ts
β β βββ async-handler.ts
β β βββ custom-error.ts
β β βββ rate-limit.ts
β βββ logger/ # Logging configuration
β β βββ logger.config.ts
β β βββ logger.service.ts
β βββ middleware/ # Express middleware
β β βββ error-handler.ts
β β βββ morgan-middleware.ts
β β βββ service-protection.ts
β βββ types/ # TypeScript type definitions
β β βββ database.types.ts
β β βββ protection.types.ts
β βββ server.ts # Server entry point
βββ .env # Environment variables
βββ package.json # Project configuration
βββ tsconfig.json # TypeScript configuration
βββ README.md # Project documentation
- Express.js with TypeScript
- Dependency Injection container for better code organization
- Error Handling middleware with custom error classes
- Rate Limiting to protect your API
- Logging with Winston for production-ready logging
- CORS support for cross-origin requests
- XSS Protection middleware
- Environment Configuration with dotenv
- Hot Reload with tsc-watch
- TypeScript configuration optimized for Node.js
- Prettier for code formatting
- Module Aliases for clean imports
- Build Process with TypeScript compilation
- Production Server configuration
- Error Handling for production environments
- Security Middleware enabled by default
After creating your project:
cd my-app
npm install
npm run devYour server will start on http://localhost:3000
You can run a demo to see the generator in action:
npm run demoThis will create a sample project called demo-express-app to demonstrate the functionality.
npm run dev- Start development server with hot reloadnpm run build- Build the project for productionnpm start- Start production servernpm run format- Format code with Prettier
The generated project includes several configuration files:
- app.config.ts - Application configuration
- database.config.ts - Database configuration (ready for your database)
- logger.config.ts - Logging configuration
- .env - Environment variables
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions, please open an issue on GitHub.