Express TypeScript Server Scaffold
npm install nhb-expressQuickly bootstrap a productionβready Express + TypeScript + Zod server with a single command.
> 3 Built-in templates for MongoDB + Mongoose, PostgreSQL + Prisma and PostgreSQL + Drizzle
- Node.js 22 or newer
- Stable internet connection
- npm, pnpm, or yarn for installation
---
- β
TypeScript with ts-node and nodemon for development and pre-configured tsconfig.json
- β
Express.js preβconfigured with custom middlewares
- β
Zod for schema validation
- β
Mongoose for MongoDB integration
- β
Drizzle and/or Prisma for PostgreSQL integration
- β
Stylog from nhb-toolbox for colorful logging
- β
nhb-scripts for easy build, commit, module scaffolding, formatting, linting, and more
- β
Scaffolding via CLI β choose package manager, DB, ORM/ODM etc.
- β
Builtβin CI/CD workflow for automatic deployment to Vercel (Currently only available for Mongoose setup)
---
You donβt need to install anything globally. Run directly with your favorite package manager:
``bashUsing npx
npx nhb-express@latest
Follow the interactive prompts:
- Choose a project name
- Select a database (
MongoDB default)
- Pick your package managerYour new server will be scaffolded in the chosen folder with all dependencies installed.
---
π Quick Start
After running the CLI:
`bash
cd
pnpm dev # or npm run dev / yarn dev
Runs on port: 4242
`---
π Project Structure
$3
`ini
π /
ββ π .github/
β ββ π workflows/
β ββ βοΈ publish.yml # GitHub Actions workflow for CI/CD (vercel deployment)
β
ββ π .vscode/
β ββ π extensions.json # Recommended Extensions for VS Code
β ββ π settings.json # VS Code Settings for better formatting
β
ββ π public/ # Folder contains static files
| ββ πΌοΈ favicon.png # Favicon to show in client application(s) if supported, e.g. Browsers
β
ββ π scripts/ # Helper scripts for development purpose
β
ββ π src/
β ββ π app/ # All source (*.ts) files
β | ββ π classes/ # Utility classes e.g. QueryBuilder, ErrorWihStatus
β | ββ π configs/ # App configurations
β | ββ π constants/ # Constant values
β | ββ π errors/ # Custom error processors/handlers
β | ββ π middlewares/ # Custom Express middlewares
β | ββ π modules/ # Feature modules (controllers, services, etc.)
β | ββ π routes/ # Route definitions
β | ββ π types/ # Types for the App
β | ββ π utilities/ # Helper functions
β |
β ββ π app.ts # Express app setup
β ββ π index.d.ts # Global type declarations
β ββ π server.ts # Server bootstrap
β
ββ π .env # Environment variables
ββ π« .gitignore # Ignore files/folders from being pushed/committed
ββ π« .prettierignore # Ignore files/folders from being formatted with prettier
ββ βοΈ .prettierrc.json # Prettier config
ββ βοΈ eslint.config.mjs # ESLint config (flat config, ready for TS)
ββ βοΈ nhb.scripts.config.mjs # Config for nhb-scripts
ββ βοΈ nodemon.json # Nodemon config
ββ βοΈ package.json # Auto-generated package.json
ββ π README.md # This file
ββ βοΈ tsconfig.json # Ready to use tsconfig
ββ βοΈ vercel.json # Deployment config for Vercel
`$3
`ini
π /
ββ π .vscode/
β ββ π extensions.json # Recommended Extensions for VS Code
β ββ π settings.json # VS Code Settings for better formatting
β
ββ π prisma/
β ββ π schema.prisma # Prisma Schema file
β
ββ π public/ # Folder contains static files
| ββ πΌοΈ favicon.png # Favicon to show in client application(s) if supported, e.g. Browsers
β
ββ π scripts/ # Helper scripts for development purpose
β
ββ π src/
β ββ π app/ # All source (*.ts) files
β | ββ π configs/ # App configurations (CORS, Database, ENV etc.)
β | ββ π constants/ # Constant values
β | ββ π errors/ # Custom error Class/processors/handlers
β | ββ π middlewares/ # Custom Express middlewares
β | ββ π modules/ # Feature modules (controllers, services, etc.)
β | ββ π routes/ # Route definitions
β | ββ π types/ # Types for the App
β | ββ π utilities/ # Helper functions
β |
β ββ π prisma/ # Prisma Client generated files
β |
β ββ π app.ts # Express app setup
β ββ π index.d.ts # Global type declarations
β ββ π server.ts # Server bootstrap
β
ββ π .env # Environment variables
ββ π« .gitignore # Ignore files/folders from being pushed/committed
ββ π« .prettierignore # Ignore files/folders from being formatted with prettier
ββ βοΈ .prettierrc.json # Prettier config
ββ βοΈ eslint.config.mjs # ESLint config (flat config, ready for TS)
ββ βοΈ nhb.scripts.config.mjs # Config for nhb-scripts
ββ βοΈ nodemon.json # Nodemon config
ββ βοΈ prisma.config.ts # Prisma config
ββ βοΈ package.json # Auto-generated package.json
ββ π README.md # Instructions and information
ββ βοΈ tsconfig.json # Ready to use tsconfig
ββ βοΈ vercel.json # Deployment config for Vercel
`$3
`ini
π /
ββ π .vscode/
β ββ π extensions.json # Recommended Extensions for VS Code
β ββ π settings.json # VS Code Settings for better formatting
β
ββ π migrations/ # Migration files (will be) generated by drizzle-kit
β
ββ π public/ # Folder contains static files
| ββ πΌοΈ favicon.png # Favicon to show in client application(s) if supported, e.g. Browsers
β
ββ π scripts/ # Helper scripts for development purpose
β
ββ π src/ # All source (*.ts) files
β ββ π app/ # Application logic and internal configs
β | ββ π configs/ # App configurations (CORS, ENV etc.)
β | ββ π constants/ # Constant values
β | ββ π errors/ # Custom error Class/processors/handlers
β | ββ π middlewares/ # Custom Express middlewares
β | ββ π modules/ # Feature modules (controllers, services, etc.)
β | ββ π routes/ # Route configuration
β | ββ π types/ # Types for the App
β | ββ π utilities/ # Helper functions
β |
β ββ π drizzle/ # Drizzle schema and initialization
β | ββ π schema/ # Contains drizzle schemas
β | ββ π index.ts # Drizzle initialization with all schemas
β |
β ββ π app.ts # Express app setup
β ββ π index.d.ts # Global type declarations
β ββ π server.ts # Server bootstrap
β
ββ π .env # Environment variables
ββ π« .gitignore # Ignore files/folders from being pushed/committed
ββ π« .prettierignore # Ignore files/folders from being formatted with prettier
ββ βοΈ .prettierrc.json # Prettier config
ββ βοΈ drizzle.config.ts # Drizzle config
ββ βοΈ eslint.config.mjs # ESLint config (flat config, ready for TS)
ββ βοΈ nhb.scripts.config.mjs # Config for nhb-scripts
ββ βοΈ nodemon.json # Nodemon config
ββ βοΈ package.json # Auto-generated package.json
ββ π README.md # Instructions and information
ββ βοΈ tsconfig.json # Ready to use tsconfig
ββ βοΈ vercel.json # Deployment config for Vercel
`---
βοΈ CI/CD Workflow
A readyβtoβuse GitHub Actions workflow is included in:
`ini
.github/workflows/publish.yml
`β
What it does:
- Runs on push to your main branch
- Builds your project
- Deploys automatically to Vercel (configured via
vercel.json)β
How to use:
1. Push your project to a GitHub repository.
2. Add your Vercel tokens/secrets as GitHub repository secrets:
Go to
Settings >> Secrets and variables >> Actions >> Repository secrets and add these variables:
- VERCEL_ORG_ID
- VERCEL_PROJECT_ID
- VERCEL_TOKEN
3. Every time you push to main and _version is updated_, GitHub Actions will trigger and deploy your server to Vercel.You can customize the workflow to fit your own CI/CD needs (e.g., change branches, add tests, deploy elsewhere).
---
π οΈ nhb-scripts
This project comes integrated with nhb-scripts β a cli package also by Nazmul Hassan:
β¨ What you get:
-
npm/pnpm/yarn run build β builds your project
- npm/pnpm/yarn run commit β guided commit with semantic messages
- npm/pnpm/yarn run module β scaffolds new modules
- npm/pnpm/yarn run fix β autoβfix lint issues
- npm/pnpm/yarn run format β formats with Prettier
- and _moreβ¦_ configurable via nhb.scripts.config.mjsYou can explore and extend
nhb-scripts` in your project as needed.---
Made with β€οΈ by Nazmul Hassan