Welcome to the Express TypeScript Starter project! This starter kit helps you quickly set up and develop an Express server using TypeScript, making it easier to build scalable and maintainable Node.js applications.
This project contains a starter setup for building RESTful APIs with Express and TypeScript. It supports environment configuration through .env
files, input validation with Joi, and database interactions via Mongoose.
- Built with Express for fast server-side development.
- Written in TypeScript for type safety and modern JavaScript features.
- Environment variable management with
dotenv
. - Schema validation using
joi
. - MongoDB support through
mongoose
. - Automated dev-restart with
nodemon
.
- Node.js: Make sure you have Node.js installed on your machine. You can download it from nodejs.org.
- NPM: Comes bundled with Node.js, but ensure it's updated.
-
Clone the repository:
git clone https://github.com/Ekans111/express-typescript-mongodb-starter.git cd express-typescript-mongodb-starter
-
Install dependencies:
npm install
-
Set up environment variables:
- Create a
.env
file in the root directory. - Define your environment variables referring .env.example (e.g.,
PORT=5000
,DB_HOST=localhost
,DB_NAME=mydb
,DB_PORT=27017
).
- Create a
-
Development Server: To start the application in development mode with hot-reloading:
npm run dev
-
Production Build: Compile TypeScript into JavaScript:
npm run build
-
Serve Compiled Code: Run the compiled code in
dist
directory:npm run serve
npm run test
: Run tests (currently not specified).npm run start
: Run the app usingts-node
(without nodemon).npm run dev
: Start the development server withnodemon
.npm run build
: Compile TypeScript to JavaScript.npm run serve
: Start the server using compiled files.
- dotenv: Manages environment variables.
- express: Web framework for Node.js.
- joi: Data validation library.
- mongoose: MongoDB object modeling tool.
- @types/express: Type definitions for Express.
- @types/node: Type definitions for Node.js.
- nodemon: Tool that helps develop Node.js applications by automatically restarting the application when file changes are detected.
- ts-node: TypeScript execution environment and REPL for Node.js.
- typescript: TypeScript language package.
This project is licensed under the ISC License. See the LICENSE file for details.
Feel free to contribute to this starter kit by opening issues or pull requests. Happy coding! 🎉
Author: Ekans111