Skip to content

🔥NodeJs + ExpressJs + TypeScript + Template with Husky, ESLint, Prettier, GitHub Repo Standards (Code of Conduct, License) along with Commitlint.

License

Notifications You must be signed in to change notification settings

AmanKrSahu/backend-starter-template

Repository files navigation

🚀 What Makes This Template Worth Using?

Building an optimized backend project from scratch can be time-consuming and complex. To simplify this process, I've created a boilerplate that streamlines backend development for me and others.

This template includes Node.js, Express.js, and TypeScript, along with strict ESLint rules, Prettier configuration, and essential repository standards. It also integrates best practices for code quality, consistency, and maintainability, making it easier to start new projects efficiently while allowing for future enhancements.


🎁 What's Included in This Template?

This backend template is designed to streamline development with modern tools and best practices. Here's what it includes:

🚀 Technologies Used

  • Node.js v22.13, Express.js v4.21, and TypeScript v5.8 for a robust backend framework.
  • Strict environment enforcement using .npmrc requiring npm v11.1+ and Node.js v20+ for consistency.

📜 Repository Standards

  • Includes CODE_OF_CONDUCT.md and MIT LICENSE to ensure project integrity.
  • Prettier is the default code formatter (prettier configuration).
  • Strict ESLint rules:
    • ESLint configurations ensure clean and maintainable code.
    • Warns about unused variables and enforces TypeScript best practices.
  • Advanced TypeScript configurations (noImplicitAny, strictNullChecks) for type safety (tsconfig.json).
  • Automatic import sorting using ESLint plugins for cleaner code organization.

📦 Installed Dependencies

Production Dependencies

  • express, cookie-parser, cors, dotenv – Essential middleware for API handling and security.

Development Dependencies

  • Linting & Formatting:
    • eslint, eslint-config-prettier, eslint-plugin-prettier, prettier – Enforce code quality.
    • eslint-plugin-import, eslint-plugin-simple-import-sort, eslint-plugin-unicorn – Improve import management.
  • TypeScript & Node Types:
    • @typescript-eslint/eslint-plugin, @typescript-eslint/parser, @types/node, @types/express – Ensure TypeScript best practices.
  • Commit Standards:
    • husky – Set up Git hooks for pre-commit checks.
    • @commitlint/cli, @commitlint/config-conventional – Enforce conventional commits.
  • Development Utilities:
    • ts-node-dev – Enables hot-reloading during development.

This template provides a ready-to-use, optimized backend setup with best practices for scalability, maintainability, and developer efficiency.


💻 Available Commands

Below are the commands you can use along with a brief explanation of their functions:

  • npm run dev – Starts the development server using ts-node-dev, enabling live reloading for faster development.
  • npm run build – Compiles the TypeScript code into JavaScript and copies package.json to the dist folder, preparing the project for production.
  • npm run start – Runs the compiled application from the dist folder in production mode.
  • npm run lint – Analyzes the codebase with ESLint, identifying potential issues and enforcing coding standards.
  • npm run lint:fix – Automatically fixes fixable ESLint issues, improving code quality and consistency.
  • npm run format – Checks if the code is properly formatted using Prettier without making changes.
  • npm run format:fix – Formats all code files using Prettier and writes changes to disk, ensuring a consistent code style.
  • npm run type-check – Runs TypeScript’s type checker to detect type errors without generating compiled output.
  • npm run prepare – Initializes Husky for Git hooks, ensuring pre-commit checks are in place.

These commands help maintain code quality, enforce consistency, and streamline the development workflow.


✅ Guidelines to Run the Backend Locally

Follow these steps to set up and run the backend project on your local machine:

# To install dependencies 
npm install

# To run the server
npm run dev

The server will start, and you can access it at http://localhost:8000 (or the port specified in your environment variables).


Thank You for Using This Template!

If you found this template helpful, please give it a star. It helps others discover it!

For any suggestions or improvements, feel free to open an issue. If you have any feedback, you can reach out to me, Aman Sahu.

About

🔥NodeJs + ExpressJs + TypeScript + Template with Husky, ESLint, Prettier, GitHub Repo Standards (Code of Conduct, License) along with Commitlint.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published