A production-ready boilerplate for building RESTful APIs using Node.js, Express, and TypeScript with Swagger documentation, optimized for Vercel deployment.
- TypeScript: Type-safe JavaScript
- Express: Fast, unopinionated, minimalist web framework
- Swagger Documentation: API documentation with swagger-jsdoc and swagger-ui-express
- Error Handling: Centralized error handling
- Security: Helmet for security headers
- Logging: Winston for logging
- Environment Variables: dotenv for environment variables
- Code Quality: ESLint and Prettier for code quality
- API Monitoring: Health check endpoint
- Vercel Deployment: Ready to deploy on Vercel
/
├── src/
│ ├── api/ # API routes (for Vercel serverless functions)
│ ├── controllers/ # Request handlers
│ ├── middleware/ # Custom middleware
│ ├── routes/ # Route definitions
│ ├── utils/ # Utility functions
│ ├── config/ # Configuration
│ ├── types/ # TypeScript type definitions
│ ├── app.ts # Express app setup
│ └── server.ts # Local development server
├── .env.example # Example environment variables
├── .gitignore # Git ignore file
├── package.json # Package dependencies
├── tsconfig.json # TypeScript configuration
├── vercel.json # Vercel configuration
└── README.md # Project documentation
- Node.js (>= 14.x)
- npm or yarn
- Clone the repository
git clone https://github.com/yourusername/express-typescript-vercel.git
cd express-typescript-vercel
- Install dependencies
npm install
# or
yarn install
- Copy
.env.example
to.env
and update the values
cp .env.example .env
- Start the development server
npm run dev
# or
yarn dev
- Open http://localhost:8000/docs to view the API documentation
npm install -g vercel
# or
yarn global add vercel
vercel login
vercel
You can set environment variables in the Vercel dashboard or with the CLI:
vercel env add JWT_SECRET
vercel --prod
- Create a new controller in
src/controllers
- Create a new route in
src/routes
- Add the route to
src/routes/index.ts
The API documentation is available at /docs
when the server is running.
MIT