- JavaScript (MDN) docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript
- ECMAScript (spec, ECMA-262) docs: https://www.ecma-international.org/publications-and-standards/standards/ecma-262/
- TypeScript docs: https://www.typescriptlang.org/docs/
- Node.js docs: https://nodejs.org/
- Express docs: https://expressjs.com/
- React docs: https://react.dev/
- nodemon site: https://nodemon.io/
- nodemon (npm): https://www.npmjs.com/package/nodemon
- bcrypt docs: https://www.npmjs.com/package/bcrypt
- cors docs: https://www.npmjs.com/package/cors
- jsonwebtoken (JWT) docs: https://www.npmjs.com/package/jsonwebtoken
- helmet (npm / docs): https://www.npmjs.com/package/helmet
- morgan (npm / docs): https://www.npmjs.com/package/morgan
- MongoDB docs: https://www.mongodb.com/
- Mongoose docs: https://mongoosejs.com/
- Joi docs: https://joi.dev/
- Joi gitHub: https://github.com/hapijs/joi
- Zod docs: https://zod.dev/
- Zod gitHub: https://github.com/colinhacks/zod
- Jest docs: https://jestjs.io/
- dotenv docs: https://github.com/motdotla/dotenv
- ESLint docs: https://eslint.org/docs/latest/
- Prettier docs: https://prettier.io/docs/
A professional, well-structured TypeScript Node.js API built with Express and MongoDB (Mongoose). This project is designed as a clean starter for building production-grade REST APIs with TypeScript, strong typing, validation, centralized error handling, and sensible defaults for pagination, filtering and searching.
Key highlights
- TypeScript-first codebase with strict compiler settings
- Express for HTTP routing and middleware
Table of contents
- Project status
- Tech stack
- Quick start
Project status
- Version: 2.0.0
- Node.js + TypeScript
- Express
- Clone the repository and install dependencies
git clone https://github.com/md-abu-kayser/typescript-express-mongoose-starter.git
- Create environment file(s)
This project loads environment variables using dotenv. Copy or create an .env file at the repository root. Example values:
- Run in development (auto-reload)
npm run start:dev
## Environment variables
- PORT (required) - HTTP port the server will listen on
- DATABASE_URL (required) - MongoDB connection string
## Available npm scripts
- `npm run start:dev` - Start the app in development using `ts-node-dev` (auto-reload)
- `npm run start:prod` - Run the built production bundle (`node dist/server.js`)
## How the app starts
- Entry point for development: `src/server.ts` - connects to MongoDB then starts the Express app.
- Main Express application: `src/app.ts` - registers middleware, health check and routes.
GET /health
Base path: /api/v1/students
- Create a student
- POST /
- Body shape: { student: { ... } }
- Get students (list)
- GET /
- Query params supported:
- Get single student
- GET /:studentId
- Returns 200 and the student document, or 404 if not found.
- Update student
- PATCH /:studentId
- Body shape: { student: { ...fieldsToUpdate } }
- Delete student (soft delete)
- DELETE /:studentId
- Soft deletes the record by setting
isDeleted: trueand returns the updated document.
Key fields (see src/app/modules/student/student.interface.ts and student.model.ts):
Request validation uses Zod schemas (src/app/modules/student/student.validation.ts) and the validateRequest middleware (src/app/middlewares/validateRequest.ts).
AppError(src/app/utils/AppError.ts) is used to create operational errors with a status code.globalErrorHandler(src/app/middlewares/globalErrorHandler.ts) serializes errors and sends a consistent JSON error envelope.
src/server.ts- app bootstrap, DB connection and process-level error handlingsrc/app.ts- Express initialization, global middleware, and route mounting
Unit and integration tests can be written using Jest (configured in package.json). Example:
Contributions are welcome. A recommended workflow:
- Ensure
NODE_ENV=productionand supply a secureDATABASE_URLwhen deploying. - Build (
npm run build) before starting the production process.
- This project is licensed under the terms of the MIT License.
- You may replace or update the license as needed for client or proprietary projects.
- Name: Md Abu Kayser - Full-Stack Engineer
- Project: typescript-express-mongoose-starter
- Maintainer: md-abu-kayser
- Email: abu.kayser.official@gmail.com
- GitHub: github.com/abu.kayser-official
If you’d like this README tailored for a specific purpose - such as hiring managers, open-source contributors, or client deliverables - feel free to request a custom tone or format. Thank You For Reviewing This Project!