Create Express API with TypeScript
Scaffold a minimal Express.js API with TypeScript.
Steps:
- •Ask for the project name if not provided
- •Create project directory and initialize:
npm init -y - •Install dependencies:
bash
npm install express cors dotenv npm install -D typescript ts-node @types/node @types/express @types/cors nodemon
- •Create
tsconfig.jsonwith sensible defaults - •Create folder structure:
code
src/ ├── index.ts # Entry point with basic Express setup ├── routes/ # Route handlers └── middleware/ # Custom middleware
- •Add scripts to package.json:
dev,build,start - •Create a sample health check endpoint at
/api/health - •Add
.env.exampleand.gitignore
Inform user:
- •Run
npm run devto start development server - •Server runs on
http://localhost:3000by default