npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

suresh-node-ts-starter

v1.0.2

Published

A modern, production-ready Node.js TypeScript server starter template with decorator-based architecture, Express, Prisma, PostgreSQL, JWT authentication, Redis, and comprehensive testing setup.

Readme

Node.js TypeScript Server Starter

A modern, production-ready Node.js server setup with decorator-based architecture, TypeScript, Express, Prisma, and PostgreSQL.

✨ Features

  • 🎯 Decorator-Based Architecture - Clean, declarative route definitions
  • TypeScript - Full type safety with latest TypeScript features
  • 🚀 Express - Fast, unopinionated web framework
  • 🗄️ Prisma + PostgreSQL - Modern ORM with PostgreSQL database
  • 🔐 Authentication - JWT-based auth with Redis token management
  • 🔒 Security - Helmet.js for security headers
  • 📝 Validation - Joi validation with decorators
  • 📝 Logging - Morgan for HTTP request logging
  • 🌐 CORS - Cross-Origin Resource Sharing enabled
  • 🔄 Hot Reload - Nodemon for development
  • 📦 Modern Tooling - Latest Node.js and TypeScript versions

Prerequisites

  • Node.js >= 18.0.0
  • npm or yarn or pnpm

Installation

Option 1: Scaffold a new project (recommended)

Use the CLI to create a fresh project in a new folder:

npx suresh-node-ts-starter my-new-app
cd my-new-app
npm install

Then follow the .env and database setup steps shown below.

Option 2: Clone this repository

  1. Clone the repository:
git clone <your-repo-url>
cd suresh-node-ts-starter
  1. Install dependencies:
npm install
  1. Set up PostgreSQL database:

    Option A: Using Docker (Recommended for development)

    If you have Docker installed, use one of these commands:

    # Modern Docker (docker compose as subcommand)
    docker compose up -d
       
    # OR if you have docker-compose installed separately
    docker-compose up -d

    If Docker Compose is not installed, you can install it:

    # For Ubuntu/Debian/Kali
    sudo apt install docker-compose
       
    # Or use Docker's built-in compose (recommended)
    # Just use: docker compose (no hyphen needed)

    Option B: Using existing PostgreSQL

    • Make sure PostgreSQL is installed and running on your machine
    • Create a database: createdb suresh_db (or use psql to create it)
  2. Create a .env file:

PORT=3000
NODE_ENV=development
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/suresh_db?schema=public"

# JWT Configuration
JWT_SECRET=your-super-secret-key-change-in-production
JWT_ACCESS_EXPIRY=15m
JWT_REFRESH_EXPIRY=7d

# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_URL=redis://localhost:6379
  1. Set up the database:
# Generate Prisma Client
npm run prisma:generate

# Run migrations
npm run prisma:migrate

# Seed the database (optional)
npm run prisma:seed

Usage

Development

Run the development server with hot reload:

npm run dev

The server will start on http://localhost:3000 (or the port specified in your .env file).

Production

  1. Build the TypeScript code:
npm run build
  1. Start the production server:
npm start

Other Scripts

  • npm run type-check - Type check without building
  • npm run clean - Remove the dist folder

Project Structure

This project uses a decorator-based architecture for clean, scalable code. See PROJECT_STRUCTURE.md for detailed documentation.

src/
├── config/              # Configuration (env, database)
├── controllers/         # Decorator-based controllers
├── core/               # Core framework (router, registry)
├── decorators/         # Custom decorators (@Controller, @Get, etc.)
├── middlewares/        # Express middlewares
├── services/           # Business logic layer
├── validations/        # Joi validation schemas
├── utils/              # Utility functions
├── app.ts              # Express app setup
└── server.ts           # Server entry point

API Endpoints

Public Endpoints

  • GET / - Welcome message
  • GET /health - Health check endpoint
  • GET /api - API information

Authentication Endpoints

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • POST /api/auth/refresh - Refresh access token
  • POST /api/auth/logout - Logout (requires auth)
  • POST /api/auth/me - Get current user (requires auth)

Protected User Endpoints (Require Authentication)

  • GET /api/users - Get all users (with pagination, search, sorting)
  • GET /api/users/:id - Get user by ID
  • POST /api/users - Create user
  • PUT /api/users/:id - Update user
  • DELETE /api/users/:id - Delete user (admin only)

See AUTH_MODULE.md for detailed authentication documentation.

Development

Decorator-Based Architecture

This project uses decorator-based architecture for clean, maintainable code. See PROJECT_STRUCTURE.md for detailed documentation.

Adding New Controllers

  1. Create a controller file: src/controllers/product.controller.ts
import { Controller, Get, Post, Body } from '../decorators';
import { Validate } from '../decorators/validate';

@Controller('/products')
export class ProductController {
  @Get('/')
  async getProducts() {
    return { products: [] };
  }

  @Post('/', Validate(createProductSchema))
  async createProduct(@Body() body: any) {
    return { created: body };
  }
}
  1. Export from src/controllers/index.ts
  2. Register in src/core/controllers.registry.ts

Using Services

Services contain business logic:

import { UserService } from '../services';

const users = await UserService.getUsers({ page: 1, limit: 10 });

Validation

Apply validation using decorators:

@Post('/', Validate(createUserSchema))
async createUser(@Body() body: any) {
  // body is already validated
}

TypeScript Configuration

The project uses strict TypeScript settings. Modify tsconfig.json to adjust compiler options.

License

MIT