Getting Started with RS Tech Hub Modules

Welcome to RS Tech Hub! This guide will help you get up and running with professionally maintained NestJS infrastructure modules in minutes.

What You'll Build

By following this guide, you'll set up a complete NestJS backend application with:

  • User authentication - Secure JWT-based auth with refresh tokens
  • User management - Complete user CRUD operations
  • Profile system - User profiles with customizable fields
  • Account management - Account lifecycle and settings
  • GraphQL API - Modern API with Apollo Server
  • Database - PostgreSQL with Prisma ORM

All maintained by RS Tech Hub, so you never worry about security patches or dependency updates again.


Prerequisites

Before you begin, make sure you have:

  • Docker 4+ - For running PostgreSQL database
  • Node.js v24+ - Required for NestJS and modules
  • Yarn or npm - Package manager
  • Git - For cloning the demo repository

Quick Start (5 Minutes)

Step 1: Clone the Demo Repository

git clone https://github.com/RuffSantiDev/rs-tech-hub-demo-backend.git
cd rs-tech-hub-demo-backend

This demo repo includes a pre-configured NestJS application with all RS Tech Hub modules integrated.

Step 2: Set Up Environment Variables

Database Password

  1. Copy the database password template:
    cp dbpw.dev.secret-template.txt dbpw.dev.secret.txt
    
  2. Edit dbpw.dev.secret.txt and add your database password on the first line (no labels, just the password)

Application Environment

  1. Copy the environment template:
    cp .env-template.txt .env
    
  2. Edit .env and configure these critical variables:
DATABASE_URL=postgres://admin:YOUR_PASSWORD@localhost:5440/dev
DATABASE_PORT=5440
DATABASE_HOST=localhost

JWT_SECRET=your-random-jwt-secret-here
JWT_REFRESH_SECRET=your-random-refresh-secret-here
SERVICE_TOKEN=your-service-token-here
REQUEST_SIGNING_SECRET=your-signing-secret-here
CSRF_SECRET=your-csrf-secret-here
SESSION_SECRET=your-session-secret-here

BASIC_AUTH_USERNAME=admin
BASIC_AUTH_PASSWORD=your-admin-password

RS_TECH_HUB_NESTJS_STARTER_BUNDLE_LICENSE_KEY=your-license-key-here

Important: Replace all placeholder values with secure random strings. Use openssl rand -base64 32 to generate secure secrets.

Step 3: Start the Database

yarn docker:build:dev

This creates a Docker container with PostgreSQL database:

  • Container name: rs-tech-hub-nestjs-demo-backend
  • Database service: nestjs-starter-backend-db
  • Port: 5440 (configured to avoid conflicts with other PostgreSQL instances)

Step 4: Install Dependencies

yarn install

This installs all required packages, including:

  • All RS Tech Hub modules
  • NestJS core packages
  • Prisma ORM
  • GraphQL and Apollo Server
  • Authentication libraries (Passport, JWT)

Note: If you encounter missing modules after installation, run:

yarn add @rs-tech-hub/nestjs-account-starter@latest @rs-tech-hub/nestjs-auth-core@latest @rs-tech-hub/nestjs-auth-starter@latest @rs-tech-hub/nestjs-clock@latest @rs-tech-hub/nestjs-common-interceptors@latest @rs-tech-hub/nestjs-prisma@latest @rs-tech-hub/nestjs-profile@latest @rs-tech-hub/nestjs-service-operation@latest @rs-tech-hub/nestjs-user@latest @rs-tech-hub/nestjs-test-starter@latest

Step 5: Set Up the Database Schema

The schema is already pre-generated in /generated/.prisma.

You can regenerate it if you have applied changes.

Generate Prisma Client

yarn prisma:gen

This generates the Prisma client in ./generated/.prisma/client

Copy Prisma Client to Modules

yarn postinstall

This runs scripts/copy-prisma-client.js which copies the generated Prisma client into node_modules/@rs-tech-hub/nestjs-prisma/src/lib/generated/client

Important: Run this command after every yarn install or npm install to ensure modules have access to the Prisma client.

Run Database Migrations

yarn prisma:migrate:dev

This initializes the database schema with all required tables:

  • RefreshToken - For JWT refresh token rotation
  • ActivationToken - For email verification
  • User - Core user data
  • Profile - User profile information
  • UserActivity - Activity tracking
  • Account - Account management

Step 6: Start the Server

Development Mode (with hot reload)

yarn start:dev

Production Mode

yarn build
yarn start

Your server will start on http://localhost:4000


Testing Your Setup

GraphQL Playground

Open your browser and navigate to:

http://localhost:4000/graphql

The GraphQL Playground provides an interactive interface where you can:

  • Browse the complete API schema
  • Run queries and mutations
  • Test authentication flows

Example Queries

Try these queries in the playground:

Sign Up a New User

Note: Add the service token to your request headers:

{
  "Authorization": "Bearer YOUR_SERVICE_TOKEN_HERE"
}
mutation {
  auth_signUp(
    email: "user@example.com"
    password: "SecurePassword123!"
    firstName: "John"
    lastName: "Doe"
  ) {
    token
    activationKey
    refreshToken
    user {
      id
      email
      Status
      Role
      accountId
      createdAt
      updatedAt
    }
  }
}

Activate the user

mutation Auth_activateUser {
  auth_activateUser(
    input: {
      email: "user@example.com"
      activationKey: "activationKey-from-signup"
    }
  )
}

Log In

mutation {
  auth_login(email: "user@example.com", password: "SecurePassword123!") {
    token
    refreshToken
    user {
      id
      Status
      Role
      email
      issuerId
      accountId
      createdAt
      updatedAt
    }
  }
}

Get Current User (Requires Authentication)

query {
  auth_currentUser {
    id
    email
    firstName
    lastName
    status
    role
  }
}

Note: Add the access token to your request headers:

{
  "Authorization": "Bearer YOUR_ACCESS_TOKEN_HERE"
}

What's Included

The demo backend comes pre-configured with these RS Tech Hub modules:

ModulePurpose
@rs-tech-hub/nestjs-account-starterAccount lifecycle management
@rs-tech-hub/nestjs-auth-coreJWT authentication foundation
@rs-tech-hub/nestjs-auth-starterComplete auth flow (signup, login, refresh)
@rs-tech-hub/nestjs-clockTimestamp and scheduling utilities
@rs-tech-hub/nestjs-common-interceptorsRequest/response interceptors
@rs-tech-hub/nestjs-prismaPrisma ORM integration
@rs-tech-hub/nestjs-profileUser profile management
@rs-tech-hub/nestjs-service-operationService layer patterns
@rs-tech-hub/nestjs-userUser CRUD operations
@rs-tech-hub/nestjs-test-starterTesting utilities

Available GraphQL Operations

Queries

  • auth_verifyEmail - Verify email address
  • auth_currentUser - Get authenticated user
  • account_getById - Fetch account by ID
  • account_validateData - Validate account data
  • user_getCurrent - Get current user details
  • user_getById - Fetch user by ID
  • user_getByEmail - Fetch user by email
  • profile_get - Get user profile
  • license_getLicenses - View license information

Mutations

  • auth_signUp - Register new user
  • auth_login - Authenticate user
  • auth_refreshToken - Refresh access token
  • auth_logout - End session
  • auth_renewActivationToken - Resend activation email
  • auth_activateUser - Activate user account
  • auth_confirmSignupEmail - Confirm email address
  • auth_updatePassword - Change password
  • account_update - Update account details
  • account_remove - Delete account
  • profile_update - Update user profile
  • test_signUpTestUsers - Create test users (dev only)
  • test_removeTestUsers - Remove test users (dev only)
  • license_resetProductionUsageCount - Reset license usage

Project Structure

rs-tech-hub-demo-backend/
├── src/
│   ├── app/
│   │   ├── app.module.ts        # Root module with all imports
│   │   └── app.service.ts       # Application service
│   └── main.ts                  # Application entry point
├── prisma/
│   ├── starter-schema.prisma    # Database schema
│   └── migrations/              # Database migrations
├── generated/
│   └── .prisma/client/          # Generated Prisma client
├── scripts/
│   └── copy-prisma-client.js    # Prisma client copy script
├── .env                         # Environment variables
├── docker-compose.yml           # Database container config
└── package.json                 # Dependencies and scripts

Next Steps

Now that you have the demo running, you can:

  1. Explore the modules - Check the NPM packages at @rs-tech-hub
  2. Customize your schema - Edit prisma/starter-schema.prisma and run migrations
  3. Add business logic - Build your domain logic on top of the infrastructure
  4. Integrate into your app - Use these modules in your own NestJS project
  5. Extend existing class - Build on top of RS-Tech-Hub service classes by extending them
  6. Get a license - Visit Gumroad to license for production

Troubleshooting

Port Already in Use

If port 4000 is taken, edit src/main.ts:

const port = process.env.PORT ?? 4000; // Change 4000 to your desired port

Docker Database Issues

Restart the Docker container:

docker-compose down
yarn docker:build:dev

Prisma Client Not Found

Make sure to run the postinstall script:

yarn postinstall

Missing Dependencies

Install all required packages manually:

yarn add graphql @apollo/server
yarn add @nestjs/common @nestjs/core reflect-metadata rxjs
yarn add @nestjs/platform-express
yarn add passport @nestjs/passport passport-jwt @nestjs/jwt passport-local bcrypt axios
yarn add @as-integrations/express5

Support & Resources


What Makes This Different?

Unlike typical open-source packages or agency-built code:

Professionally maintained - Security patches within 48 hours
Monthly updates - Dependency updates included
Breaking change notices - 90-day migration warnings
Long-term commitment - No abandonware, guaranteed support
Production-ready - Battle-tested patterns, not experimental code

You build features. We maintain infrastructure.

Ready to stop rebuilding authentication for the 10th time? Grab your license on Gumroad.


Support & Resources