Skip to content

Repository files navigation

Template Node.js TypeScript

A modern Node.js TypeScript template with a well-organized folder structure and best practices.

Requirements

  • Node.js 22.x (LTS)
  • pnpm (recommended) or npm

Getting Started

Instructions for installing dependencies and running the app locally.

# Install dependencies
pnpm install
# Run in development mode
pnpm run dev
# Build for production
pnpm run build
# Start production server
pnpm run start

Project Structure

src/
├── config/ # Configuration files and environment variables
├── constants/ # Application constants and enums
├── middleware/ # Express/HTTP middleware functions
├── services/ # Business logic and service layer
├── shared/ # Shared utilities and helpers
├── types/ # TypeScript type definitions and interfaces
├── utils/ # Utility functions and helpers
└── index.ts # Application entry point
tests/ # Unit and integration tests
dist/ # Compiled JavaScript output (generated)

Folder Descriptions

FolderDescription
config/Environment configuration, app settings, and external service configs
constants/Static values, HTTP status codes, error messages, and app-wide constants
middleware/Request processing middleware (auth, logging, validation, etc.)
services/Business logic layer with reusable service modules
shared/Cross-cutting utilities shared across the application
types/TypeScript interfaces, types, and type guards
utils/Helper functions and utility modules

Scripts

ScriptDescription
devStarts the app in development mode with live reloading
buildCompiles TypeScript to JavaScript (CJS and ESM)
startRuns the compiled app
testRuns unit tests
test:covRuns tests with coverage report
lintRuns ESLint to check and fix code style
formatFormats code using Prettier

Path Aliases

The project uses path aliases for cleaner imports:

import{config}from'@/config';import{HTTP_STATUS}from'@/constants';import{getCurrentTimestamp}from'@/utils';

Docker

Build and run the application using Docker:

docker build -t template-node-typescript .
docker run -p 8080:8080 template-node-typescript

Built With

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A modern Node.js TypeScript template with a well-organized folder structure and best practices.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages