Skip to content
/ express-ts Public template

A production-ready starter template for building robust backend applications using Express.js and TypeScript. This template includes a well-structured setup, essential tools, and best practices to streamline your development process.

License

Notifications You must be signed in to change notification settings

prasadsawant7/express-ts

Repository files navigation

Express TypeScript Template

A production-ready starter template for building robust backend applications using Express.js and TypeScript. This template includes a well-structured setup, essential tools, and best practices to streamline your development process.

Features

  • Web Library: express - A fast, unopinionated web framework for Node.js.
  • Type Checking: typescript - Enhances JavaScript with static typing for safer and scalable code.
  • Development Server: nodemon - Automatically restarts the server on code changes during development.
  • Linting & Formatting: eslint & prettier - Ensures code quality and enforces a consistent code style.
  • Pre-commit hook: husky & lint-staged - Runs automated checks on staged files before committing.
  • Testing: jest & supertest - Comprehensive testing framework with HTTP assertion capabilities.
  • Documentation: swagger-jsdoc & swagger-ui-express - Generates and serves interactive API documentation.
  • Logging: winston & morgan - Centralized logging with request logging for better monitoring.
  • Security Enhancements: helmet & cors - Adds essential HTTP headers and enables Cross-Origin Resource Sharing.
  • Environment Variables: dotenv - Simplifies configuration management through .env files.
  • Module Alias: module-alias - Provides cleaner imports with custom path aliases.

Prerequisites

  • Node.js (version 14 or above)
  • npm or yarn

Installation

  1. Clone the repository:

    git clone https://github.com/prasadsawant7/express-ts.git
    cd express-ts
  2. Install dependencies:

    npm install

Scripts

Script Description
npm run build Builds the TypeScript code into JavaScript.
npm start Starts the app in production mode.
npm run start:dev Starts the app in development mode with Nodemon.
npm run test:unit Runs unit tests using Jest.
npm run test:e2e Runs end-to-end tests using Jest.
npm run lint Lints the code using ESLint.
npm run format Formats the code using Prettier.
npm run prepare Prepares the project by installing Husky hooks.

Project Structure

express-ts/
├── .husky
│ ├── _/ # Contains scripts and binaries related to husky
│ ├── pre-commit # Pre-Commit Script
├── coverage/ # Testing Code Coverage Reports
├── dist/ # Compiled JavaScript output
├── logs/ # All & Error Logs
├── src/
│ ├── __tests__/ # Test Code
│ │ ├── e2e/ # End-to-End Testing
│ │ ├── unit/ # Unit Testing
│ ├── controllers/ # Define controller logic
│ ├── libs/ # Shared libraries and utilities
│ ├── middlewares/ # Custom middleware
│ ├── routes/ # Application routes
│ ├── main.ts # Entry point of the application
├── .eslintignore # Ignores files from getting linted by ESLint
├── .gitignore # Ignores files from getting tracked by Git
├── .prettierignore # Ignores files from getting formatted by Prettier
├── .prettierrc # Prettier configuration
├── .eslint.config.mjs # ESLint configuration
├── .jest.config.ts # Jest configuration
├── nodemon.json # Nodemon configuration
├── package.json # Project metadata and scripts
├── tsconfig.jest.json # TypeScript configuration for Jest
├── tsconfig.json # TypeScript configuration for the whole project

Important

Remove the package-lock.json entry from .gitignore

About

A production-ready starter template for building robust backend applications using Express.js and TypeScript. This template includes a well-structured setup, essential tools, and best practices to streamline your development process.

Topics

Resources

License

Stars

Watchers

Forks