TpExpress

The fastest way to scaffold a modern TypeScript + Eslint + Node.js + Express.js project. Production-ready boilerplate with batteries included and 4 database options to choose from.

Quick Installation
npm create tpexpress

Quick Start Guide

Get up and running in minutes with these simple steps

Step 1: Create Project
# Create a new project
npm create tpexpress my-awesome-project
cd my-awesome-project
Step 2: Development Mode
# Setup environment
# Start development server
npm run dev
Step 3: Production Build
# Setup environment
# Build and start production server
npm run build
npm run start

System Requirements

Make sure you have these installed before getting started

Requirement Version
Node.js v22.19.0+
npm 10.9.3+

Core Technologies

Everything you need to build modern, scalable web applications with TypeScript

TypeScript First

Full TypeScript support with strict configuration, type safety, path mapping (@/ imports), and excellent developer experience out of the box.

4 Database Options

Choose from Drizzle ORM, Mongoose ODM, Prisma ORM, or raw PostgreSQL. Each comes with proper setup and example implementations.

Security Built-in

Helmet, CORS, rate limiting, password hashing with bcrypt, JWT authentication, and session management configured and ready to use.

Fast Development

Hot reload with tsx, ESLint, Git hooks with Husky, comprehensive npm scripts, and modern ES modules support.

Redis Integration

In-memory caching and session storage with Redis and connect-redis for optimal performance and scalability.

Modern Tooling

Zod validation, Axios HTTP client, EJS templating, Morgan logging, and production-ready deployment configuration.

Database Options

Choose your preferred database setup from these professionally configured options

Drizzle ORM + PostgreSQL

Modern, type-safe SQL toolkit with excellent TypeScript integration and lightweight performance.

Mongoose ODM + MongoDB

Feature-rich MongoDB object modeling with built-in validation and schema enforcement.

Prisma ORM + PostgreSQL

Auto-generated type-safe client with powerful migration system and visual database studio.

Raw PostgreSQL

Direct database connection for maximum control and performance optimization.

Security & Performance

Production-ready security configurations and performance optimizations

Security Headers

Helmet middleware for setting various HTTP headers to help protect your app from well-known web vulnerabilities.

Rate Limiting

Express rate limit and slow down middleware to prevent abuse and DDoS attacks on your API endpoints.

Authentication

JWT-based authentication with bcrypt password hashing and secure session management with Redis.

Input Validation

Zod schema validation for request validation with TypeScript integration and automatic error handling.

Environment Configuration

Environment Variables. Setup required before start and dev run

Environment Configuration Example
# Server Configuration
PORT=3000
NODE_ENV=development

# Database
DATABASE_URL=postgresql://user:password@localhost:5432/mydb
REDIS_URL=redis://localhost:6379

# JWT & Security
JWT_SECRET=your-super-secret-jwt-key
JWT_ISSUER=http://localhost:3000
SESSION_SECRET=your-session-secret

# CORS
CORS_ORIGINS="http://localhost:3000,http://localhost:5173"

Available Scripts

Comprehensive npm scripts for development, building, and deployment

Development Scripts
# Start development server with hot reload
npm run dev
# Build TypeScript to JavaScript
npm run build
# Start server
npm run start
Code Quality Scripts
# Run ESLint to check code quality
npm run lint
# Automatically fix ESLint errors
npm run lint:fix
# Run TypeScript type checking
npm run typecheck
# Run complete CI pipeline
npm run ci
Database Scripts (Drizzle/Prisma)
# Generate database schema and types
npm run db:generate
# Apply database migrations
npm run db:migrate
# Open database studio
npm run db:studio

Project Structure

Well-organized codebase with clear separation of concerns and scalable architecture

Directory Structure
my-awesome-project/
├── .husky/                             # Git hooks automation
│   └── pre-commit                      # Pre-commit linting and formatting checks
├── dist/                               # Compiled TypeScript output (production build)
├── prisma/                             # 🔹 Prisma ORM configuration (Prisma setup only)
│   ├── migrations/                     # Database schema migration history
│   └── schema.prisma                   # Database schema definition and client config
├── public/                             # Static assets served directly by Express
├── src/                                # Main application source code
│   ├── config/                         # Application configuration and database connections
│   │   ├── dbs/                        # Database connection configurations
│   │   │   ├── drizzlepgsql.ts         # 🔹 Drizzle ORM + PostgreSQL setup
│   │   │   ├── mongo.ts                # 🔹 MongoDB connection with Mongoose
│   │   │   ├── prismapgsql.ts          # 🔹 Prisma client initialization
│   │   │   └── pgsql.ts                # 🔹 Raw PostgreSQL connection pool
│   │   └── redis.ts                    # Redis cache configuration
│   │   └── env.ts                      # Environment variables validation and parsing
│   ├── controllers/                    # Request handlers and business logic orchestration
│   │   └── userControllers.ts          # User-related HTTP request controllers
│   ├── drizzle/                        # 🔹 Drizzle ORM specific files (Drizzle setup only)
│   │   ├── meta/                       # Migration metadata and state tracking
│   │   └── schema.ts                   # Database schema definitions with TypeScript types
│   ├── lib/                            # Core utility libraries and common functionality
│   │   ├── AppError.ts                 # Custom application error classes
│   │   ├── callBy.ts                   # Function caller identification utility
│   │   ├── callFrom.ts                 # Request origin tracking utility
│   │   ├── globalErrorHandler.ts       # Centralized error handling middleware
│   │   ├── HttpStatusCode.ts           # HTTP status code constants and helpers
│   │   ├── InvalidateCache.ts          # Cache invalidation strategies
│   │   └── notFoundHandler.ts          # 404 error handling middleware
│   ├── middlewares/                    # Express middleware functions
│   │   ├── auth/                       # Authentication and authorization
│   │   │   └── AuthenticateUser.ts     # JWT token validation and user verification
│   │   ├── log/                        # Request logging and monitoring
│   │   │   └── morgan.ts               # HTTP request logger configuration
│   │   └── security/                   # Security-focused middleware
│   │       ├── cors.ts                 # Cross-Origin Resource Sharing configuration
│   │       ├── helmet.ts               # Security headers and protection
│   │       ├── ratelimiter.ts          # API rate limiting and abuse prevention
│   │       ├── session.ts              # Session management and storage
│   │       └── slowdowner.ts           # Request throttling for DDoS protection
│   ├── model/                          # 🔹 Database models (Mongoose/MongoDB only)
│   │   └── User.ts                     # User schema and model definitions
│   ├── routes/                         # API endpoint definitions and routing
│   │   ├── RouteManager.ts             # Centralized route registration and management
│   │   └── userRoute.ts                # User-related API endpoints
│   ├── services/                       # Business logic and data access layer
│   │   └── userServices.ts             # User-related business operations
│   ├── types/                          # TypeScript type definitions and extensions
│   │   ├── express-session.d.ts        # Session object type extensions
│   │   ├── express.d.ts                # Express request/response type extensions
│   │   └── global.d.ts                 # Global type declarations
│   ├── utils/                          # Helper functions and utilities
│   │   ├── generateToken.ts            # JWT token generation and management
│   │   └── getPublicIP.ts              # Client IP address extraction utility
│   ├── validators/                     # Input validation and sanitization
│   │   ├── requestSchema/              # Request validation schemas
│   │   │   └── userSchemaValidation.ts # User input validation rules
│   │   └── validate.ts                 # Validation middleware and error handling
│   ├── views/                          # Frontend templates and static assets
│   │   ├── assets/                     # Static files (CSS, images, icons)
│   │   │   ├── favicon.ico             # Website favicon
│   │   │   └── home.css                # Homepage styling
│   │   └── home.ejs                    # Homepage template (EJS templating)
│   └── app.ts                          # Main application setup and Express configuration
├── .env                                # Environment variables (keep this secure!)
├── .gitignore                          # Git ignore patterns for excluded files
├── drizzle.config.ts                   # 🔹 Drizzle migration and generation config
├── eslint.config.js                    # ESLint code quality and style rules
├── package.json                        # Project dependencies and npm scripts
├── Readme.md                           # Project documentation and setup guide
└── tsconfig.json                       # TypeScript compiler configuration
🔹 Database-Specific Files Legend
Files marked with 🔹 are conditionally included based on your chosen database option
• Each setup includes only the relevant database configuration files
• All other files remain consistent across all database choices

Technology Stack

Built with modern, battle-tested technologies and industry best practices

TypeScript Node.js Express.js ESLint Helmet CORS Redis JWT Bcrypt Zod Morgan EJS Husky Rate Limiter PostgreSQL MongoDB Drizzle ORM Prisma Mongoose

Stats

Stats of Downloads, Typescript, Built-in packages, Database-options

4
Database Options
20+
Built-in Packages
100%
TypeScript
1k+
Downloads

Contributing

Help make TpExpress better for everyone

How to Contribute
# 1. Fork the repository
git clone https://github.com/imvikashkk/create-tpexpress.git
# 2. Create your feature branch
git checkout -b feature/amazing-feature
# 3. Commit your changes
git commit -m 'Add some amazing feature'
# 4. Push to the branch
git push origin feature/amazing-feature
# 5. Open a Pull Request

Built with ❤️ by Vikash Kumar Khunte

Making TypeScript + Express development faster and more enjoyable