Skip to content

jhordyess/express-ts-starter

Repository files navigation

Express TypeScript Starter

This is a starter project for building a backend application using Express, TypeScript, and Webpack.

Features

  • Express: Fast and minimalist web framework for Node.js. (v. 5)
  • TypeScript: Strongly typed JavaScript for better development experience. (v. 5)
  • Webpack: Module bundler for compiling and optimizing the code. (v. 5)
  • ESLint: Linting for maintaining code quality. (v. 9)
  • Prettier: Code formatting for consistent style. (v. 3)
  • Husky: Git hooks for enforcing pre-push checks. (v. 9)
  • pnpm: Package manager for managing dependencies. (v. 10)

Prerequisites

  1. Install Node.js (LTS version recommended).
  2. Install pnpm globally:
npm install -g pnpm@latest-10

Getting Started

  1. Clone the repository:
git clone https://github.com/jhordyess/express-ts-starter.git
  1. Navigate to the project folder:
cd express-ts-starter
  1. Install dependencies:
pnpm i
  1. Start the development server:
pnpm dev
  1. Open your browser or API client and interact with the server running at http://localhost:3000.

Automatic Lifecycle Scripts

This template includes two useful npm lifecycle scripts configured in package.json.

  • prepare: Runs after install and initializes Husky, so Git hooks (like pre-push) are ready automatically.
  • postinstall: Runs after install and executes pnpm audit --audit-level moderate to check for known vulnerabilities in dependencies.

What this means:

  1. When you run pnpm i, Husky setup is done for you.
  2. A security check is also executed automatically after dependencies are installed.
  3. If vulnerabilities are found, review and update the affected packages before continuing.

Project Structure

express-ts-starter/
├── .env.example            # Example environment variables file.
├── .gitignore              # List of files and directories to be ignored by version control.
├── .prettierrc.json        # Prettier configuration file.
├── eslint.config.js        # ESLint configuration file.
├── package.json            # Project configuration and dependencies.
├── pnpm-lock.yaml          # pnpm lock file for dependency versions.
├── README.md               # Project documentation.
├── tsconfig.json           # TypeScript configuration file.
├── webpack.config.js       # Webpack configuration file.
├── .husky/                 # Directory for Git hooks managed by Husky.
│   ├── pre-push            # Pre-push hook to run linting and TypeScript checks.
├── src/
│   ├── index.ts            # Main entry point of the application.
│   ├── config.ts           # Configuration file for the application.

Commands

Start the development server

pnpm dev

Build the project for production

pnpm build

Build the project for production with validation

pnpm build:validate

Start the production server

pnpm start

Run TypeScript checks

pnpm ts-check

Lint the code

pnpm lint

Validate the project (lint + TypeScript checks)

pnpm validate

Format the code

pnpm format

Contributing

Contributions are welcome! If you find any issues or want to enhance the project, feel free to submit a pull request.


Happy coding!

About

Starter project for using Express with TypeScript, powered by Webpack.

Topics

Resources

Stars

Watchers

Forks

Contributors