@10abdullahbutt/express-rest-api-starter
v1.0.0
Published
Professional Express.js REST API starter with TypeScript, MongoDB, and comprehensive tooling
Downloads
10
Maintainers
Readme
Express REST API Starter (TypeScript + MongoDB)
A professional, production-ready Express.js REST API boilerplate written in TypeScript, using MongoDB (Mongoose), with best practices for structure, testing, CI/CD, and developer experience.
Features
- TypeScript for type safety and modern development
- Express.js for robust REST APIs
- MongoDB with Mongoose ODM
- Modular structure (
src/modules) for scalable code - Async error handling with reusable
asyncHandler - Comprehensive testing with Jest and Supertest
- ESLint and Prettier for code quality and formatting
- Husky pre-commit hooks for lint, test, and build
- GitHub Actions for CI/CD (test, lint, build, coverage)
- Environment variable management with dotenv
- Rate limiting, security, and logging middleware
- Example User module with CRUD endpoints
Getting Started
1. Clone the repository
git clone <your-repo-url>
cd express-rest-api-starter2. Install dependencies
npm install3. Set up environment variables
Copy .env.example to .env and update as needed:
cp env.example .env4. Start MongoDB
Make sure MongoDB is running locally (default: mongodb://localhost:27017).
5. Run the application
# For development (with hot reload)
npm run dev
# For production build
npm run build
npm start6. Run tests
npm testProject Structure
src/
config/ # Database and app config
middleware/ # Custom Express middleware
modules/ # Feature modules (e.g., users)
users/
controllers/
models/
routes/
services/
__tests__/
routes/ # Main API route aggregator
utils/ # Reusable utilities (e.g., asyncHandler)
test/ # Test setupExample API Endpoints
GET /api/v1/users- List usersGET /api/v1/users/:id- Get user by IDPOST /api/v1/users- Create userPUT /api/v1/users/:id- Update userDELETE /api/v1/users/:id- Soft delete user
Lint, Format, and Type Check
npm run lint # Lint code
npm run format # Format code
npm run type-check # TypeScript type checkHusky Pre-commit Hook
Runs lint, test, and build before every commit to ensure code quality.
GitHub Actions CI/CD
- Runs on push and PR to
main/develop - Lints, type-checks, tests, and builds
- Uploads coverage to Codecov
License
MIT
