Skip to content

alihasnain1221/express-ts-boiler-plate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Express TypeScript Boilerplate 👋

Express TypeScript Boilerplate


Overview

Welcome to express-ts-boiler-plate, a feature-rich and professionally structured boilerplate for building robust and scalable backend applications using Express.js and TypeScript. This boilerplate comes pre-configured with dynamic imports, ESLint, Prettier, and TypeScript settings to ensure a smooth development experience.


Features

  • Dynamic Imports: Leverage the power of dynamic imports to efficiently load modules as needed, enhancing the overall performance of your application.

  • ESLint and Prettier: Maintain a consistent code style and catch potential issues early with ESLint and Prettier configurations included in the project.

  • TypeScript Setup: Harness the benefits of TypeScript for enhanced code readability, maintainability, and early error detection.

  • Multi Environment setup: Ease of multiple environemnts for replicalability.

  • Professional Backend Directory Structure: The boilerplate follows a well-organized and intuitive directory structure that promotes scalability and maintainability of your backend codebase.


Getting Started

Prerequisites

Before you begin, ensure you have the following installed:


Installation

Setup the Boilerplate (Any Directory):

npx express-ts-boiler-plate@latest

The rest would be done via User Interaction.


Configuration

Already created a .env file in the project root and configured with MongoDB connection:

MONGODB_URI=localhost:27017/

Run the Application

Start the application with the following command:

npm dev

To include the additional environment configurations in your README.md, you can revise the section about running the application to not only cover how to start the application in the development environment but also to explain how users can easily switch between different environments by simply modifying the ENVIRONMENT variable. Here's how you might articulate these updates:


Configuring Multiple Environments

To switch between environments, modify the ENVIRONMENT variable in the npm script within the package.json. The default script for the development environment is shown below:

"scripts": {
    "dev": "cross-env ENVIRONMENT=dev nodemon --exec ts-node-dev -r tsconfig-paths/register src/app.ts",
}

For example, to add a production environment, you could add a new script like this:

"scripts": {
    "dev": "cross-env ENVIRONMENT=dev nodemon --exec ts-node-dev -r tsconfig-paths/register src/app.ts",
    "prod": "cross-env ENVIRONMENT=prod nodemon --exec ts-node-dev -r tsconfig-paths/register src/app.ts"
}

And just add .env.prod to the config directory.

To run the application in the production environment, you would then use:

npm run prod

This setup allows for easy configuration and switching between environments, ensuring that your application can be properly configured for different stages of deployment.


Acknowledgments

Special thanks to Najam Bashir and Arslan Ahmad (Really appreciate the Motivation and the starting idea)

And all of my NextTek Team family.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published